Re: Fonts in localized web apps. I'm building an ...
# multiplatform
b
Re: Fonts in localized web apps. I'm building an app that has a web version. JS now since wasmJs doesn't support everything i need. I've just run into an issue I am not sure what to do about. The app is designed to support about 55 languages, but since this is all rendering in a canvas, the theme needs to have all 25 fonts to support 55 languages. thats 40mb+ just in fonts. I can dynamically build the theme based on the users locale, but then if the user happens across content in a font it doesn't have, you get tofus (little boxes). Is anyone working with kmp web and supporting multiple languages? What are you doing about the massive font load?
I'm thinking Skia really need to be able to fall back the browsers system fonts. this is pretty much untenable. Seems I'm also hitting bug #3967, where the ui recomposition is not triggered. These fonts are massive, the web app is just choking on them, especially the CJK font.
Update: i'm reading that there is an experimental font loader coming in future versions.
o
You can use an api to translate at load time according to the user language. Instead of font file. I think that will be a good approach
d
Sorry if this is a dumb question, but why 55 fonts to support 55 languages? Don't you use Unicode? One and only one font should be enough for your 55 languages, shouldn't it?
b
@Ohiorenua Aigboje i will do that in some cases, but translation is not always all that good. Also, if the font is not there to render, then translating doesn't do you any god, ,because you can't display the translation. If the native apps support all those languages, there is no problem because they already have the font, the problem is the webApp doesn't, and has to loading them, because Skia doesn't have access to the browsers fonts. IMO That really needs to change, as it makes localization extremely difficult for webApps.
@Didier Villevalois Yes or course I'm using unicode, is there another way to do this? To answer the question, you don't have to load 55 fonts, you need to load about 25 of them to support all 55 languages, and some of them are massive files. I've actually used the
pyftsubset
tool to strip down some of the larger ones (several of them are 10mb each, and one is almost 20mb), and store them on my own CDN, but that is a trade off from being able to support all chars or just the most widely used ones. It was pretty much the only way i could handle the problem. IMO its ridiculous that the fonts that are already available to the browser are not accessible to Skia, and can not be used like they can on a native build. You have to jump through these hoops, or you have to accept that a localized web app will not actually be localized properly.
@Didier Villevalois ahh i see why you asked, i have corrected my OP.
d
Ah OK, sorry, I always thought that Unicode was made to support all the world languages with a single charset and thus a single Unicode font..
b
@Didier Villevalois oh i wish, that would have made life so much easier ๐Ÿ™‚ most of the fonts are not too large. but a lot of the logographic ones like Chinese, Korean, and Japanese are absolutely massive character sets.
๐Ÿ˜† 1
today i learned 3
b
Yeah this is weird. If you want emojis to work you also need to include a dedicated font for that...
a
Hey there! I don't have an immediate solution, but I can confirm that we are working on the fallback fonts
๐Ÿ™Œ๐Ÿป 1
๐Ÿ™Œ 3
b
@bod and that emoji font is also another 10mb ๐Ÿ˜•
โœ… 1
@Anton Makeevis that usable now? RIght now I've developed a workaround where fonts are lazy loaded when needed. its not ideal, so I'd be willing to try this as an experimental feature.
a
@Brill Not yet, but the PR is on review, as soon as its merged you can try the next dev build
๐Ÿ‘ 1