Calligraphy icon indicating copy to clipboard operation
Calligraphy copied to clipboard

How to turn off Calligraphy for a specific style/textAppearance/view?

Open TWiStErRob opened this issue 8 years ago • 1 comments

The current resolution path doesn't allow for exceptions. If I define the font in the theme to get it across the app, it's not possible to disable it on lower levels (textAppearance, style, view).

<style name="MyTextAppearance" parent="TextAppearance.AppCompat">
    ... other customizations
    <item name="fontPath">fonts/MyFont.ttf</item>
</style>

Which is used in the theme (as shown in https://github.com/chrisjenx/Calligraphy/issues/319#issuecomment-293930302).

I want to be able to say:

<style name="MyTextAppearance.NoCustomFont">
    <item name="fontPath">@null</item>
</style>

<TextView
        android:textAppearance="@style/MyTextAppearance.NoCustomFont"
    />

but this obviously doesn't work, because CalligraphyFactory is using TextUtils.isEmpty to check and fall back to more and more global values.

Would it be possible to include some magic value like fontPath="android:font-family" to break out of font resolution in onViewCreatedInternal and prevent calling applyFontToTextView?

TWiStErRob avatar Apr 13 '17 15:04 TWiStErRob

yangjieK gave the trick:

https://github.com/chrisjenx/Calligraphy/issues/388#issuecomment-307311701

OsmanYalin avatar Mar 20 '19 14:03 OsmanYalin