https://kotlinlang.org logo
#compose-web
Title
# compose-web
m

mohamed rejeb

12/05/2023, 4:04 PM
Did anyone manage to load custom font in Compose web (canvas), I was able to load the fonts with some workarounds (The font family is null at the beginning then I initialize it from a LaunchedEffect after successfully loading the fonts and creating the font family), and when I use the font family in a Text composable I get an error.
IllegalStateException: Could not load font
, the error appears only when I use that font family in a Text composable.
b

Brian Mbigo

12/05/2023, 4:17 PM
I use custom fonts in my project, and using the same approach as you (loading the font in a LaunchedEffect) Here is the theme composable and the implementation on wasm using compose-multiplatform resources to load a font (resource takes in the path to the font)
thank you color 1
m

mohamed rejeb

12/05/2023, 4:28 PM
Thanks I will check it
I still have the same issue. It appears that the problem is in the font that I am using. It's working fine on desktop but not in web. I'm not sure why. When I tried a different font, it worked fine.
a

Abdul Basit

12/06/2023, 3:42 PM
Exploring same.
s

Shriharsha Bhagwat

02/07/2024, 12:18 PM
6 Views