Calligraphy
Calligraphy copied to clipboard
Default font style not applied on older platforms <4.0.4
I test the calligraphy styled application on a older android 4.0.4 (GT-P7100) with the result that the font is not applied. It seems that the default definition isn't applied which i have declared in this way:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:textAppearance">@style/LightTextAppearance</item>
</style>
<style name="LightTextAppearance" parent="android:TextAppearance">
<item name="fontPath">fonts/LightWeb.ttf</item>
</style>
This worked fine so far on other devices and api level. What can i do further solving this issue?
Here's what README.md says about this:
Define your default font using CalligraphyConfig, in your Application class in the #onCreate() method.
@Override
public void onCreate() {
super.onCreate();
CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
.setDefaultFontPath("fonts/Roboto-RobotoRegular.ttf")
.setFontAttrId(R.attr.fontPath)
.build()
);
//....
}
Note: You don't need to define CalligraphyConfig but the library will apply no default font and use the default attribute of R.id.fontPath.
I had exactly this set, but without effect. I changed the font right now, and now it works as expected. Seems the font is the problem. The font can just set in the styles to work.
OTF fonts are a pain they hardly work. And you need to use well formatted TTF, (Generally Webfonts work)
But what lets me wonder it seems there is a difference in handling the font. Then it works well when i set it in styles.xml, programmatically in application class has no effect. I have attached the font t let you confirm. BrooklynSamuelsNo5-LightWeb.ttf.zip
Post a sample of how you are setting it too. Cheers.
On Wed, 20 Apr 2016, 06:38 Daniel Rindt, [email protected] wrote:
But what lets me wonder it seems there is a difference in handling the font. Then it works well when i set it in styles.xml, programmatically in application class has no effect. I have attached the font t let you confirm. BrooklynSamuelsNo5-LightWeb.ttf.zip https://github.com/chrisjenx/Calligraphy/files/227261/BrooklynSamuelsNo5-LightWeb.ttf.zip
— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/chrisjenx/Calligraphy/issues/277#issuecomment-212267293
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
...
<item name="android:textAppearance">@style/LightTextAppearance</item>
</style>
<style name="LightTextAppearance" parent="android:TextAppearance">
<item name="fontPath">fonts/BrooklynSamuelsNo5-LightWeb.ttf</item>
</style>
This is how i add it. And it works on platforms >4.0.4. Applications onCreate:
CalligraphyConfig.initDefault(new Builder()
.setFontAttrId(R.attr.fontPath)
.build());
It makes no difference if i add this too:
.setDefaultFontPath("fonts/BrooklynSamuelsNo5-LightWeb.ttf")
If i set another ttf there it works.
Out of interest what is the other TTF?
Yeah the fonts are loaded the same way, have a look. one one works through styles only pre 4.0.4 is bizzare...
Yes, thank you for caring!