I need Heavy asterisk (u2731) character in my app.
For android 3 and later I used the the following in my TextView:
android:text="\u2731"
and it works fine. But in android 2.x I see a rectangle instead of asterisk. I think that the specific Unicode character is missing in default fonts of Android 2.x .
So what can I do to see this character in Android 2.x? May be I need to load a custom font?
Which font contains this character?
As far as I know, Android 3.0 uses the Roboto font.
You can easily find it for free as a ttf font you might want to store in your assets folder.
Here is the reference and downlad site
[EDIT]
A workaround could be something like this:
String str = "your string containing fat asterisks (**)";
str = str.replace("**", "<b>*</b>");
myTextView.setText(Html.fromHtml(str));
It will make all the ** occurrences become a BOLD *
Related
Encoding Problem in android String
Web service return below string response
ãñøþ1219
but i getting response like ����1219
I am using below code to convert but it is not working
URLEncoder.encode(result, "UTF-8");
Please Help Me how i can fix this problem
Thanks In Advance
you must use Unicode font in order to display correctly Unicode text.
Most Android devices do not come with a complete set of Unicode fonts. Also in order to display Unicode text in a way that can be read properly you need to include a proper font for the script concerned.
Hence you can try as follows :
Typeface tf =Typeface.createFromAsset(getApplicationContext().getAssets(), "your_font.ttf");
text.setTypeface(tf,Typeface.BOLD);
text.setText(Html.fromHtml(your_text_with_unicode));
When you are getting response like ����1219, it is a font problem. When Android renders symbols as empty squares or the squares shown in above response,it means that Unicode support is working, but the font does not have those symbols. Adding to that the complex scripts like Indic scripts (e.g. Devanagari) require special rendering engine on top of that.
I have an Android- as well as iPhone-Version of my App. In iOS I can tell the CSV-Parser to encode the string with UTF-8. Apparently this is also possible in Android when I use the InputStreamReader when I open the CSV file.
isr = new InputStreamReader(getAssets().open(
"english.csv"), "UTF-8");
Also when I check the encoding
System.out.println(isr.getEncoding());
it returns UTF8.
The weird thing now is, that some phonetic words!! are shown completely correct, whereas most of them show phonetic words containing square symbols. Although the exact same letters are shown correctly in other words.
Ok guys,
apparently it only works with applying another font. Because the encoding really works. Only Android standard fonts have their problem displaying phonetic letters.
I followed this guy's solution:
I don't use unicode characters in my android-textview.How can I do this?
and used another font called Constructium. Just have to import it into your assets folder and use it either through the XML Layout file or directly in your code, as this guy has done it:
How to change the font on the TextView?
Now, I'm developing an android application, which needs to show some special characters. I need this font "Arial Unicode MS" to show the characters correctly. And I add the following code in my main activity:
EditText editText = (EditText) findViewById(R.id.flipped_window);
Typeface font = Typeface.createFromAsset(getAssets(),"ARIALUNI.TTF");
editText.setTypeface(font);
It does work. However, the size of this font file is too big, it's 22,731 kb.
Is there better solution for this problem? Thanks.
Your real problem is redistributing a copyrighted font. :-)
As Craig mentioned, you're illegally redistributing a copyrighted font.
My best guess would be to first look at all the glyphs available in Droid Sans; in my experience, it should be good enough unless you're looking to use it for formatting.
If you can't do that, create the symbols you need as PNG or GIF images and insert them inline. (GIFs will be substantially smaller for black & white).
buddy, you can decrease font size with Font creator software with elimination unused characters in font. you can decrease it to 50,60kb also :-)
password download link : www.downloadsoftware.ir
I wonder how whatsapp gives support for that. I could use emojis on iPhone because it is natively supported. I'm not developing for bb neither android but I need to help a coder with this stuff.
The bb guy told me that he can add a font as a project resource (ttf), but since emojis are colored graphics, I'm not sure if i can create a ttf. I do not know anything about fonts either.
As you can see, my unknowledge is huge on this. I just need some tips that point me to the right way to research.
Thanks!
On Android you can make a BitMap font with the tutorial i found here. Then you can embed all your Emoji into that font.
For making this on the BlackBerry you can use the FontFamily class. Here is a tutorial that explains how this works.
Have fun! :-)
From my experience most emoticons (emoji) do not use a font, but are rather bitmap graphics (e.g. emoticons in the default Android text editor). There are several downsides to using a font:
Suppose you made the characters a, b, c, d etc into emoticons - the user would then be unable to read/send messages with those characters in without them turning to emoticons.
Fonts are generally quite large as they contain a lot of information for displaying the text at different sizes/styles
Using bitmap graphics will allow you to easily use the same emoticons across a wide range of devices, whilst using standard device fonts the text around the emoticons.
You will have to parse the string that you are displaying, find the emoticons, and replace them with images.
On Android for instance you would accomplish this with:
Search the string for all emoticon occurences (regex can do this easily enough)
Replace all emoticons with the string <img src="emoticon.png" /> (althugh change emoticon.png based on the type of emoticon)
Convert the String to HTML with String myHtmlString = Html.fromHtml(myEmoticonString, myImageGetter, null);
Display the string in a TextView myTextView.setText(myHtmlString)
In step 3 myImageGetter needs to be an instance of Html.ImageGetter which returns a graphic (drawable) based on the src attribute of the images in the string (ie it converts a string file name to an actual graphic)
The steps on other platforms would be different but you should be able to use the same basic method (parse string, replace emoticons with images).
Let me tell what I know, I dont know emoji, but googling it had me thinking it is a set of emoticons, primarily Japanese in origin. If that is true I would like to point out that it is common to create custom fonts using a font file (shown here). And in that font file you should be able to embed these emoticons and use them.
The link I provided above, is for J2ME, but the logic and design should be similar. Hope this helps.
There are a number of posts all over the internet on this topic, however none of them have been able to isolate and solve the problem.
I am trying to show some special UTF-8 encoded symbols stored in a SQLite database using a TextView, however all it shows is boxes. I understand what this means is that right font is not installed. But when I print those symbols using Arial font on Mac it works.
I am trying to use an Arial typeface on the device and the emulator.
Any advise.
It works on your Mac because the font used by your mac contains those special characters. It would be impossible to create a fontfile that contains all characters defined in unicode. Chinese fonts are a good example: none of them contain all of the ~60.000 known Chinese characters because the font file would be huge and unusable.
You could try using the font from your Mac on android (might be copyright issues - try finding a free font that contains the characters: package the (ttf) file in your application, for example in the /assets folder, and then in your application load that font with
TypeFace typeFace = Typeface.createFromAsset(assetmanager,"fontfile.ttf");
You can then use this in a TextView like so:
TextView view = (TextView) findById(R.id.mytext);
view.setTypeFace(typeFace);
If I'm understanding your situation correctly, you might want to consider the StringEscapeUtils.unescapeXml() method. It's in the common-lang.jar file available here: http://commons.apache.org/lang/
It will take encoded symbols (for example ' for an apostrophe) and get you to a proper character.