Does Android Support Windows Fonts? And How To Write Unicode Text Into A Textview?
Is it possible to use Windows fonts (.ttf file) in Android applications? I have some unicode-8 texts like this: جۆرەه and I want
Solution 1:
Well, yes you can use .ttf
files in Android Applications. Navigate to your Android project's src/main folder, make a new folder assets there and paste your .ttf
file in it. You can place your font in the directory which supports your language. After that, you can use the font in an EditText
like this:
// For Setting the typeface in the TextViewsTypefacexyzTypeFace= Typeface.createFromAsset(getAssets(), "xyz.ttf");
TextViewtaglineTextView= (TextView) findViewById(R.id.taglineTextView);
taglineTextView.setTextSize(25);
taglineTextView.setTypeface(xyzTypeFace);
Solution 2:
Thank you guys for your answers,
Finally, I solved the problem by using the following method..
publicstaticStringfixEncodingUnicode(String response) {
String str = "";
try {
str = newString(response.getBytes("ISO-8859-1"), "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
String decodedStr = Html.fromHtml(str).toString();
return decodedStr;
}
Post a Comment for "Does Android Support Windows Fonts? And How To Write Unicode Text Into A Textview?"