Class ItextTrueTypeFont
java.lang.Object
com.itextpdf.io.font.FontProgram
com.itextpdf.io.font.TrueTypeFont
com.itextpdf.io.font.ItextTrueTypeFont
public class ItextTrueTypeFont
extends com.itextpdf.io.font.TrueTypeFont
iText TrueType字体解析器
由于 TrueTypeFont(OpenTypeParser fontParser) 构造器私有无法扩展自定义字体解析器,因此采用重载重新部分功能。 源码来自于Itext 7.1.13 的TrueTypeFont类 使用类ItextOpenTypeParser替换了类OpenTypeParser
- Since:
- 2024-3-21 18:36:35
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int[][]boolean默认为非空,如果解析到cmap表为空,则设置为trueprotected booleanprotected com.itextpdf.io.util.IntHashtableThe map containing the kerning information.Fields inherited from class com.itextpdf.io.font.FontProgram
avgWidth, codeToGlyph, DEFAULT_WIDTH, encodingScheme, fontIdentification, fontMetrics, fontNames, isFontSpecific, registry, unicodeToGlyph, UNITS_NORMALIZATION -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedItextTrueTypeFont(byte[] ttf) ItextTrueTypeFont(String path) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()String[]Gets the code pages supported by the font.intThe offset from the start of the file to the table directory.byte[]com.itextpdf.io.font.otf.OpenTypeGdefTableReadercom.itextpdf.io.font.otf.GlyphPositioningTableReadercom.itextpdf.io.font.otf.GlyphSubstitutionTableReaderintgetKerning(com.itextpdf.io.font.otf.Glyph first, com.itextpdf.io.font.otf.Glyph second) Gets the kerning between two glyphs.intbyte[]booleanbooleanisBuiltWith(String fontProgram) booleanisCff()protected voidprotected voidprotected voidvoidupdateUsedGlyphs(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.Methods inherited from class com.itextpdf.io.font.TrueTypeFont
mapGlyphsCidsToGidsMethods inherited from class com.itextpdf.io.font.FontProgram
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, toString
-
Field Details
-
isEmptyCmap
public boolean isEmptyCmap默认为非空,如果解析到cmap表为空,则设置为true -
bBoxes
protected int[][] bBoxes -
isVertical
protected boolean isVertical -
kerning
protected com.itextpdf.io.util.IntHashtable kerningThe map containing the kerning information. It represents the content of table 'kern'. The key is anIntegerwhere 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 anInteger. This value is usually negative.
-
-
Constructor Details
-
ItextTrueTypeFont
protected ItextTrueTypeFont() -
ItextTrueTypeFont
- Throws:
IOException
-
ItextTrueTypeFont
- Throws:
IOException
-
-
Method Details
-
hasKernPairs
public boolean hasKernPairs()- Overrides:
hasKernPairsin classcom.itextpdf.io.font.TrueTypeFont
-
getKerning
public int getKerning(com.itextpdf.io.font.otf.Glyph first, com.itextpdf.io.font.otf.Glyph second) Gets the kerning between two glyphs.- Overrides:
getKerningin classcom.itextpdf.io.font.TrueTypeFont- Parameters:
first- the first glyphsecond- the second glyph- Returns:
- the kerning to be applied
-
isCff
public boolean isCff()- Overrides:
isCffin classcom.itextpdf.io.font.TrueTypeFont
-
getActiveCmap
-
getFontStreamBytes
public byte[] getFontStreamBytes()- Overrides:
getFontStreamBytesin classcom.itextpdf.io.font.TrueTypeFont
-
getPdfFontFlags
public int getPdfFontFlags()- Overrides:
getPdfFontFlagsin classcom.itextpdf.io.font.TrueTypeFont
-
getDirectoryOffset
public int getDirectoryOffset()The offset from the start of the file to the table directory. It is 0 for TTF and may vary for TTC depending on the chosen font.- Overrides:
getDirectoryOffsetin classcom.itextpdf.io.font.TrueTypeFont- Returns:
- directory Offset
-
getGsubTable
public com.itextpdf.io.font.otf.GlyphSubstitutionTableReader getGsubTable()- Overrides:
getGsubTablein classcom.itextpdf.io.font.TrueTypeFont
-
getGposTable
public com.itextpdf.io.font.otf.GlyphPositioningTableReader getGposTable()- Overrides:
getGposTablein classcom.itextpdf.io.font.TrueTypeFont
-
getGdefTable
public com.itextpdf.io.font.otf.OpenTypeGdefTableReader getGdefTable()- Overrides:
getGdefTablein classcom.itextpdf.io.font.TrueTypeFont
-
getSubset
-
readGdefTable
- Overrides:
readGdefTablein classcom.itextpdf.io.font.TrueTypeFont- Throws:
IOException
-
readGsubTable
- Overrides:
readGsubTablein classcom.itextpdf.io.font.TrueTypeFont- Throws:
IOException
-
readGposTable
- Overrides:
readGposTablein classcom.itextpdf.io.font.TrueTypeFont- Throws:
IOException
-
getCodePagesSupported
Gets the code pages supported by the font.- Overrides:
getCodePagesSupportedin classcom.itextpdf.io.font.TrueTypeFont- Returns:
- the code pages supported by the font
-
isBuiltWith
- Overrides:
isBuiltWithin classcom.itextpdf.io.font.TrueTypeFont
-
close
- Overrides:
closein classcom.itextpdf.io.font.TrueTypeFont- Throws:
IOException
-
updateUsedGlyphs
public 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. This set of used glyphs can be used for building width array and ToUnicode CMAP.- Overrides:
updateUsedGlyphsin classcom.itextpdf.io.font.TrueTypeFont- Parameters:
usedGlyphs- 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 ranges
-