I just updated my project androidx.compose.ui:ui t...
# compose
c
I just updated my project androidx.compose.ui:ui to 1.0.0-beta06 and I’m having a crash here:
TypefaceAdapter
Copy code
private fun create(
    fontStyle: FontStyle = FontStyle.Normal,
    fontWeight: FontWeight = FontWeight.Normal,
    fontFamily: FontListFontFamily,
    fontSynthesis: FontSynthesis = FontSynthesis.All
): Typeface {
    val font = fontMatcher.matchFont(fontFamily, fontWeight, fontStyle)

    val typeface = try {
        when (font) {
            is ResourceFont -> resourceLoader.load(font) as Typeface
            is AndroidFont -> font.typeface
            else -> throw IllegalStateException("Unknown font type: $font")
        }
    } catch (e: Exception) {
        throw IllegalStateException("Cannot create Typeface from $font")
    }

    val loadedFontIsSameAsRequest = fontWeight == font.weight && fontStyle == font.style
    // if synthesis is not requested or there is an exact match we don't need synthesis
    if (fontSynthesis == FontSynthesis.None || loadedFontIsSameAsRequest) {
        return typeface
    }

    return synthesize(typeface, font, fontWeight, fontStyle, fontSynthesis)
}
Copy code
throw IllegalStateException("Cannot create Typeface from $font")
when in 05 it was working. Any tips on how to debug this?
Fonts are: roboto_bold.xml roboto_medium.xml
I’m getting a: android.content.res.Resources$NotFoundException: Font resource ID #0x7f090001
But this code works for sure on 05 and not in 06, the only changes on this branch were the version of compose.ui
So, what I found out is that when I changed back from XML to tff type, my fonts, it works 🤔
for some reason, the api can’t find my xml fonts as if they were resources
isn’t xml type accepted anymore?
creating an issue on the library 🙂
👍 1
r
If these are downloadable fonts, i faced it too, check the discussion in this issue --> https://issuetracker.google.com/issues/187627758 and the link to the downloadable fonts feature request.
1
c
My issue was already merged as a duplicate 🙂
👍 1