Numbers in localized custom font in android - android

I am developing an Android application using Bengali Font. As such there is no issue in using Bengali Font for text item. Text are taken from text files and loaded using Bengali Typeface. But I am not sure how best, I can accommodate numeric figure. For example final scores of Test is presented in a format like:
Your Score = 50
Suppose I want to present it in Bengali like:
আপনার স্কোর = ৫০
The problem is numeric figure is calculated at run-time. I thought of keeping a map files containing digit and their localized characters and thus presenting the numbers in custom font. But that is not very efficient way. In Android is there any support for formatting numbers in localized font like Bengali or Tamil?

To use numbers in custom font look at the Android documentation of NumericShaper.

Related

Apply two custom fonts in a paragraph and display them in android

The project I worked on has some rare characters that are not supported by Unicode
"private-use area" (PUA) code points in the range U+EE80 through U+EFF. One custom open type font range from U+0000 to U+FFFF and the other has characters beyond U+FFFF. Both fonts are in the same language.
I need to display the characters based on their PUA range(characters are retrieved from database in random lines, no fixed location for a particular character). I tried different solutions but none of them works(bidi class with typeface, composite fonts, merging fonts, fallback, etc).
Has somebody used custom fonts that can display different font based on their range of PUA code points(character by character) on Android?
If you are using java to develop your android app, java only support unicode system so you cannot use characters beyond unicode system.

How to use different png textless buttons for different languages in android?

I have a set of textless PNG buttons that I did adding the text in photoshop in English and in Spanish, I don't have the option to use the string file cause the text is already added in Photoshop. How do I use the spanish buttons if the user selects spanish language??.......
The same as Spanish strings. You can use drawable-en and drawable-es same way as for strings - values-en, values-es. Put image for English into drawable-en, and for Spanish - into drawable-es
PNG buttons that I did adding the text in photoshop
--> that's your main problem, trying to circumvent it will probably prove to be less efficient than using the framework's built-in system to produce buttons with text and images (this question discusses how to do that). But if you can't, you can probably use the system's Locale to determine the language of the user, like so :
Locale.getDefault().getLanguage()
// this will return "en" for english

How to get system Android emoji drawable by unicode character?

I want to implement an android emoji keyboard just using emoji unicode array, without any extra res.
So for the emoji unicode character, I need to get the drawable from android system, if the system doesn't support the charactor, I just ignore this character.
After some basic research,
emojicon, https://github.com/rockerhieu/emojicon
emojicon, https://github.com/ankushsachdeva/emojicon
These implements all use self made resources.
use TextView setText, tv.setText("\u263A"); TextView can show the resource, but how can I get the resource?
Here's the problem- the system doesn't determine what characters can be displayed. The font does. The font needs to define how to draw every character it will display. That's why you'll see boxes or ? for missing characters- that's the font's default render. There is no method on Android to test if a character will display in a given font (although it would be really nice). And since there's no way to know what font the EditText is using, there's no way to know if a given character is supported. Your best bet is to limit yourself to characters defined in the default Android System font. But even then you're assuming the OEM didn't use a different default font, the user hasn't overridden it, and the app hasn't overridden it. Basically, you're forced to guess and hope.

how to convert ascii fonts to unicode for translation

I am developing an android and ios app which will be translated in multiple languages including english, hindi and gurmukhi. We have some pdf files in Gurmukhi that use ASCII fonts instead of unicode and we need to translate them to other languages so that when we try to copy the text we end up with some weird text. Is there a way to do it?
Thanks in advance.
Every symbol font has its own repertoire, so you need a custom lookup table from the ‘wrong’ character to the real character corresponding to what the glyph looks like in the particular font you are using. You can work out this table by installing the font in question and opening it in the Character Map (charmap.exe), noting down which symbol appears in each of the boxes normally occupied by A, B, C...
There is a converter tool here which knows about some common symbol fonts. If the font you want is in that list, you could try to extract the lookup table by pasting in all the characters in the range 32–126;128–255 (!"#$%&'()*+,-./0123456789:;<=>?#ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_``abcdefghijklmnopqrstuvwxyz{|}~¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ) and grabbing what comes out when converted to ‘Unicode’.
Do you need to do the conversion in the application itself? If so you will typically need to write a character-by-character lookup loop. If not, best to use a tool like this manually to convert the material you want into standard Unicode, because dealing with text encoded in arbitrary symbol fonts is a pain in the neck.

Android: Display Special Characters

I would like to display special characters such as: ṁ ṭ m ē. In case they don't display here as well, this is how the four characters should look like:
In Android, these will display in squares. For other scripts, I am able to come over this problem with using a different font. But in this case setting the font (TextView.setTypeFace) will not solve this issue. These characters display correctly in for example OpenOffice (using Arial or Courier New), but inside Android it doesn't even when using the same fonts).
I also tried having the string saved as a unicode encoded string (e.g. in strings.xml: \u1E41 \u1E6D) getting the same result (in the logs they appear as they should). Any ideas?
If these characters are representable in Unicode, then you should be able to use Html.fromHtml() to get the glyph into a TextView, e.g.
textView.setText(Html.fromHtml("Ӓ"), TextView.BufferType.SPANNABLE);
It was really only a font issue. It was just hard to find a font that supports all characters I need.
Seeing that Google Translate has no problems with transliteration characters motivated me to make a more thorough search for fonts. Below is a list of useful fonts for this purpose:
http://guindo.pntic.mec.es/jmag0042/alphaeng.html (extensive but non-free)
http://users.teilar.gr/~g1951d/
http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=FontDownloads
http://www.mufi.info/fonts/

Categories

Resources