我目前正在使用从 TTF 文件加载的外部(非标准)字体在 Canvas 上绘制文本。我想为我正在显示的文本启用字距调整。
我想知道是否有可能使用 Android API 从字体中读取字距对。
我想知道是否有可能使用 Android API 从字体中读取字距对。
没有公共 API 可以从 TTF 文件中读取字距调整对。不过,我从以下位置提取了相关代码阿帕奇FOP您可以使用以下命令读取字偶距对这个图书馆.
用法示例:
TTFFile file = TTFFile.open(getAssets().open("fonts/font.ttf"));
Map<Integer, Map<Integer, Integer>> kerning = file.getKerning();
您还可以检索其他元数据。例子:
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(); // 400
String copyright = ttfFile.getCopyrightNotice(); // "Font data copyright Google 2014"
我想为我正在显示的文本启用字距调整。
See:
如何调整 Android TextView 中的文本字距?
设置字母间距(浮动)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)