Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple font Not working at time in application

Friends, Running out in a strange issue. I want to use two font (Gujarat & Hindi) in same applicaion. Here is process of install fonts in device

  • Needed root device.
  • Install Font Installer App
  • Download Lohit-Devanagari.ttf & Lohit-Gujarati.ttf from this site
  • Copy ttf files file at /system/fonts
  • Given Read/Write Permission & installed both fonts
  • Reboot device

Issue

After reboot device I can read only that font which I installed last. Either Gujarati or Devangari

Note:- I am creating Only SoftKeyboard Apps which will work in all app, so I can't use Typeface class

I am just doing setText for read fonts..

textView1.setText("TextView1 ગુજરાતી");
textView2.setText("TextView2 हिन्दी ");

I want like this.

TextView1 ગુજરાતી
TextView2 हिन्दी

But I getting output like this

TextView1 ગુજરાતી
TextView2 ☐☐☐☐☐☐

or

TextView1 ☐☐☐☐☐☐☐
TextView2 हिन्दी

Note:- I am creating Only SoftKeyboard Apps which will work in all app, so I can't use Typeface class

like image 682
Niranj Patel Avatar asked Nov 04 '22 09:11

Niranj Patel


2 Answers

Have you tried to place these fonts in your asset folder?

Typeface tf = Typeface.createFromAsset(this.getAssets(), "fonts/Lohit-Devanagari.ttf");
TextView tv = (TextView) findViewById(R.id.txtOnlyOne)
tv.setText("TextView1 ગુજરાતી");    
tv.setTypeface(tf);

Is root and fonts in system a requirement?

like image 161
Waza_Be Avatar answered Nov 08 '22 07:11

Waza_Be


Installing fonts with the help of Font Installer apps, just replace the DroidSansFallback.ttf file from /system/fonts. I suggestion you to merge the fonts of Hindi and Gujarati (in your case) into one, then install the font using your app. Now you can see both of your fonts.

like image 30
Manish Kumar Avatar answered Nov 08 '22 07:11

Manish Kumar