0

I created an app in android 3.0.1

I used Segoe UI light font as default for overall app. Now when I tested in different phones. I found a problem that in case if my phone's font is customized with different font style. That font also affect my app's UI font. That causes me more UI collapse in my app due to custom phone font.

Please help me to make my app's font fixed and not to be changed by phone's custom font.

Thanks in advance.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Rohan Ashik
  • 73
  • 1
  • 12

3 Answers3

0

Use a custom typeface and set your views texts to that typeface. As you will be putting the font file in your app structure, it should solve your problem. Reference: How to use custom font in Android Studio

Aykut Karaca
  • 350
  • 3
  • 15
  • Yes yes offcource I did the same. For your referrence see this android:fontFamily="@font/segoe" this is how I mentioned in all TextView. It works fine in regular phones. If a phone uses a custom font in main system. then it also affects the app font also. Thats the problem – Rohan Ashik Jan 29 '18 at 18:26
0

you can integrate this easy to use custom font library Calligraphy and assign a custom font to your application OR you can use downloadable fonts from latest Android documentation, using the Calligraphy library is the easiest way of setting your app's custom font across all phones even with custom ROMS

-1

So the way to do that is to override the View you want a custom font for, and progmmatically set the Typeface in the constructor. E.G. for a TextView

public CustomFontTextView extends TextView{


 public CustomFontTextView(final Context context, final AttributeSet set){
      super(context, set);
  this.setTypeface(fetchTypeFace());    
 }

 protected Typeface fetchTypeFace(){
   return Typeface.createFromAsset(resources.getAssets(),"your_font.ttf"));
 } 

}
whompum
  • 69
  • 2
  • 12