Is there some kind of ```Typography(defaultFontFam...
# compose
t
Is there some kind of
Copy code
Typography(defaultFontFamily = Rubik)
Equivalent for M3 ? Or are we supposed to copy paste all the internal token stuff and maintain them when they evolve ?
s
I haven’t played with M3 at all, but I know that this is simply a convenience secondary constructor . You can probably define your own that does the exact same thing to avoid having to copy-paste as you said
t
Not for M3 😞 It's all based on internal / private token stuff
s
Alright, I wonder why that decision was made, maybe there’s good reason for it. But besides that, you can probably still define your own function that takes all the inputs the M3 Typography class needs, plus a defaultFontFamily that does this for you in one place.
t
Yes that means copy all the tokens values and updating them each time those M3 token values are updated. (What I said I'd like to avoid in first post)
s
Fair enough. I wonder who we could ping in here from Google who works on M3 to explain why that secondary constructor does not exist as it does for M2. If anything, you can make a FeatureRequest in the bug tracker for this functionality. Someone appropriate will definitely take a look at it there. And link it back here so that people who face the same issue can upvote it.
b
I think you can do it this way:
Copy code
private val fontFamily = FontFamily(...)
private val defaults = Typography()
val AppTypography = Typography(
    displayLarge = defaults.displayLarge.copy(
        fontFamily = fontFamily,
    ),
    labelSmall = defaults.labelSmall.copy(
        fontFamily = fontFamily,
    ),
    ...
)
❤️ 1
t
Arf of course, thanks a lot. Since it's not data class I did not even thought of checking if they added a copy method ... Shame on me.