Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.6.0] Could not load font #4387

Closed
dhng22 opened this issue Feb 28, 2024 · 15 comments
Closed

[1.6.0] Could not load font #4387

dhng22 opened this issue Feb 28, 2024 · 15 comments
Labels
bug Something isn't working resources

Comments

@dhng22
Copy link

dhng22 commented Feb 28, 2024

Happened on the new composeResources system:

FATAL EXCEPTION: main Process: , PID: 14880 java.lang.IllegalStateException: Could not load font at androidx.compose.ui.text.font.TypefaceRequestCache.runCached(FontFamilyResolver.kt:207) at androidx.compose.ui.text.font.FontFamilyResolverImpl.resolve(FontFamilyResolver.kt:92) at androidx.compose.ui.text.font.FontFamilyResolverImpl.resolve-DPcqOEQ(FontFamilyResolver.kt:79) at androidx.compose.foundation.text.TextFieldSizeKt$textFieldMinSize$1.invoke(TextFieldSize.kt:47) at androidx.compose.foundation.text.TextFieldSizeKt$textFieldMinSize$1.invoke(TextFieldSize.kt:38) at androidx.compose.ui.ComposedModifierKt$materialize$result$1.invoke(ComposedModifier.kt:270) at androidx.compose.ui.ComposedModifierKt$materialize$result$1.invoke(ComposedModifier.kt:265) at androidx.compose.ui.Modifier$Element.foldIn(Modifier.kt:136) at androidx.compose.ui.CombinedModifier.foldIn(Modifier.kt:396) at androidx.compose.ui.CombinedModifier.foldIn(Modifier.kt:396) at androidx.compose.ui.CombinedModifier.foldIn(Modifier.kt:396) at androidx.compose.ui.ComposedModifierKt.materializeModifier(ComposedModifier.kt:265) at androidx.compose.ui.layout.LayoutKt$materializerOf$1.invoke-Deg8D_g(Layout.kt:205) at androidx.compose.ui.layout.LayoutKt$materializerOf$1.invoke(Layout.kt:203) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:118) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35) at androidx.compose.foundation.text.selection.SimpleLayoutKt.SimpleLayout(SimpleLayout.kt:79) at androidx.compose.foundation.text.CoreTextFieldKt$CoreTextField$5$1.invoke(CoreTextField.kt:668) at androidx.compose.foundation.text.CoreTextFieldKt$CoreTextField$5$1.invoke(CoreTextField.kt:643) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35) at androidx.compose.material3.TextFieldKt.TextFieldLayout(TextField.kt:617) at androidx.compose.material3.TextFieldImplKt$CommonDecorationBox$3.invoke-eopBjH0(TextFieldImpl.kt:205) at androidx.compose.material3.TextFieldImplKt$CommonDecorationBox$3.invoke(TextFieldImpl.kt:113) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:228) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35) at androidx.compose.material3.TextFieldTransitionScope.Transition-DTcfvLk(TextFieldImpl.kt:382) at androidx.compose.material3.TextFieldImplKt.CommonDecorationBox(TextFieldImpl.kt:103) at androidx.compose.material3.TextFieldDefaults.DecorationBox(TextFieldDefaults.kt:500) at androidx.compose.material3.TextFieldKt$TextField$2$1.invoke(TextField.kt:223) at androidx.compose.material3.TextFieldKt$TextField$2$1.invoke(TextField.kt:221) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:118) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35) at androidx.compose.foundation.text.CoreTextFieldKt$CoreTextField$5.invoke(CoreTextField.kt:643) at androidx.compose.foundation.text.CoreTextFieldKt$CoreTextField$5.invoke(CoreTextField.kt:642) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35) at androidx.compose.foundation.text.CoreTextFieldKt.CoreTextFieldRootBox(CoreTextField.kt:1305) at androidx.compose.foundation.text.CoreTextFieldKt.CoreTextField(CoreTextField.kt:642) at androidx.compose.foundation.text.BasicTextFieldKt.BasicTextField(BasicTextField.kt:166) at androidx.compose.material3.TextFieldKt$TextField$2.invoke(TextField.kt:201) at androidx.compose.material3.TextFieldKt$TextField$2.invoke(TextField.kt:200) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)

To Reproduce
Put google font inside composeResources(.tff extension):
image

then call it with FontResource
image

then use created font with Typography
image

Typography then used with MaterialTheme
image

Expected behavior
Font load and works

@dhng22 dhng22 added bug Something isn't working submitted labels Feb 28, 2024
@dhng22
Copy link
Author

dhng22 commented Feb 28, 2024

Nevermind, I've just read the updated doc that multimodule is not supported yet. These font are indeed loaded from another module beside shared. Please tell me if i'm correct

@MatkovIvan
Copy link
Member

multimodule is not supported yet

Yep, that's correct

@MatkovIvan
Copy link
Member

Issue to track #4229

@sereden
Copy link

sereden commented Mar 1, 2024

I'm facing the same issue when using @Preview (due to limitations of KMM we create Previews in the Android part).
I also created a regular res folder and moved fonts over there but the issue persist. Are there any workarounds for this?
I'm considering using a default (Roboto) font for the preview as the last call but it doesn't provide the same Look and Fill as the real fonts

@MatkovIvan
Copy link
Member

@sereden the issue about resources inside preview is here - #4338

@dhng22
Copy link
Author

dhng22 commented Mar 21, 2024

@MatkovIvan Is multi-module resource supported in 1.6.10-dev1523?

@parfenovedyard
Copy link

I had the same issue.
Updating compose plugin from 1.6.0 to 1.6.1 helped.

@dhng22
Copy link
Author

dhng22 commented Apr 3, 2024

@parfenovedyard I thought they said multimodule requires Kotlin 2.0.0-Beta5 minimum? What kotlin version are you using

@terrakok
Copy link
Member

terrakok commented Apr 3, 2024

You could try 1.6.10-dev1557
But it is under active development and there is no guaranties

@parfenovedyard
Copy link

@parfenovedyard I thought they said multimodule requires Kotlin 2.0.0-Beta5 minimum? What kotlin version are you using

1.9.23

@quan7794
Copy link

I had the same issue. Updating compose plugin from 1.6.0 to 1.6.1 helped.

I'm using 1.6.2 version, and the issue happened. After downgraded to 16.1, the issue gone. Thanks

I don't know why it's happing on newest version of Compose Plugin when it's fixed on 1.6.1. Look like they do not verify it enough.

@vdcast
Copy link

vdcast commented Jun 18, 2024

I just realized that Compose Resources throws this error right after you add any new font.

Solution: You need to upgrade or lowgrade your Compose Plugin version to fix this issue after adding new font.
If you current version is 1.6.2 => set it to 1.6.1 => sync project => run project and be sure fonts loaded successfully => after that you can go back to 1.6.2 and fonts are working well.
Same process for other Compose Plugin versions.

@rishabhsingh2002
Copy link

Changing from 1.6.1 to 1.6.2 works for me

@okushnikov
Copy link
Collaborator

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

@radbobdad
Copy link

radbobdad commented Aug 21, 2024

I am using Compose Plugin 1.5.1. Changing to 1.5.0+sync+run and back to 1.5.1 did not resolve this issue for me.
When I try 1.6.1 or 1.6.2 it says it can't find it in
https://dl.google.com/dl/android/maven2/androidx/compose/compiler/compiler/1.6.1/compiler-1.6.1.pom
or
https://repo.maven.apache.org/maven2/androidx/compose/compiler/compiler/1.6.1/compiler-1.6.1.pom

Running Koala 2024.1.1 Patch 1.

@JetBrains JetBrains locked and limited conversation to collaborators Aug 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working resources
Projects
None yet
Development

No branches or pull requests

10 participants