2

I followed the documentation to add downloadable fonts for Roboto font family. But I am not able to apply the font-family app-wide. I get this error repeatedly:

E/Minikin: addFont failed to create font /data/user/0/<package_name>/cache/.font1091-1091-0

I added three fonts from Android Studio GUI and it populated all the required files in font directory and certs in values directory. Here's one of the font resource file:

font/roboto_italic.xml

<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:app="http://schemas.android.com/apk/res-auto"
        app:fontProviderAuthority="com.google.android.gms.fonts"
        app:fontProviderPackage="com.google.android.gms"
        app:fontProviderQuery="name=Roboto&amp;weight=300"
        app:fontProviderCerts="@array/com_google_android_gms_fonts_certs">
</font-family>

Then I created a font-family resource file:

font/app_font_family.xml

<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:app="http://schemas.android.com/apk/res-auto">
    <font app:fontStyle="normal" app:fontWeight="400" app:font="@font/roboto_regular"/>
    <font app:fontStyle="italic" app:fontWeight="400" app:font="@font/roboto_italic" />
    <font app:fontStyle="normal" app:fontWeight="700" app:font="@font/roboto_medium"/>
</font-family>

Finally, to apply the font-family app wide, I added the following to my app theme:

  <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        ...
        <item name="fontFamily">@font/app_font_family</item>
  </style>

None of the fonts are loading. Phone has internet connection and permission.

I get error in logcat repeatedly:

12-30 22:19:52.475 1091-1091/<package_name> E/Minikin: addFont failed to create font /data/user/0/<package_name>/cache/.font1091-1091-0

I found similar issues posted here and here. I have set READ and WRITE external storage permissions as suggested by a comment in first link but to no avail. I prefixed fontFamily attribute with android namespace still no luck.

<item name="android:fontFamily">@font/app_font_family</item>

targetSdkVersion is 26. I am using support library version 26.1.0

My phone has Play Services version 14. (this post mentions version 11+ is needed)

I want to apply app wide custom font without bundling in apk but I can't see it working. Can someone please help me fix this issue?

Update: Font loads when set on any TexView or textAppearance style using:

app:fontFamily="@font/app_font_family"
andriod:textStyle="normal"

Error still appears and font is not applied app-wide.

sziraqui
  • 5,763
  • 3
  • 28
  • 37

0 Answers0