Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to specify that Android's TypeFace should use lining numbers and not old-style numbers?

I'm using Raleway, and the default is to use old-style numbers where 3, 4, 5, 7, and 9 descend below the baseline. On iOS I can specify a feature setting to use the "upper case" (lining) numbers:

UIFontFeatureSelectorIdentifierKey : @(kUpperCaseNumbersSelector)

How do I do this on Android?

like image 217
i_am_jorf Avatar asked Oct 27 '25 09:10

i_am_jorf


1 Answers

So, for Android 5.0 and above (API 21), you can use the fontFeatureSettings property to enable this:

TextView myTextView = findViewById(R.id.myTextView);
myTextView.setFontFeatureSettings("lnum"); // Enabling lining numbers

Which I've tested to work with Raleway. Unfortunately that's probably not a sufficient option. There's a similar question here in which the suggested solution is to re-upload the font to FontSquirrel's font generator and substitute the lining number glyphs for the tabular glyphs.

like image 112
Kevin Coppock Avatar answered Oct 28 '25 22:10

Kevin Coppock