Class TrueTypeFont
java.lang.Object
org.ofdrw.converter.font.TrueTypeFont
- All Implemented Interfaces:
FontDrawPathProvider, GlyphDataProvider
TrueType 字体解析器
https://docs.microsoft.com/zh-cn/typography/opentype/spec/otff
CMAP见
https://docs.microsoft.com/zh-cn/typography/opentype/spec/cmap
- Since:
- 2021-09-28 21:05:09
- Author:
- 权观宇
-
Field Summary
FieldsModifier and TypeFieldDescription字体名称来资源有 name表 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription获取变换矩阵getGlyph(int gid) 通过字形的Index获取字形数据getPath(int gid) 通过字体索引号获取字形绘制路径getSubtable(int platformId, int platformEncodingId) 获取特定平台特定编码的字符映射子表org.apache.fontbox.ttf.CmapLookup获取Unicode到字形的映射表getUnicodeGlyph(int code) 通过Unicode获取字形数据parse(byte[] buf) 创建TTF字体解析器parse(InputStream in) 创建TTF字体解析器创建TTF字体解析器parse(TTFDataStream raf) 解析字体readCMap(long cmapOffset, TTFDataStream data) 解析cmap
-
Field Details
-
fontFamily
字体名称来资源有 name表 -
fontSubFamily
-
psName
-
-
Constructor Details
-
TrueTypeFont
public TrueTypeFont()
-
-
Method Details
-
parse
创建TTF字体解析器- Parameters:
in- 流- Returns:
- this
- Throws:
IOException- IOE
-
parse
创建TTF字体解析器- Parameters:
buf- 读取到内存的字体数据- Returns:
- this
- Throws:
IOException- IOE
-
parse
创建TTF字体解析器- Parameters:
inPath- 字体文件路径- Returns:
- this
- Throws:
IOException- IOE
-
parse
解析字体- Parameters:
raf- 随机读取字体- Returns:
- this
- Throws:
IOException- IOE
-
getGlyph
通过字形的Index获取字形数据- Specified by:
getGlyphin interfaceGlyphDataProvider- Parameters:
gid- 字形Index- Returns:
- 字形数据
- Throws:
IOException- IOE
-
getPath
通过字体索引号获取字形绘制路径- Specified by:
getPathin interfaceFontDrawPathProvider- Parameters:
gid- 字形索引号- Returns:
- 字形路径或null
- Throws:
IOException- 字体解析异常
-
readCMap
解析cmap- Parameters:
cmapOffset- cmap开始偏移量data- 随机访问流- Returns:
- cmap子表数组
- Throws:
IOException- IOE
-
getSubtable
获取特定平台特定编码的字符映射子表Returns the subtable, if any, for the given platform and encoding.
- Parameters:
platformId- 平台IDplatformEncodingId- 平台编码ID- Returns:
- 映射子表
-
getUnicodeCmapLookup
public org.apache.fontbox.ttf.CmapLookup getUnicodeCmapLookup()获取Unicode到字形的映射表- Returns:
- 映射表
- Throws:
IllegalArgumentException- 字体没有cmap表
-
getUnicodeGlyph
通过Unicode获取字形数据如果没有cmap那么返回空白字符
- Parameters:
code- unicode- Returns:
- 字符数据
- Throws:
IOException- 字体文件解析异常
-
getFontMatrix
-