How can I use fonts available to the browser on Co...
# compose-web
a
How can I use fonts available to the browser on Compose Web? I've tried the following and all of them render as roboto. I also tried preloading, but still the same result
Copy code
listOf(
    "sans-serif",
    "sans",
    "roboto",
    "system",
    "Arial"
).forEach {
    val fontFamily = FontFamily(SystemFont(it))
    Text("The quick brown fox ๐ŸฆŠ๐Ÿ˜๐Ÿค” ${it}", fontFamily = fontFamily, fontSize = 32.sp)
}
So far I think this is not possible. Just double checking in case I am missing something
k
this is not possible
๐Ÿ˜ฅ 1
๐Ÿ‘ 1
j
So this means if you're dealing with user input in any language you'll need to embed all of the fonts, I think ๐Ÿ™
k
yes
a
thanks for confirming @Konstantin Tskhovrebov What is a SystemFont in the context of Compose Web? I don't get it
k
As I remember this is Skiko embedded font
a
I'll open a ticket with more info on that. right now using the api is very confusing as the doc says "A Font that's already installed in the system." I understand the technical limitations, but this is not clear from an API POV
k
I understand your point. It works as you say on Desktop
e
as an addition to the comment in that issue: the local font API is async and requires an additional runtime permission from the browser, which might involve the browser asking the user which fonts to allow the website to use, for privacy concerns. https://wicg.github.io/local-font-access/#permissions