Hey guys! I'm creating a typography and based on t...
# compose-android
a
Hey guys! I'm creating a typography and based on the previous XML style I have the
textAllCaps
property defined, but looking into the TextStyle we don't have this property. What would be the best approach in this case?
1
r
You might be able to do it with fontFeatureSettings
You use the CSS syntax as a string in the variant of TextStyle that takes a fontFeatureSettings parameter
a
huum considering the code, how exactly should I do that Romain?
Copy code
val TextBadgeLabel = TextStyle(
    fontFamily = FontFamily.Default,
    fontSize = 14.sp,
    letterSpacing = text_badge_line_spacing,
    fontWeight = FontWeight.Bold,
    color = textColor_Subtle,
    //all caps??
)
r
add
fontFeatureSettings = "font-variant-caps: small-caps"
Ah crap no it won't work
Try "smcp" as the string
a
interesting
fontFeatureSettings = "font-variant-caps: smcp"
like this?
r
No just smcp
a
now I'm seeing the documentation here
r
Yes it's on developer.android.com too
a
good
let me know if you can help me with more one thing Romain... there is a
selector
in xml style to define what color will be set up according to
state_enabled
, do we have a way to handle this inside TextStyle?
Copy code
<selector xmlns:android="<http://schemas.android.com/apk/res/android>">
    <item android:state_enabled="true" android:color="?attr/tokens.foreground.Normal"/>

    <item android:state_enabled="false" android:color="?attr/tokens.foreground.Normal.Disabled"/>
</selector>
in my style, the text color is this selector
r
No, text style doesn’t handle logic on its own
a
Ok! Thanks, Romain! Helped me a lot with the fontFeatureSettings tip
Pleasure!
r
We should probably improve the docs :)
But glad it helped
a
good! good!
just a question, some reason for we don't have a more explicit way to do uppercase inside text style?
r
I’d have to ask the text folks but I assume it’s because using the css syntax gives access to many features without requiring a ridiculous number of function overloads
And something like small caps isn’t a common requirement
a
huuum ok!
thanks again 👊