Skip to content Skip to sidebar Skip to footer

Use Opentype Font Features In Android

Is there any way to use OpenType font features (small caps, old style figures, etc.) in Android? Something like a custom TextView would be ideal.

Solution 1:

Solution 2:

Outdated, look at dcow's answer instead

I don't think Android provide such API but you may use WebView, specially the new KitKat Chrome WebView would be nice if is not supported on older WebView. A sample that you can see a opentype feature setting difference via preinstalled Droid Arabic Naskh font: <div style="-webkit-font-feature-settings: 'rlig' 0">لا</div>

Otherwise I guess you should dive into JNI compiling Harfbuzz/Freetype and may Cairo for rendering glyph outlines if there is not any other way for it. Have a look at some HarfBuzz examples, you may be able to port it to your Android application. Depends on what you need other than configuring opentype features (layout, line wrapping) you may require compiling ICU4C or Pango and other libraries, but that would be very large dependency just for a mobile app of-course.

Post a Comment for "Use Opentype Font Features In Android"