GetTextBoundsAsync claims PreloadAsync can be used to make sure font is loaded. This is inaccurate

The documentation claims that using PreloadAsync can be used to make sure a font is loaded before doing GetTextBoundsAsync.

Can repro here

local ContentProvider = game:GetService("ContentProvider")
local TextService = game:GetService("TextService")

ContentProvider:PreloadAsync({ Font.fromName("BungeeInline").Family })

local CharacterTextBoundParams = Instance.new("GetTextBoundsParams")
CharacterTextBoundParams.Text = "TEST"
CharacterTextBoundParams.Font = Font.fromName("BungeeInline")
CharacterTextBoundParams.Size = 32
CharacterTextBoundParams.Width = 32

print(TextService:GetTextBoundsAsync(CharacterTextBoundParams))

Font family rbxasset://fonts/families/BungeeInline.json failed to load: Temp read failed.
Temp read failed.

This in turn makes it impossible to use GetTextBoundsAsync for its intended purposes (to get text bounds of the newer fonts) as all the newer fonts have this temp read failed error. Having test with numerous fonts, this is 100% the case. Default fonts on Roblox work fine, but none of the custom fonts work

Upon further testing, this also does not work when doing the id, if I do both Font.new(“rbxassetid://12187370000”) and Font.fromId(12187370000) it still gives the same warning

Expected behavior

The font to be loaded and no potential read warnings

Page URL: https://create.roblox.com/docs/reference/engine/classes/TextService#GetTextBoundsAsync

1 Like

This is just an acknowledgment announcement!

We’ve filed a ticket into our internal database for this issue, and we will update you when we have further information!

Thanks for the report!

I had to use a clunky workaround, but I assume it was intentional. To me, fromName should include ALL fonts, but it seems fromName only works with the old fonts. So now, I have to manually go and grab and every single new fonts ids and paste it into a module

Yeah, Font.fromName only works with fonts that are bundled with the app. Other fonts are by asset ID, just like other assets like images and audio. After fixing that issue, does the issue with PreloadAsync still occur?

After editing the repro script to use the asset ID, it works correctly for me.