Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First Download the ttf files from any one of the links,</p> <p><a href="http://www.neda.net.ir/downloads/fonts/persian.ttf" rel="nofollow">http://www.neda.net.ir/downloads/fonts/persian.ttf</a></p> <p><a href="http://alefba.us/wp-content/plugins/download-monitor/download.php?id=farsifonts-0.4.zip" rel="nofollow">http://alefba.us/wp-content/plugins/download-monitor/download.php?id=farsifonts-0.4.zip</a></p> <pre><code> copy the ttf file into assets folder in your project,, </code></pre> <p>first select the Languge code as Farsi in code on clicking button</p> <p>button.setOnClickListener(new View.OnClickListener() {</p> <pre><code> @Override public void onClick(View v) { Locale myLocale = new Locale("fa"); Resources res = getResources(); DisplayMetrics dispmetrics = res.getDisplayMetrics(); Configuration conf = res.getConfiguration(); conf.locale = myLocale; res.updateConfiguration(conf, dispmetrics); String current_locale = getResources().getConfiguration().locale.getDisplayName(); System.out.println(current_locale); Intent refresh = new Intent(getBaseContext(), MainActivity.class); startActivity(refresh); } }); </code></pre> <p>then below , setContentView(R.layout.activity_main);</p> <pre><code> implement this code,,to get the typeFace done String current_locale = getResources().getConfiguration().locale.getDisplayName(); System.out.println("-----"+current_locale); if(current_locale.equals("Persian")) { Typeface font1 = Typeface.createFromAsset(getAssets(), "persian.ttf"); b1.setTypeface(font1); } </code></pre> <p>this solution definitely works and the reason that square brackets appears in your phone is due to that <strong>Farsi Unicode is not installed on your Mobile and if u want to install Farsi font your phone must be rooted one</strong></p> <p>--Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload