有没有办法指定 Android 的 TypeFace 应该使用衬里数字而不是旧式数字?

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

我正在使用 Raleway,默认情况下使用旧式数字,其中 3、4、5、7 和 9 低于基线。在 iOS 上,我可以指定一个功能设置以使用 "upper case"(衬里)数字:

UIFontFeatureSelectorIdentifierKey : @(kUpperCaseNumbersSelector)

如何在 Android 上执行此操作?

因此,对于 Android 5.0 及更高版本 (API 21),您可以使用 fontFeatureSettings 属性 来启用此功能:

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

我已经测试过它可以与 Raleway 一起使用。不幸的是,这可能不是一个充分的选择。有一个类似的问题 here in which the suggested solution is to re-upload the font to FontSquirrel's font generator 并将内衬数字字形替换为表格字形。