InflationX / Calligraphy

Custom fonts in Android the easy way...
Apache License 2.0
1.09k stars 83 forks source link

Theme level styling not working for me #14

Open theapache64 opened 5 years ago

theapache64 commented 5 years ago

Hey, this might not be a library issue, but most probably mine.

I've set the fontAttr like this

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
       ...
        <item name="materialButtonStyle">@style/CustomButtonStyle</item>
    </style>

    <style name="CustomButtonStyle" parent="Widget.MaterialComponents.Button.OutlinedButton">
        <item name="fontPath">fonts/GoogleSans-Bold.ttf</item>
        <item name="android:textSize">50sp</item>
    </style>

but the font's not getting changed for the button, (textSize attr works). (Note: If i set the fontPath attr directly to the widget,it works. but i want to do it via style.xml) What am i doing wrong?

jbruchanov commented 4 years ago

+1

hsson commented 3 years ago

Also having this issue! I'm using a default font specified as suggested in the README. But for buttons I have created a new style that uses the fontPath="fonts/my-other-font.tff" (not the same as the default font) attribute. For some reason the buttons still use the default font and not the font specified by fontPath.

Specifying the fontPath attribute directly on the element in the layout works, but not when specifying it in styles.xml

hsson commented 3 years ago

I did some experimenting and found that if I specify the style directly on the element on the layout, the correct font is applied. But if I just rely on the materialButtonStyle in my theme and don't explicitly set the style on each button it doesn't work.