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

    Fields
    Modifier and Type
    Field
    Description
    protected int[][]
     
    boolean
    默认为非空,如果解析到cmap表为空,则设置为true
    protected boolean
     
    protected com.itextpdf.io.util.IntHashtable
    The 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

    Constructors
    Modifier
    Constructor
    Description
    protected
     
     
    ItextTrueTypeFont(byte[] ttf)
     
     
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    Map<Integer,int[]>
     
    Gets the code pages supported by the font.
    int
    The offset from the start of the file to the table directory.
    byte[]
     
    com.itextpdf.io.font.otf.OpenTypeGdefTableReader
     
    com.itextpdf.io.font.otf.GlyphPositioningTableReader
     
    com.itextpdf.io.font.otf.GlyphSubstitutionTableReader
     
    int
    getKerning(com.itextpdf.io.font.otf.Glyph first, com.itextpdf.io.font.otf.Glyph second)
    Gets the kerning between two glyphs.
    int
     
    byte[]
    getSubset(Set<Integer> glyphs, boolean subset)
     
    boolean
     
    boolean
    isBuiltWith(String fontProgram)
     
    boolean
     
    protected void
     
    protected void
     
    protected void
     
    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.

    Methods inherited from class com.itextpdf.io.font.TrueTypeFont

    mapGlyphsCidsToGids

    Methods 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

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • isEmptyCmap

      public boolean isEmptyCmap
      默认为非空,如果解析到cmap表为空,则设置为true
    • bBoxes

      protected int[][] bBoxes
    • isVertical

      protected boolean isVertical
    • kerning

      protected com.itextpdf.io.util.IntHashtable kerning
      The map containing the kerning information. It represents the content of table 'kern'. The key is an 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.
  • Constructor Details

  • Method Details

    • hasKernPairs

      public boolean hasKernPairs()
      Overrides:
      hasKernPairs in class com.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:
      getKerning in class com.itextpdf.io.font.TrueTypeFont
      Parameters:
      first - the first glyph
      second - the second glyph
      Returns:
      the kerning to be applied
    • isCff

      public boolean isCff()
      Overrides:
      isCff in class com.itextpdf.io.font.TrueTypeFont
    • getActiveCmap

      public Map<Integer,int[]> getActiveCmap()
      Overrides:
      getActiveCmap in class com.itextpdf.io.font.TrueTypeFont
    • getFontStreamBytes

      public byte[] getFontStreamBytes()
      Overrides:
      getFontStreamBytes in class com.itextpdf.io.font.TrueTypeFont
    • getPdfFontFlags

      public int getPdfFontFlags()
      Overrides:
      getPdfFontFlags in class com.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:
      getDirectoryOffset in class com.itextpdf.io.font.TrueTypeFont
      Returns:
      directory Offset
    • getGsubTable

      public com.itextpdf.io.font.otf.GlyphSubstitutionTableReader getGsubTable()
      Overrides:
      getGsubTable in class com.itextpdf.io.font.TrueTypeFont
    • getGposTable

      public com.itextpdf.io.font.otf.GlyphPositioningTableReader getGposTable()
      Overrides:
      getGposTable in class com.itextpdf.io.font.TrueTypeFont
    • getGdefTable

      public com.itextpdf.io.font.otf.OpenTypeGdefTableReader getGdefTable()
      Overrides:
      getGdefTable in class com.itextpdf.io.font.TrueTypeFont
    • getSubset

      public byte[] getSubset(Set<Integer> glyphs, boolean subset)
      Overrides:
      getSubset in class com.itextpdf.io.font.TrueTypeFont
    • readGdefTable

      protected void readGdefTable() throws IOException
      Overrides:
      readGdefTable in class com.itextpdf.io.font.TrueTypeFont
      Throws:
      IOException
    • readGsubTable

      protected void readGsubTable() throws IOException
      Overrides:
      readGsubTable in class com.itextpdf.io.font.TrueTypeFont
      Throws:
      IOException
    • readGposTable

      protected void readGposTable() throws IOException
      Overrides:
      readGposTable in class com.itextpdf.io.font.TrueTypeFont
      Throws:
      IOException
    • getCodePagesSupported

      public String[] getCodePagesSupported()
      Gets the code pages supported by the font.
      Overrides:
      getCodePagesSupported in class com.itextpdf.io.font.TrueTypeFont
      Returns:
      the code pages supported by the font
    • isBuiltWith

      public boolean isBuiltWith(String fontProgram)
      Overrides:
      isBuiltWith in class com.itextpdf.io.font.TrueTypeFont
    • close

      public void close() throws IOException
      Overrides:
      close in class com.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:
      updateUsedGlyphs in class com.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 status
      subsetRanges - additional subset ranges