android-fonts
How to change the FontSize in an Android WebView?
I finally found it:- WebSettings webSettings = webView.getSettings(); either setTextSize or webSettings.setTextSize(WebSettings.TextSize.SMALLEST); This one works too:- webSettings.setDefaultFontSize(10);
Android Typeface createFromAsset
You can use your View‘s getContext() method to get the current Context, then use it to get the assets: Typeface font = Typeface.createFromAsset(getContext().getAssets(), “robotobold.ttf”);
“RuntimeException: native typeface cannot be made” when loading font
Android does not support OpenType (OTF), only TrueType (TTF), so your Molot.otf font probably will not work. I wrote both of those blog posts you link to in your opening sentence (the one is a pirated copy of the other), and they do not use Molot.otf. (BTW, I somewhat repaired the formatting of that post … Read more
How do I specify eg. Roboto-Medium or Roboto-Black in styles.xml
On Android 5.0 you can set Roboto Medium with sans-serif-medium. This solution, taken from Google iosched 2014, uses sans-serif on Android pre-v21: values/styles.xml <style name=”MyStyle”> <item name=”android:fontFamily”>@string/font_fontFamily_medium</item> </style> values/fonts.xml <string name=”font_fontFamily_medium”>sans-serif</string> values-v21/fonts.xml <string name=”font_fontFamily_medium”>sans-serif-medium</string>
How to add external fonts to android application
You need to create fonts folder under assets folder in your project and put your TTF into it. Then in your Activity onCreate() TextView myTextView=(TextView)findViewById(R.id.textBox); Typeface typeFace=Typeface.createFromAsset(getAssets(),”fonts/mytruetypefont.ttf”); myTextView.setTypeface(typeFace); Please note that not all TTF will work. While I was experimenting, it worked just for a subset (on Windows the ones whose name is written in … Read more
how to prevent system font-size changing effects to android application?
If you require your text to remain the same size, you’ll have to use dp. To quote the documentation: An sp is the same base unit, but is scaled by the user’s preferred text size (it’s a scale-independent pixel), so you should use this measurement unit when defining text size (but never for layout sizes). … Read more
How to use specified weights for fonts in XML
Its looks like android following web standards for font management and sizing for android app. The “font-weight” property is used to define the weight of a font, such as regular or bold. But for all other weights a numerical range from 100 to 900 is used. One of the challenges with web fonts is that … Read more
How to set custom font for a whole application in Android?
All I did was: 1: Added “new resource directory” to the RES folder, Selected RESOURCE TYPE as “font” from the drop-down given, named the new directory “font” and saved. 2: Added my “custom_font.ttf” to the FONT folder just created. 3: Added my custom font in the application base theme in STYLES.XML DONE.
How set Spannable object font with custom font
This is a late answer but will help others to solve the issue. Use the following code:(I’m using Bangla and Tamil font) TextView txt = (TextView) findViewById(R.id.custom_fonts); txt.setTextSize(30); Typeface font = Typeface.createFromAsset(getAssets(), “Akshar.ttf”); Typeface font2 = Typeface.createFromAsset(getAssets(), “bangla.ttf”); SpannableStringBuilder SS = new SpannableStringBuilder(“আমারநல்வரவு”); SS.setSpan (new CustomTypefaceSpan(“”, font2), 0, 4,Spanned.SPAN_EXCLUSIVE_INCLUSIVE); SS.setSpan (new CustomTypefaceSpan(“”, font), 4, 11,Spanned.SPAN_EXCLUSIVE_INCLUSIVE); … Read more