Reputation: 845
I have been using Devanagari/Hindi fonts lately. My android application supports all way back to android 2.1 using sherlock library. My question is, is there any way to determine if the device supports/provides devanagari/hindi fonts programmatically?
I know android phones having less than gingerbread doesn't support these fonts, so I can safely assume that I can use my custom font available in the application itself. But I don't want to use my custom font, if these fonts are readily available from the system (for android phone greater than Ice Cream Sandwich).
My application is working fine with my custom font.
Code to use custom font:
Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/mangal.ttf");
TextView txtviewdevanagari = (TextView) findViewById(R.id.textViewdevnagari);
txtviewdevanagari.setTypeface(typeface);
Code to determine the android OS:
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
String str = fixUnicode(content[1]);
Log.d("DetailActivity", "from gingerbread");
Log.d("DetailActivity", str);
if(!content[1].equals(null))txtviewdevanagari.setText(str);
}else{
Log.d("DetailActivity", "from ICS+");
if(!content[1].equals(null))txtviewdevanagari.setText(content[1]);
}
Upvotes: 0
Views: 291
Reputation: 24998
There are only 3 fonts available in Android:
1. normal (Droid Sans)
2. serif (Droid Serif)
3. monospace (Droid Sans Mono)
Source
and starting with 4.1 Roboto has become available:
android:fontFamily="sans-serif" // roboto regular
android:fontFamily="sans-serif-light" // roboto light
android:fontFamily="sans-serif-condensed" // roboto condensed
android:fontFamily="sans-serif-thin" // roboto thin (android 4.2)
Unlike in Java Swing, there is no way you can determine if a certain font is available in Android :)
Upvotes: 1