public class TrueTypeFont extends Object implements GlyphDataProvider, FontDrawPathProvider
https://docs.microsoft.com/zh-cn/typography/opentype/spec/otff
CMAP见
https://docs.microsoft.com/zh-cn/typography/opentype/spec/cmap
| 限定符和类型 | 字段和说明 |
|---|---|
String |
fontFamily
字体名称来资源有 name表
|
String |
fontSubFamily |
String |
psName |
| 构造器和说明 |
|---|
TrueTypeFont() |
| 限定符和类型 | 方法和说明 |
|---|---|
List<Number> |
getFontMatrix()
获取变换矩阵
|
GlyphData |
getGlyph(int gid)
通过字形的Index获取字形数据
|
GeneralPath |
getPath(int gid)
通过字体索引号获取字形绘制路径
|
CmapSubtable |
getSubtable(int platformId,
int platformEncodingId)
获取特定平台特定编码的字符映射子表
Returns the subtable, if any, for the given platform and encoding.
|
org.apache.fontbox.ttf.CmapLookup |
getUnicodeCmapLookup()
获取Unicode到字形的映射表
|
GlyphData |
getUnicodeGlyph(int code)
通过Unicode获取字形数据
如果没有cmap那么返回空白字符
|
TrueTypeFont |
parse(byte[] buf)
创建TTF字体解析器
|
TrueTypeFont |
parse(InputStream in)
创建TTF字体解析器
|
TrueTypeFont |
parse(Path inPath)
创建TTF字体解析器
|
TrueTypeFont |
parse(TTFDataStream raf)
解析字体
|
CmapSubtable[] |
readCMap(long cmapOffset,
TTFDataStream data)
解析cmap
|
public String fontFamily
public String fontSubFamily
public String psName
public TrueTypeFont parse(InputStream in) throws IOException
in - 流IOException - IOEpublic TrueTypeFont parse(byte[] buf) throws IOException
buf - 读取到内存的字体数据IOException - IOEpublic TrueTypeFont parse(Path inPath) throws IOException
inPath - 字体文件路径IOException - IOEpublic TrueTypeFont parse(TTFDataStream raf) throws IOException
raf - 随机读取字体IOException - IOEpublic GlyphData getGlyph(int gid) throws IOException
getGlyph 在接口中 GlyphDataProvidergid - 字形IndexIOException - IOEpublic GeneralPath getPath(int gid) throws IOException
getPath 在接口中 FontDrawPathProvidergid - 字形索引号IOException - 字体解析异常public CmapSubtable[] readCMap(long cmapOffset, TTFDataStream data) throws IOException
cmapOffset - cmap开始偏移量data - 随机访问流IOException - IOEpublic CmapSubtable getSubtable(int platformId, int platformEncodingId)
Returns the subtable, if any, for the given platform and encoding.
platformId - 平台IDplatformEncodingId - 平台编码IDpublic org.apache.fontbox.ttf.CmapLookup getUnicodeCmapLookup()
IllegalArgumentException - 字体没有cmap表public GlyphData getUnicodeGlyph(int code) throws IOException
如果没有cmap那么返回空白字符
code - unicodeIOException - 字体文件解析异常Copyright © 2024. All rights reserved.