I have to implement Nepali Font on my application and for that I have used unicode font named DroidSansDevanagari-Regular.ttf.The reason I have used this font is that on my Rooted Galaxy S2 I900,I have installed Resurrection Remix 3.06 JB(AOKP) which renders Nepali Font correctly. And under system/fonts folder I have found this DroidSansDevanagari-Regular.ttf font,which is responsible for displaying Nepali Font.
Further I have used the correct way of using custom font
Typeface font =
Typeface.createFromAsset(context.getAssets(),
"fonts/DroidSansDevanagari- Regular.ttf");
someTextView.setTypeface(font);
And though my application displays the Nepali Font it doesn't correctly maps the font.Using same font I get correct mapping on Rooted Galaxy S2 phone,but I can't get correct mapping on other phones. Let me illustrate this by picture
Correct Mapping
InCorrect Mapping
So,my question is how to map the font in correct manner as done by my Rooted Galaxy S2 phone.For that do I have to look upon AOKP project and look upon EditText or Typeface classes.Please provide me guidance on how to correctly map the fonts on each and every device
Thanks in advance
For correct font mapping ,indic text renderer is the best solution I found so far.But before implementing this library,please look upon the solution explained on this issue in order to render fonts with long texts and without any line spacing in between words
Related
I am using arial.ttf in my project. In genymotion emulator,in some mobile devices my text view is look good. But in Sony Xperia tablet 4.1.1 i have a text rendering problem. Text looking very bad. What should i do?
<TextView
android:id="#+id/yazi1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Ret"
android:textColor="#color/siyah"
android:textColorHint="#color/siyah"
android:textSize="#dimen/font14" />
Typeface tfArial = Typeface.createFromAsset(getAssets(), "arial_tur2.ttf")
screenshot http://hizliresim.com/ynJjWk
Use OTF instead of TTF. That can be your problem. I was in this situation and changing the file with OTF solved my problem.
OTF is more likely to be a “better” font, as it supports more advanced typesetting features (smallcaps, alternates, ligatures and so on actually inside the font rather than in fiddly separate expert set fonts). It can also contain either spline (TTF-style) or Bezier (PostScript Type 1-style) curves, so hopefully you're getting the shapes the font was originally designed in and not a potentially-poorer-quality conversion.
On the other hand, if you're downloading free fonts from shovelware sites, you're unlikely to get any of that. Indeed, you may simple be getting a TTF font renamed to OTF.
I am using the following line of code to change the font type in android application :L
Typeface font = Typeface.createFromAsset(this.getAssets(), "fonts/Abumohammed.ttf");
textView.setTypeface(font);
I am sure that Abumohammed.ttf is in assets/fonts folder .. but the font don't change and don't has any effect on the textview !!
Android does not support every font file. When it fails, it tends to fail silently, showing the default font instead. I have no idea what Android does not like about some of them.
I would find some font that definitely works, such as this one, and try it to make sure that the rest of your code is OK. If indeed you determine that the font file does not work, AFAIK you have no choice but to find some other font.
I was annoyed enough by this that I thought I'd share some results of my digging. I tried a few font files that ended up using the fallback font. To 'fix' some of these files, I simply had to open the file in FontForge, then File->Generate Font and re-save as TTF. This allowed some that were not showing to draw properly.
Others required moving the glyphs from the Microsoft area (U+F030) to U+0030 range.
I haven't educated myself on what 'Generate Font' actually does. But, now that I know HOW to fix it, I can at least start to figure out why it isn't working. I suspect this can only be fixed in the AOSP tree however.
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.