0

I have recently added a custom font to my Android project in Android Studio (following these instructions). This is not a regular font to show text but a custom font containing a large number of icons which are used all over my app.

This works fine. However now some users reported the problem, that on their devices only some icons can be used, while many other icons are shown as characters instead. All users have in common, that they have configured a custom font/theme in their device settings which seems override the app styles. Thus instead of my icon font the app now uses the device font which of course does not include my custom icons...

As far as I found out this option is not a native Android feature but is implemented independently by different devices manufactures. Since I have no such a device, I cannot reproduce or test this problem.

Is there any way to skip these device settings and force the app use my custom font?


EDIT:

This is how I added the custom font to my project:

  • Created a new fonts folder in res/ and put my font files there
  • Use android:fontFamily="@font/my_custom_font" on TextViews, etc.
  • done

This is then overwritten by the system settings on some devices (e.g. by the Huawei Design Manager). Can this be avoided?

Andrei Herford
  • 17,570
  • 19
  • 91
  • 225

1 Answers1

0

Put your font in the res/font folder and reference them in your TextView in case you need a specific one with the android:fontFamily attribute.

For the whole app put

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

In

styles.xml 

Source : Youtube Video

Vishnu
  • 53
  • 1
  • 3
  • Thanks. This is exactly what I did this is overwritten by the device settings. Question is, if there is any way to override this device settings / to force the usage of my font. – Andrei Herford Mar 25 '21 at 19:24