问题
Is it possible to use Windows fonts (.ttf file) in Android applications?
I have some unicode-8 texts like this:
جۆرەه
and I want to put it into a textView,, I tried some other methods but they did not work. Now, I want to embed a font into the application to read the text correctly..
By the way, it is Kurdish Language..
Any help is appreciated
回答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 TextViews
Typeface xyzTypeFace = Typeface.createFromAsset(getAssets(), "xyz.ttf");
TextView taglineTextView = (TextView) findViewById(R.id.taglineTextView);
taglineTextView.setTextSize(25);
taglineTextView.setTypeface(xyzTypeFace);
回答2:
Thank you guys for your answers,
Finally, I solved the problem by using the following method..
public static String fixEncodingUnicode(String response) { String str = ""; try { str = new String(response.getBytes("ISO-8859-1"), "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } String decodedStr = Html.fromHtml(str).toString(); return decodedStr; }
来源:https://stackoverflow.com/questions/36106570/does-android-support-windows-fonts-and-how-to-write-unicode-text-into-a-textvie