Comments (7)
I'll take a look 👍
from material-components-android-compose-theme-adapter.
Hi 👋
How is the font declared in your app? Is it a <font-family>
XML file in res/font
? Or a simple TTF like res/font/CustomType.ttf
?
Can you also paste in one of your TextAppearance
s?
Thanks
from material-components-android-compose-theme-adapter.
We aren't using a custom font. Our theme inherits from Theme.MaterialComponents.DayNight.NoActionBar
and we're just overriding the textAppearanceHeadlineX, subtitleX, bodyX, etc. attributes to reference our custom text styles. These all inherit from TextAppearance.AppCompat or a more specific TextAppearance.MaterialComponents.* style. No fontFamily is set, just sizes, spacings etc.
Even something as simple as the following causes the exception:
(Theme file)
<style name="MyTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="textAppearanceHeadline1">@style/TextAppearance</item>
<item name="textAppearanceHeadline2">@style/MyAppearance</item>
<item name="textAppearanceHeadline3">@style/MyAppearance</item>
<item name="textAppearanceHeadline4">@style/MyAppearance</item>
<item name="textAppearanceHeadline5">@style/MyAppearance</item>
<item name="textAppearanceHeadline6">@style/MyAppearance</item>
<item name="textAppearanceSubtitle1">@style/MyAppearance</item>
<item name="textAppearanceSubtitle2">@style/MyAppearance</item>
<item name="textAppearanceBody1">@style/MyAppearance</item>
<item name="textAppearanceBody2">@style/MyAppearance</item>
<item name="textAppearanceButton">@style/MyAppearance</item>
<item name="textAppearanceCaption">@style/MyAppearance</item>
(In dedicated text appearance styles file)
<style name="MyAppearance" parent="TextAppearance.AppCompat" />
from material-components-android-compose-theme-adapter.
I'm able to reproduce this in the sample in this library but only if I use TextAppearance.AppCompat.*
as the parent, as you've shown above. The problem doesn't occur for TextAppearance.MaterialComponents.*
styles. The AppCompat styles seem to resolve to:
<item name="fontFamily">sans-serif-condensed-light</item>
whereas MDC styles resolve to either sans-serif
or sans-serif-medium
, which I think is the problem. If I add sans-serif-condensed-light
to a custom style that extends from MDC I get the same crash.
It's probably something the library should handle, or perhaps a Compose limitation on condensed fonts. But in the meantime I'd suggest using the MDC styles as parents if possible.
from material-components-android-compose-theme-adapter.
Hmmm. So the related code for this is here.
It sounds like even though fontFamily
is set to sans-serif-condensed-light
, tv.resourceId
is still being set to something. This would probably be fixed if we do the string check first, then fall through to creating a FontFamilyWithWeight
in the else.
from material-components-android-compose-theme-adapter.
I'm able to reproduce this in the sample in this library but only if I use
TextAppearance.AppCompat.*
as the parent, as you've shown above. The problem doesn't occur forTextAppearance.MaterialComponents.*
styles. The AppCompat styles seem to resolve to:<item name="fontFamily">sans-serif-condensed-light</item>
whereas MDC styles resolve to either
sans-serif
orsans-serif-medium
, which I think is the problem. If I addsans-serif-condensed-light
to a custom style that extends from MDC I get the same crash.It's probably something the library should handle, or perhaps a Compose limitation on condensed fonts. But in the meantime I'd suggest using the MDC styles as parents if possible.
Thanks, using only MDC styles works.
from material-components-android-compose-theme-adapter.
@ricknout do you want to take this? If not, I can probably do it later in the week
from material-components-android-compose-theme-adapter.
Related Issues (20)
- Can't able to setup material-components-android-compose-theme-adapter HOT 3
- Version 1.1.22 ships with missing dependency on :core module HOT 2
- Parse fontFamily in main theme as defaultFontFamily
- gh-pages issue
- Preview dark theme HOT 1
- Can not use serif-monospace HOT 2
- In app dark mode setting is ignored & missing manual dark mode override HOT 5
- Text color same as surface color
- Release versions alpha releases of Compose HOT 1
- Setting LineHeight using dp instead of sp breaks vertical spacing
- MDC-Android Compose Theme Adapter (broken images)
- Breaking ProcessLifecycle Events
- SmallTopAppBar not working HOT 2
- createMdcTheme() is missing secondaryVariant color in dark mode HOT 1
- context.theme.key, getDeclaredMethod will always throw if we target SDK 32 HOT 2
- The API docs link is broken
- Fonts are not read from the XML Material Theme HOT 1
- Stable release dependency on MCD alpha HOT 1
- Typography font is not applied when using mdc theme HOT 2
- Not possible to update to 1.0.22 / 1.1.22 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from material-components-android-compose-theme-adapter.