Hello there,
I am experimenting with the new compose multiplatform 1.5.1 and trying to do custom fonts in somehow common way. I see that there is a new experimental resource() function which gives a ByteArray for any given resource. My question is, how can I load it into a proper Font on Android? On iOS there seem to be a function for that but it is not resolving for Android for some reason. And afaik, loading Font directly from ByteArray is not possible, one would need to write it into a file and I’d need context for that.
Am I missing something?
as a common expect/actual value, then you can create your own common FontFamily using
FontListFontFamily
.
l
Lukas Anda
09/11/2023, 2:25 PM
Yes I’ve read that article and was actually going for that originally, but was wondering if that is actually necessary given the new API
h
Halil Ozercan
09/11/2023, 2:28 PM
sorry I misinterpreted your question. Yes, unfortunately there is no way in Android to create a Typeface/Font from ByteArray. You'll need to write it to a file then re-read.
l
Lukas Anda
09/11/2023, 3:42 PM
Well the question is, can I write it to a file without Context on Android? Do you know about such possibility?