Cannot create Typeface from ResourceFont
See original GitHub issueWe added a compose based screen to our regular view based app and wanted to use the MdcTheme but are getting a “Cannot create Typeface from ResourceFont(resId=17040217, weight=FontWeight(weight=400), style=Normal)” exception.
No custom / downloadable font ist being used in this project. We tried and removed any item from any custom text style (which all inherit from TextAppearance.AppCompat or TextAppearance.MaterialComponents.* styles) but that didn’t help either.
We were not able to find the issue and have to set readTypography
to false
for now.
We used compose / theme adapter version v1.0.0-alpha06 and material theme version 1.2.1 (we also tried 1.3.0-alpha03).
Exception:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: XXX, PID: 23474
java.lang.IllegalStateException: Cannot create Typeface from ResourceFont(resId=17040217, weight=FontWeight(weight=400), style=Normal)
at androidx.compose.ui.text.platform.TypefaceAdapter.create(SourceFile:245)
at androidx.compose.ui.text.platform.TypefaceAdapter.create(SourceFile:145)
at androidx.compose.ui.text.platform.extensions.TextPaintExtensionsKt.createTypeface(SourceFile:131)
at androidx.compose.ui.text.platform.extensions.TextPaintExtensionsKt.applySpanStyle(SourceFile:53)
at androidx.compose.ui.text.platform.AndroidParagraphIntrinsics.<init>(SourceFile:66)
at androidx.compose.ui.text.platform.AndroidParagraphIntrinsicsKt.ActualParagraphIntrinsics(SourceFile:128)
at androidx.compose.ui.text.ParagraphIntrinsicsKt.ParagraphIntrinsics(SourceFile:54)
at androidx.compose.ui.text.MultiParagraphIntrinsics.<init>(SourceFile:76)
at androidx.compose.ui.text.TextDelegate.layoutIntrinsics(SourceFile:117)
at androidx.compose.ui.text.TextDelegate.layoutText(SourceFile:139)
at androidx.compose.ui.text.TextDelegate.layout-BAnaFRY(SourceFile:197)
at androidx.compose.foundation.text.TextController$measure$1.invoke(SourceFile:268)
at androidx.compose.foundation.text.TextController$measure$1.invoke(Unknown Source:13)
at androidx.compose.ui.LayoutKt$measureBlocksOf$1.measure-2MWCACw(SourceFile:147)
at androidx.compose.ui.node.InnerPlaceable.performMeasure-BRTryo0(SourceFile:47)
at androidx.compose.ui.node.LayoutNodeWrapper.measure-BRTryo0(SourceFile:123)
at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.performMeasure-BRTryo0(SourceFile:104)
at androidx.compose.ui.node.LayoutNodeWrapper.measure-BRTryo0(SourceFile:123)
at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.performMeasure-BRTryo0(SourceFile:104)
at androidx.compose.ui.node.LayoutNodeWrapper.measure-BRTryo0(SourceFile:123)
at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.performMeasure-BRTryo0(SourceFile:104)
at androidx.compose.ui.node.LayerWrapper.performMeasure-BRTryo0(SourceFile:67)
at androidx.compose.ui.node.LayoutNodeWrapper.measure-BRTryo0(SourceFile:123)
at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.performMeasure-BRTryo0(SourceFile:104)
at androidx.compose.ui.node.LayoutNodeWrapper.measure-BRTryo0(SourceFile:123)
at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.performMeasure-BRTryo0(SourceFile:104)
at androidx.compose.ui.node.LayoutNodeWrapper.measure-BRTryo0(SourceFile:123)
at androidx.compose.ui.node.OuterMeasurablePlaceable$remeasure$2.invoke(SourceFile:91)
at androidx.compose.ui.node.OuterMeasurablePlaceable$remeasure$2.invoke(Unknown Source:0)
at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SourceFile:133)
at androidx.compose.ui.platform.AndroidComposeView.observeMeasureModelReads(SourceFile:473)
at androidx.compose.ui.node.OuterMeasurablePlaceable.remeasure-BRTryo0(SourceFile:90)
at androidx.compose.ui.node.OuterMeasurablePlaceable.measure-BRTryo0(SourceFile:63)
at androidx.compose.ui.node.LayoutNode.measure-BRTryo0(SourceFile:1228)
at androidx.compose.foundation.layout.Measurer.measure(SourceFile:1191)
at androidx.constraintlayout.core.widgets.analyzer.BasicMeasure.measure(SourceFile:394)
at androidx.constraintlayout.core.widgets.analyzer.BasicMeasure.measureChildren(SourceFile:105)
at androidx.constraintlayout.core.widgets.analyzer.BasicMeasure.solverMeasure(SourceFile:227)
at androidx.constraintlayout.core.widgets.ConstraintWidgetContainer.measure(SourceFile:113)
at androidx.compose.foundation.layout.Measurer.performMeasure-f8GzS1k(SourceFile:1342)
at androidx.compose.foundation.layout.ConstraintLayoutKt$ConstraintLayout$2.invoke(SourceFile:94)
at androidx.compose.foundation.layout.ConstraintLayoutKt$ConstraintLayout$2.invoke(Unknown Source:13)
at androidx.compose.ui.LayoutKt$MeasuringIntrinsicsMeasureBlocks$1.measure-2MWCACw(SourceFile:386)
E/AndroidRuntime: at androidx.compose.ui.node.InnerPlaceable.performMeasure-BRTryo0(SourceFile:47)
at androidx.compose.ui.node.LayoutNodeWrapper.measure-BRTryo0(SourceFile:123)
at androidx.compose.foundation.layout.PaddingModifier.measure-3Jkh9V0(SourceFile:209)
at androidx.compose.ui.node.ModifiedLayoutNode.performMeasure-BRTryo0(SourceFile:36)
at androidx.compose.ui.node.LayoutNodeWrapper.measure-BRTryo0(SourceFile:123)
at androidx.compose.foundation.layout.FillModifier.measure-3Jkh9V0(SourceFile:683)
at androidx.compose.ui.node.ModifiedLayoutNode.performMeasure-BRTryo0(SourceFile:36)
at androidx.compose.ui.node.LayoutNodeWrapper.measure-BRTryo0(SourceFile:123)
at androidx.compose.ui.node.OuterMeasurablePlaceable$remeasure$2.invoke(SourceFile:91)
at androidx.compose.ui.node.OuterMeasurablePlaceable$remeasure$2.invoke(Unknown Source:0)
at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SourceFile:133)
at androidx.compose.ui.platform.AndroidComposeView.observeMeasureModelReads(SourceFile:473)
at androidx.compose.ui.node.OuterMeasurablePlaceable.remeasure-BRTryo0(SourceFile:90)
at androidx.compose.ui.node.OuterMeasurablePlaceable.measure-BRTryo0(SourceFile:63)
at androidx.compose.ui.node.LayoutNode.measure-BRTryo0(SourceFile:1228)
at androidx.compose.material.SurfaceKt$SurfaceLayout$1$1.invoke(SourceFile:140)
at androidx.compose.material.SurfaceKt$SurfaceLayout$1$1.invoke(Unknown Source:13)
at androidx.compose.ui.LayoutKt$MeasuringIntrinsicsMeasureBlocks$1.measure-2MWCACw(SourceFile:386)
at androidx.compose.ui.node.InnerPlaceable.performMeasure-BRTryo0(SourceFile:47)
at androidx.compose.ui.node.LayoutNodeWrapper.measure-BRTryo0(SourceFile:123)
at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.performMeasure-BRTryo0(SourceFile:104)
at androidx.compose.ui.node.LayerWrapper.performMeasure-BRTryo0(SourceFile:67)
at androidx.compose.ui.node.LayoutNodeWrapper.measure-BRTryo0(SourceFile:123)
at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.performMeasure-BRTryo0(SourceFile:104)
at androidx.compose.ui.node.LayoutNodeWrapper.measure-BRTryo0(SourceFile:123)
at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.performMeasure-BRTryo0(SourceFile:104)
at androidx.compose.ui.node.LayerWrapper.performMeasure-BRTryo0(SourceFile:67)
at androidx.compose.ui.node.LayoutNodeWrapper.measure-BRTryo0(SourceFile:123)
at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.performMeasure-BRTryo0(SourceFile:104)
at androidx.compose.ui.node.LayoutNodeWrapper.measure-BRTryo0(SourceFile:123)
at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.performMeasure-BRTryo0(SourceFile:104)
at androidx.compose.ui.node.LayoutNodeWrapper.measure-BRTryo0(SourceFile:123)
at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.performMeasure-BRTryo0(SourceFile:104)
at androidx.compose.ui.node.LayoutNodeWrapper.measure-BRTryo0(SourceFile:123)
at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.performMeasure-BRTryo0(SourceFile:104)
at androidx.compose.ui.node.LayoutNodeWrapper.measure-BRTryo0(SourceFile:123)
at androidx.compose.foundation.layout.FillModifier.measure-3Jkh9V0(SourceFile:683)
at androidx.compose.ui.node.ModifiedLayoutNode.performMeasure-BRTryo0(SourceFile:36)
at androidx.compose.ui.node.LayoutNodeWrapper.measure-BRTryo0(SourceFile:123)
at androidx.compose.ui.node.OuterMeasurablePlaceable$remeasure$2.invoke(SourceFile:91)
at androidx.compose.ui.node.OuterMeasurablePlaceable$remeasure$2.invoke(Unknown Source:0)
at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SourceFile:133)
at androidx.compose.ui.platform.AndroidComposeView.observeMeasureModelReads(SourceFile:473)
at androidx.compose.ui.node.OuterMeasurablePlaceable.remeasure-BRTryo0(SourceFile:90)
at androidx.compose.ui.node.OuterMeasurablePlaceable.measure-BRTryo0(SourceFile:63)
at androidx.compose.ui.node.LayoutNode.measure-BRTryo0(SourceFile:1228)
E/AndroidRuntime: at androidx.compose.foundation.lazy.LazyListState.measure-5vC3nwU$foundation_release(SourceFile:310)
at androidx.compose.foundation.lazy.LazyForKt$LazyFor$1.invoke(SourceFile:307)
at androidx.compose.foundation.lazy.LazyForKt$LazyFor$1.invoke(Unknown Source:10)
at androidx.compose.ui.layout.SubcomposeLayoutState$createMeasureBlocks$1.measure-2MWCACw(SourceFile:224)
at androidx.compose.ui.node.InnerPlaceable.performMeasure-BRTryo0(SourceFile:47)
at androidx.compose.ui.node.LayoutNodeWrapper.measure-BRTryo0(SourceFile:123)
at androidx.compose.foundation.layout.PaddingModifier.measure-3Jkh9V0(SourceFile:209)
at androidx.compose.ui.node.ModifiedLayoutNode.performMeasure-BRTryo0(SourceFile:36)
at androidx.compose.ui.node.LayoutNodeWrapper.measure-BRTryo0(SourceFile:123)
at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.performMeasure-BRTryo0(SourceFile:104)
at androidx.compose.ui.node.LayerWrapper.performMeasure-BRTryo0(SourceFile:67)
at androidx.compose.ui.node.LayoutNodeWrapper.measure-BRTryo0(SourceFile:123)
at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.performMeasure-BRTryo0(SourceFile:104)
at androidx.compose.ui.node.LayoutNodeWrapper.measure-BRTryo0(SourceFile:123)
at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.performMeasure-BRTryo0(SourceFile:104)
at androidx.compose.ui.node.LayoutNodeWrapper.measure-BRTryo0(SourceFile:123)
at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.performMeasure-BRTryo0(SourceFile:104)
at androidx.compose.ui.node.LayoutNodeWrapper.measure-BRTryo0(SourceFile:123)
at androidx.compose.ui.node.OuterMeasurablePlaceable$remeasure$2.invoke(SourceFile:91)
at androidx.compose.ui.node.OuterMeasurablePlaceable$remeasure$2.invoke(Unknown Source:0)
at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SourceFile:133)
at androidx.compose.ui.platform.AndroidComposeView.observeMeasureModelReads(SourceFile:473)
at androidx.compose.ui.node.OuterMeasurablePlaceable.remeasure-BRTryo0(SourceFile:90)
at androidx.compose.ui.node.OuterMeasurablePlaceable.measure-BRTryo0(SourceFile:63)
at androidx.compose.ui.node.LayoutNode.measure-BRTryo0(SourceFile:1228)
at androidx.compose.foundation.layout.RowColumnImplKt$rowColumnMeasureBlocks$1.invoke(SourceFile:87)
at androidx.compose.foundation.layout.RowColumnImplKt$rowColumnMeasureBlocks$1.invoke(Unknown Source:13)
at androidx.compose.ui.LayoutKt$measureBlocksOf$1.measure-2MWCACw(SourceFile:147)
at androidx.compose.ui.node.InnerPlaceable.performMeasure-BRTryo0(SourceFile:47)
at androidx.compose.ui.node.LayoutNodeWrapper.measure-BRTryo0(SourceFile:123)
at androidx.compose.foundation.layout.FillModifier.measure-3Jkh9V0(SourceFile:683)
at androidx.compose.ui.node.ModifiedLayoutNode.performMeasure-BRTryo0(SourceFile:36)
at androidx.compose.ui.node.LayoutNodeWrapper.measure-BRTryo0(SourceFile:123)
at androidx.compose.ui.node.OuterMeasurablePlaceable$remeasure$2.invoke(SourceFile:91)
at androidx.compose.ui.node.OuterMeasurablePlaceable$remeasure$2.invoke(Unknown Source:0)
at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(SourceFile:220)
at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SourceFile:128)
at androidx.compose.ui.platform.AndroidComposeView.observeMeasureModelReads(SourceFile:473)
at androidx.compose.ui.node.OuterMeasurablePlaceable.remeasure-BRTryo0(SourceFile:90)
at androidx.compose.ui.node.LayoutNode.remeasure-BRTryo0$ui_release(SourceFile:1235)
at androidx.compose.ui.node.LayoutNode.remeasure-BRTryo0$default(SourceFile:1233)
at androidx.compose.ui.node.LayoutNode.onBeforeLayoutChildren(SourceFile:1041)
at androidx.compose.ui.node.LayoutNode.layoutChildren(SourceFile:930)
at androidx.compose.ui.node.LayoutNode.onNodePlaced$ui_release(SourceFile:925)
at androidx.compose.ui.node.InnerPlaceable.placeAt--gyyYBs(SourceFile:118)
at androidx.compose.ui.Placeable$PlacementScope.place-gl1q84w(SourceFile:176)
E/AndroidRuntime: at androidx.compose.ui.node.DelegatingLayoutNodeWrapper$performMeasure$1.placeChildren(SourceFile:111)
at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.placeAt--gyyYBs(SourceFile:99)
at androidx.compose.ui.Placeable$PlacementScope.place-gl1q84w(SourceFile:176)
at androidx.compose.ui.node.DelegatingLayoutNodeWrapper$performMeasure$1.placeChildren(SourceFile:111)
at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.placeAt--gyyYBs(SourceFile:99)
at androidx.compose.ui.Placeable$PlacementScope.place-gl1q84w(SourceFile:176)
at androidx.compose.ui.node.DelegatingLayoutNodeWrapper$performMeasure$1.placeChildren(SourceFile:111)
at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.placeAt--gyyYBs(SourceFile:99)
at androidx.compose.ui.Placeable$PlacementScope.place-gl1q84w(SourceFile:176)
at androidx.compose.ui.node.DelegatingLayoutNodeWrapper$performMeasure$1.placeChildren(SourceFile:111)
at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.placeAt--gyyYBs(SourceFile:99)
at androidx.compose.ui.Placeable$PlacementScope.place-gl1q84w(SourceFile:176)
at androidx.compose.ui.node.DelegatingLayoutNodeWrapper$performMeasure$1.placeChildren(SourceFile:111)
at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.placeAt--gyyYBs(SourceFile:99)
at androidx.compose.ui.node.LayerWrapper.placeAt--gyyYBs(SourceFile:73)
at androidx.compose.ui.Placeable$PlacementScope.place-gl1q84w(SourceFile:176)
at androidx.compose.ui.node.OuterMeasurablePlaceable.placeAt--gyyYBs(SourceFile:115)
at androidx.compose.ui.Placeable$PlacementScope.place-gl1q84w(SourceFile:176)
at androidx.compose.ui.Placeable$PlacementScope.placeAutoMirrored-gl1q84w(SourceFile:180)
at androidx.compose.ui.Placeable$PlacementScope.placeRelative(SourceFile:154)
at androidx.compose.ui.node.LayoutNode.place(SourceFile:826)
at androidx.compose.ui.node.MeasureAndLayoutDelegate.measureAndLayout(SourceFile:220)
at androidx.compose.ui.platform.AndroidComposeView.measureAndLayout(SourceFile:391)
at androidx.compose.ui.platform.AndroidComposeView.dispatchDraw(SourceFile:545)
at android.view.View.draw(View.java:22353)
at android.view.View.updateDisplayListIfDirty(View.java:21226)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4500)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4473)
at android.view.View.updateDisplayListIfDirty(View.java:21186)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4500)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4473)
at android.view.View.updateDisplayListIfDirty(View.java:21186)
at android.view.View.draw(View.java:22081)
at android.view.ViewGroup.drawChild(ViewGroup.java:4516)
at androidx.fragment.app.FragmentContainerView.drawChild(SourceFile:235)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277)
at androidx.fragment.app.FragmentContainerView.dispatchDraw(SourceFile:223)
at android.view.View.updateDisplayListIfDirty(View.java:21217)
at android.view.View.draw(View.java:22081)
at android.view.ViewGroup.drawChild(ViewGroup.java:4516)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277)
at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(SourceFile:1963)
at android.view.View.updateDisplayListIfDirty(View.java:21217)
at android.view.View.draw(View.java:22081)
at android.view.ViewGroup.drawChild(ViewGroup.java:4516)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277)
at android.view.View.updateDisplayListIfDirty(View.java:21217)
at android.view.View.draw(View.java:22081)
at android.view.ViewGroup.drawChild(ViewGroup.java:4516)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277)
at android.view.View.updateDisplayListIfDirty(View.java:21217)
at android.view.View.draw(View.java:22081)
at android.view.ViewGroup.drawChild(ViewGroup.java:4516)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277)
at android.view.View.updateDisplayListIfDirty(View.java:21217)
at android.view.View.draw(View.java:22081)
E/AndroidRuntime: at android.view.ViewGroup.drawChild(ViewGroup.java:4516)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277)
at android.view.View.updateDisplayListIfDirty(View.java:21217)
at android.view.View.draw(View.java:22081)
at android.view.ViewGroup.drawChild(ViewGroup.java:4516)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277)
at android.view.View.draw(View.java:22353)
at com.android.internal.policy.DecorView.draw(DecorView.java:806)
at android.view.View.updateDisplayListIfDirty(View.java:21226)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:559)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:565)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:642)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:4101)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3828)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3099)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1952)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8171)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:972)
at android.view.Choreographer.doCallbacks(Choreographer.java:796)
at android.view.Choreographer.doFrame(Choreographer.java:731)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
create typeface from font resource id - Stack Overflow
I am creating Typeface to set custom font for collapsingToolbarLayout. I found this answer but it requires me to keep font in assets....
Read more >Problem with fonts on the Android platform · Issue #333 - GitHub
When I run an application with a custom font on Android, ... IllegalStateException: Cannot create Typeface from ResourceFont(resId=0, ...
Read more >Downloadable fonts are not supported in Compose [174162090]
Returns load to returning SkTypeface. createFontFamilyResolver(Font.ResourceLoader) becomes expect/actual to allow platfrom difference in behavior. Test: ...
Read more >Using Custom Font as Resources in Android App - Medium
Create font family · Right-click the font folder and go to New > Font resource file. The New Resource File window appears. ·...
Read more >ResourceFont - Android Developers
Create a view class. Updated Dec 16, 2022 ... ResourceFont. bookmark_border ... Defines a font to be used while rendering text with resource...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ll take a look 👍
@ricknout do you want to take this? If not, I can probably do it later in the week