More specifically if the font is missing the glyphs for a languages characters(double byte characters, etc) does Android default to another font or does it just show the SBOD(square box of death) symbol in place of the character?
I'm also curious how people handle font internationalization when using custom fonts.
I am not sure but I guess the app needs to handle it.Many apps place images of the symbol when its not supported by the font.Google recently launched Noto-https://www.google.com/get/noto/ which is supposed to support most of the languages.
I have a rooted phone and was trying to play around with my phone. It has android 2.2 installed. What I want to do is to display Hndi/Tamil/Telugu text inside the application that I was trying to develop. Obviously android 2.2 does not support these fonts.
As the phone is rooted doing this was easy for one language. I just followed the tips given in this link Enable Hindi Fonts on Rooted Device and was able to get Hindi fonts throughout the system. Similar approach helped me setup Tamil fonts.
But I am not able to make both Hindi and Tamil work together. The possible solutions I can think off are :
i) Create a common ttf file which shall contain both Hindi and Tamil fonts. But I have no idea whether this is possible or not.
ii) Keep a .ttf file for each language in the assets/fonts/ folder but again this is showing just square boxes on the device.
I tried this link Display Different Languages In Applicationtoo but again this seems to work for only supported fonts.
Any guidance would be highly appreciated. Thanks
Try this sample application.I shared here the whole application code for how to display one text in multiple languages especially Kannada and Telugu.
I am trying to display text in Indian regional languages on an Android app.
I've set up all the localization folders even though, I just want to have only one language for my app (say Punjabi).
In my strings.xml I have tried putting Hindi characters and Chinese characters and these are displayed correctly on the emulator. But when I put in Punjabi characters nothing shows up on the emulator.
Any reason for this? Can I overcome this problem?
I have the option of using a .ttf file in the assets folder for punjabi font. But that is not what I want to do because it does not give me complete control over the contents being displayed. Each .ttf behaves differently.
Any help is truly appreciated.
There is no support for local Indian languages on Android as yet. Hence the UTF-8 characters that fall outside the acceptable range for Android are ignored. Hence we see a blank being displayed.
Hi any body know how we can support Hindi and Gujrati Languge support in android. I used below code but it is not supported, I see only box.
I put string file in res/values-hi/string.xml folder. There is some key value for Hindi language. It is used for Hindi Language:
Locale locale = new Locale("hi");
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources()
.updateConfiguration(config,getBaseContext().getResources().getDisplayMetrics());
Anyone knows than please give me solution.
As gujarati and hindi languages are not supported by Android, you can still give that support to your Application.
For Gujarati copy the C:\WINDOWS\Fonts\Shruti.TTF file to your Assets folder click here to know how to make assets folder
then use the following code.
TextView text_view = new TextView(this);
Typeface font = Typeface.createFromAsset(getAssets(), "Shruti.TTF");
text_view.setTypeface(font);
text_view.setText("ગુજરાતી");
Shruti.TTF file is for Gujarati font.
Similarly you can add support for hindi file.
Hindi and many other Indian langy=uages are not supported in Android. Though HTC is planning to provide support for some Indian languages.Read Here.
Now, the code you used to put Hindi text in your app will only work if the Android phone has built in support for Hindi language.
You need to embed Hindi fonts in your app as Kri said.
Hindi reading method in opera mini 1 - First install latest version of "Opera Mini" on Android powered tablet or phone which is available free on Android Market. Otherwise go to official site of opera. (Read about Opera Mini & download) 2 - After that go to address bar & type opera:config and nothing should have www or http://. 3. Then come to the menu & at its end see "use bitmap fonts for complex scripts". No sentence will be written in front of. You change it to Yes. 4. Save it. Now Open any Hindi site and see hindi font on your mobile / tablet instead of square font.
Your can try the following also… Install Hindi font (including all Indian language) as system font - go this link:- http://android-bucket.blogspot.com/2011/07/hindi-font-installation-for-advance.html (Only for Advance users)
PREAMBLE: since API 17 (Android 4.2), there's a method TextView.setTextLocale() that explicitly solves this problem for TextViews and derived classes. Assign a Japanese locale (Locale.JAPAN), and Unihan characters will look Japanese.
I have an application on Android that displays Japanese text in WebViews and TextViews. There are some Chinese characters (kanji) that look, by convention, differently in China and in Japan, but share the same Unicode codepoint. Normally, the browser would rely upon the lang tag to choose the correct glyph. On Android, they all default to their Chinese shapes, and I want Japanese shapes.
The problem is well explained in this article. This article also serves as a perfect illustration of the problem - when watched on Android (up to 2.2), the characters in the "Examples of language-dependent characters" all look the same, and Chinese.
Using the lang="ja" attribute does not help. Switching the whole system locale to Japanese does not help either.
I'm wondering about Android phones that are sold in Japan. Do characters like 直, 今, 化 look Chinese-style on those, too? I'm assuming not.
So the questions are: are there official localized images of Android out there? Can I get one to run on the emulator? Is the DroidSansFallback font still the only CJK-enabled font on those? And if it is, is it the same as on the vanilla USA Android?
I'm kind of hoping that the Japanese glyphs are hidden somewhere deep in the font (Unicode private area or something). If so, I could leverage them...
EDIT: located DroidSansJapanese.ttf, installed it on the emulator by copying into /system/fonts, restarted. It made no difference on the look of the Unihan article. Even the hint area of the Japanese text input (which should know better) displays as if Chinese.
How do I know the typeface name of the DroidSansJapanese.ttf? I have a feeling it's still Droid Sans, same as in the built-in DroidSansFallback font. But if they contain the same typeface, what governs which one should take precedence? One would think - system locale, but apparently not. Fonts in Android are installed just by copying, right?
There are fonts with full Japanese support. I've heard some people talking about DroidSansJapanese.tff and TakaoPGothic.
Found a somewhat cludgey solution.
The DroidSansJapanese.ttf font exists and is available for download, for example, here. I downloaded it, renamed it to DroidSansJapanese.mp3 to avoid the 1MB compressed asset limit, and placed it under assets/web. I then introduced the following CSS statement:
#font-face
{
font-family: "DroidJP";
src:url('DroidSansJapanese.mp3')
}
Then I added 'DroidJP' to the font-family of every relevant CSS style. The way I load my HTML, the assets/web folder is already designated as the base for loading linked content.
Upon careful examination, I found several places in the app where Japanese was in TextViews. For those, I've loaded the typeface like this:
Typeface s_JFont =
Typeface.createFromAsset(Ctxt.getAssets(), "web/DroidSansJapanese.mp3");
and called setTypeface() on every relevant TextView. Now for PROFIT!
This expanded my APK by about 1 MB. There was an alternative way, where I'd store the font in the assets in compressed form - that'd save me about 500 KB of APK size, but then I'd have to expand it to phone memory on the first run, worry about data folder path, and lose compatibility with Android 1.5.
Some credit is due: here and here. Does not work on Android 2.1 (the WebViews, not the TextViews) - that's a known bug.
Now, the question remains - how do I identify devices where the default font already contains the Japanese shapes?
EDIT re: the mp3 hack. I've implemented the chunked solution at first, but then decided to go with font in the assets. The chunked approach has one upside - smaller APK size - and the following downsides:
Consumes more phone memory - you end up storing both compressed font in assets and uncompressed in the data directory
Is incompatible with Android 1.5 on the TextView side - the method Typeface.createFromFile() was introduced in API level 4
Complicates HTML generation - the CSS with the #font-face declaration needs to be parametrised, since the data path is a variable
Slows down the first app startup - you spend time combining the chunks
Storing the font as a compressed asset is not an option either - the font then doesn't show up in WebView, and you can clearly see in LogCat the message about "Data exceeds UNCOMPRESS_DATA_MAX".
Using the following in your onCreate/OnCreateView:
AssetManager am = getContext().getApplicationContext().getAssets();
mDroidSansJapaneseTypeface = Typeface.createFromAsset(am, String.format(Locale.JAPAN, "fonts/%s", "DroidSansJapanese.ttf")); //I put the font file in the assets/fonts/ folder
And then for your textviews:
myTextView.setTypeface(mDroidSansJapaneseTypeface);
myTextView.setTextLocale(Locale.JAPAN);
Be aware that not 100% of all fonts will be displayed in Android. I haven't seen too many problems for Japanese characters, but other CJK characters may appear as blank boxes, no matter what ttf file you use.