What is the reason of showing squares instead of t...
# compose-web
a
What is the reason of showing squares instead of the default text until custom fonts are loaded? Is it intended or is it going to be fixed? Looks so bad
1
👀 1
e
s
No, this would only make it load faster but depending on the network connection and the font size (especially looking at cjk here) definitely not a fix. this would help but it's still experimental. https://developer.mozilla.org/en-US/docs/Web/API/Local_Font_Access_API It would allow using system fonts as default and more importantly, display text for languages where no font is provided. Every site that's shipped globally and allows user generated content should technically provide minimalistic fonts for all major languages. obviously this means massive amounts of useless MB for unrelated users
a
im clueless about the CMP internals but this seems like an intended implementation than 'there is no X API support yet' issue. trying to understand if this is something to work around or not
c
But you are doing the trick with
Copy code
if (font == null) Loading() else Content()
Like in the example from the PR?
1
a
@Chrimaeon I am not and that is not the point. My question is why show ugly squares instead of something that does not require special handling (ie text with default styling). That is not a sensible default
c
Well, the font you use you use as your „default“ does not have those glyphs so it draws the „tofu“ until the font that contains the glyph is loaded.
trying to understand if this is something to work around or not
The null check is the work around.
a
@Chrimaeon the 'default' font is the default font from compose. the 'glyphs' are normal text characters
c
There is no default font in compose web. The necessary API is experimental as Dominik pointed out.
a
We are talking about a different thing When you render something in compose web by doing
BasicText("Hello")
that "Hello" is printed without me having to specify any fonts. So, why not use those defaults to render the text while a font is loaded instead of loading squares?
c
Ah, okay. And when do you see the tofu then? When having a theme with custom fonts?
a
@Chrimaeon whenever i load custom fonts. I'll open a ticket eventually for it with code samples