public class ItextTrueTypeFont
extends com.itextpdf.io.font.TrueTypeFont
由于 TrueTypeFont(OpenTypeParser fontParser) 构造器私有无法扩展自定义字体解析器,因此采用重载重新部分功能。 源码来自于Itext 7.1.13 的TrueTypeFont类 使用类ItextOpenTypeParser替换了类OpenTypeParser
| Modifier and Type | Field and Description |
|---|---|
protected int[][] |
bBoxes |
boolean |
isEmptyCmap
默认为非空,如果解析到cmap表为空,则设置为true
|
protected boolean |
isVertical |
protected com.itextpdf.io.util.IntHashtable |
kerning
The map containing the kerning information.
|
| Modifier | Constructor and Description |
|---|---|
protected |
ItextTrueTypeFont() |
|
ItextTrueTypeFont(byte[] ttf) |
|
ItextTrueTypeFont(String path) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
Map<Integer,int[]> |
getActiveCmap() |
String[] |
getCodePagesSupported()
Gets the code pages supported by the font.
|
int |
getDirectoryOffset()
The offset from the start of the file to the table directory.
|
byte[] |
getFontStreamBytes() |
com.itextpdf.io.font.otf.OpenTypeGdefTableReader |
getGdefTable() |
com.itextpdf.io.font.otf.GlyphPositioningTableReader |
getGposTable() |
com.itextpdf.io.font.otf.GlyphSubstitutionTableReader |
getGsubTable() |
int |
getKerning(com.itextpdf.io.font.otf.Glyph first,
com.itextpdf.io.font.otf.Glyph second)
Gets the kerning between two glyphs.
|
int |
getPdfFontFlags() |
byte[] |
getSubset(Set<Integer> glyphs,
boolean subset) |
boolean |
hasKernPairs() |
boolean |
isBuiltWith(String fontProgram) |
boolean |
isCff() |
protected void |
readGdefTable() |
protected void |
readGposTable() |
protected void |
readGsubTable() |
void |
updateUsedGlyphs(SortedSet<Integer> usedGlyphs,
boolean subset,
List<int[]> subsetRanges)
The method will update usedGlyphs with additional range or with all glyphs if there is no subset.
|
countOfGlyphs, fixSpaceIssue, getAvgWidth, getCharBBox, getFontIdentification, getFontMetrics, getFontNames, getGlyph, getGlyphByCode, getKerning, getRegistry, getWidth, isFontSpecific, setBbox, setBold, setCapHeight, setFixedPitch, setFontFamily, setFontName, setFontStretch, setFontWeight, setItalicAngle, setRegistry, setStemH, setStemV, setTypoAscender, setTypoDescender, setXHeight, toStringpublic boolean isEmptyCmap
protected int[][] bBoxes
protected boolean isVertical
protected com.itextpdf.io.util.IntHashtable kerning
Integer where the top 16 bits are the glyph number for the first character and the lower 16 bits are
the glyph number for the second character. The value is the amount of kerning in normalized 1000 units as an
Integer. This value is usually negative.protected ItextTrueTypeFont()
public ItextTrueTypeFont(String path) throws IOException
IOExceptionpublic ItextTrueTypeFont(byte[] ttf)
throws IOException
IOExceptionpublic boolean hasKernPairs()
hasKernPairs in class com.itextpdf.io.font.TrueTypeFontpublic int getKerning(com.itextpdf.io.font.otf.Glyph first,
com.itextpdf.io.font.otf.Glyph second)
getKerning in class com.itextpdf.io.font.TrueTypeFontfirst - the first glyphsecond - the second glyphpublic boolean isCff()
isCff in class com.itextpdf.io.font.TrueTypeFontpublic Map<Integer,int[]> getActiveCmap()
getActiveCmap in class com.itextpdf.io.font.TrueTypeFontpublic byte[] getFontStreamBytes()
getFontStreamBytes in class com.itextpdf.io.font.TrueTypeFontpublic int getPdfFontFlags()
getPdfFontFlags in class com.itextpdf.io.font.TrueTypeFontpublic int getDirectoryOffset()
getDirectoryOffset in class com.itextpdf.io.font.TrueTypeFontpublic com.itextpdf.io.font.otf.GlyphSubstitutionTableReader getGsubTable()
getGsubTable in class com.itextpdf.io.font.TrueTypeFontpublic com.itextpdf.io.font.otf.GlyphPositioningTableReader getGposTable()
getGposTable in class com.itextpdf.io.font.TrueTypeFontpublic com.itextpdf.io.font.otf.OpenTypeGdefTableReader getGdefTable()
getGdefTable in class com.itextpdf.io.font.TrueTypeFontpublic byte[] getSubset(Set<Integer> glyphs, boolean subset)
getSubset in class com.itextpdf.io.font.TrueTypeFontprotected void readGdefTable()
throws IOException
readGdefTable in class com.itextpdf.io.font.TrueTypeFontIOExceptionprotected void readGsubTable()
throws IOException
readGsubTable in class com.itextpdf.io.font.TrueTypeFontIOExceptionprotected void readGposTable()
throws IOException
readGposTable in class com.itextpdf.io.font.TrueTypeFontIOExceptionpublic String[] getCodePagesSupported()
getCodePagesSupported in class com.itextpdf.io.font.TrueTypeFontpublic boolean isBuiltWith(String fontProgram)
isBuiltWith in class com.itextpdf.io.font.TrueTypeFontpublic void close()
throws IOException
close in class com.itextpdf.io.font.TrueTypeFontIOExceptionpublic void updateUsedGlyphs(SortedSet<Integer> usedGlyphs, boolean subset, List<int[]> subsetRanges)
updateUsedGlyphs in class com.itextpdf.io.font.TrueTypeFontusedGlyphs - a set of integers, which are glyph ids that denote used glyphs. This set is updated inside of
the method if needed.subset - subset statussubsetRanges - additional subset rangesCopyright © 2026. All rights reserved.