I am currently drawing text on Canvas while using external (non-standard) font, loaded from TTF file. I want to enable kerning for the text I am displaying.What I want to know is if there is a possibility to read kerning pairs from typeface using Android API. 解决方案 There is no public API to read kerning pairs from a TTF file. However, I pulled the relevant code from Apache FOP and you can read the kerning pairs using this library.Example usage:TTFFile file = TTFFile.open(getAssets().open("fonts/font.ttf"));Map<Integer, Map<Integer, Integer>> kerning = file.getKerning();You can also retrieve other metadata. Example:TTFFile ttfFile = TTFFile.open(new File("/system/fonts/Roboto-Regular.ttf"));String name = ttfFile.getFullName(); // "Roboto Regular"String family = ttfFile.getSubFamilyName(); // "Regular"int fontWeight = ttfFile.getWeightClass(); // 400String copyright = ttfFile.getCopyrightNotice(); // "Font data copyright Google 2014"See:How to adjust text kerning in Android TextView?setLetterSpacing(float) 这篇关于如何从Android中的TTF文件读取字距调整对表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-23 08:21