iText 9.5.0 API
iText.IO.Font.TrueTypeFont Class Reference
Inheritance diagram for iText.IO.Font.TrueTypeFont:
iText.IO.Font.FontProgram iText.Kernel.Font.DocTrueTypeFont

Public Member Functions

  TrueTypeFont (String path)
 
  TrueTypeFont (byte[] ttf)
 
  TrueTypeFont (byte[] ttf, bool isLenientMode)
 
override bool  HasKernPairs ()
 
override int  GetKerning (Glyph first, Glyph second)
  Gets the kerning between two glyphs. More...
 
virtual bool  IsCff ()
 
virtual IDictionary< int, int[]>  GetActiveCmap ()
 
virtual byte[]  GetFontStreamBytes ()
 
override int  GetPdfFontFlags ()
 
virtual int  GetDirectoryOffset ()
  The offset from the start of the file to the table directory. More...
 
virtual GlyphSubstitutionTableReader  GetGsubTable ()
 
virtual GlyphPositioningTableReader  GetGposTable ()
 
virtual OpenTypeGdefTableReader  GetGdefTable ()
 
virtual byte[]  GetSubset (ICollection< int > glyphs, bool subsetTables)
  Gets subset based on the passed glyphs. More...
 
virtual Tuple2< int, byte[]>  Subset (ICollection< int > glyphs, bool subsetTables)
  Gets subset and a number of glyphs in it based on the passed glyphs. More...
 
virtual ICollection< int >  MapGlyphsCidsToGids (ICollection< int > glyphs)
  Maps a set of glyph CIDs (as used in PDF file) to corresponding GID values (as a glyph primary identifier in the font file). More...
 
virtual bool  IsCmapPresent (int platformID, int encodingID)
  Checks whether current TrueTypeFont program contains the “cmap” subtable with provided platform ID and encoding ID. More...
 
virtual int  GetNumberOfCmaps ()
  Gets the number of the “cmap” subtables for the current TrueTypeFont program. More...
 
virtual String[]  GetCodePagesSupported ()
  Gets the code pages supported by the font. More...
 
override bool  IsBuiltWith (String fontProgram)
  Checks whether the FontProgram was built with corresponding fontName. More...
 
virtual void  Close ()
 
virtual void  UpdateUsedGlyphs (SortedSet< int > usedGlyphs, bool subset, IList< int[]> subsetRanges)
  The method will update usedGlyphs with additional range or with all glyphs if there is no subset. More...
 
virtual void  UpdateUsedGlyphs (IDictionary< int, Glyph > usedGlyphs, bool subset, IList< int[]> subsetRanges)
  The method will update usedGlyphs with additional range or with all glyphs if there is no subset. More...
 
- Public Member Functions inherited from iText.IO.Font.FontProgram
virtual int  CountOfGlyphs ()
 
virtual FontNames  GetFontNames ()
 
virtual FontMetrics  GetFontMetrics ()
 
virtual FontIdentification  GetFontIdentification ()
 
virtual String  GetRegistry ()
 
virtual bool  IsFontSpecific ()
 
virtual int  GetWidth (int unicode)
  Get glyph's width. More...
 
virtual int  GetAvgWidth ()
 
virtual int[]  GetCharBBox (int unicode)
  Get glyph's bbox. More...
 
virtual Glyph  GetGlyph (int unicode)
 
virtual Glyph  GetGlyphByCode (int charCode)
 
virtual int  GetKerning (int first, int second)
  Gets the kerning between two glyphs. More...
 
override String  ToString ()
 

Static Public Member Functions

static byte[]  Merge (IDictionary< iText.IO.Font.TrueTypeFont, ICollection< int >> toMerge, String fontName)
  Merges the passed font into one. More...
 
static byte[]  Merge (IDictionary< iText.IO.Font.TrueTypeFont, ICollection< int >> toMerge, String fontName, bool isCmapCheckRequired)
  Merges the passed font into one. More...
 
- Static Public Member Functions inherited from iText.IO.Font.FontProgram
static float  ConvertTextSpaceToGlyphSpace (float value)
 
static float  ConvertGlyphSpaceToTextSpace (float value)
 
static double  ConvertGlyphSpaceToTextSpace (double value)
 
static int  ConvertGlyphSpaceToTextSpace (int value)
 

Package Functions

virtual void  ReadGdefTable ()
 
virtual void  ReadGsubTable ()
 
virtual void  ReadGposTable ()
 
- Package Functions inherited from iText.IO.Font.FontProgram
virtual void  SetRegistry (String registry)
 
virtual void  SetTypoAscender (int ascender)
  Sets typo ascender. More...
 
virtual void  SetTypoDescender (int descender)
  Sets typo descender. More...
 
virtual void  SetCapHeight (int capHeight)
  Sets the capital letters height. More...
 
virtual void  SetXHeight (int xHeight)
 
virtual void  SetItalicAngle (int italicAngle)
  Sets the PostScript italic angle. More...
 
virtual void  SetStemV (int stemV)
 
virtual void  SetStemH (int stemH)
 
virtual void  SetFontWeight (int fontWeight)
  Sets font weight. More...
 
virtual void  SetFontStretch (String fontWidth)
  Sets font width in css notation (font-stretch property) More...
 
virtual void  SetFixedPitch (bool isFixedPitch)
 
virtual void  SetBold (bool isBold)
 
virtual void  SetBbox (int[] bbox)
 
virtual void  SetFontFamily (String fontFamily)
  Sets a preferred font family name. More...
 
virtual void  SetFontName (String fontName)
  Sets the PostScript name of the font. More...
 
virtual void  FixSpaceIssue ()
 

Package Attributes

int[][]  bBoxes
 
bool  isVertical
 
IntHashtable  kerning = new IntHashtable()
  The map containing the kerning information. More...
 
- Package Attributes inherited from iText.IO.Font.FontProgram
IDictionary< int, Glyph codeToGlyph = new DictionaryGlyph>()
 
IDictionary< int, Glyph unicodeToGlyph = new DictionaryGlyph>()
 
bool  isFontSpecific
 
FontNames  fontNames
 
FontMetrics  fontMetrics = new FontMetrics()
 
FontIdentification  fontIdentification = new FontIdentification()
 
int  avgWidth
 
String  encodingScheme = FontEncoding.FONT_SPECIFIC
  The font's encoding name. More...
 
String  registry
 

Additional Inherited Members

- Static Public Attributes inherited from iText.IO.Font.FontProgram
const int  HORIZONTAL_SCALING_FACTOR = 100
 
const int  DEFAULT_WIDTH = 1000
 
const int  UNITS_NORMALIZATION = 1000
 

Member Function Documentation

◆ GetCodePagesSupported()

virtual String [] iText.IO.Font.TrueTypeFont.GetCodePagesSupported ( )
inlinevirtual

Gets the code pages supported by the font.

Returns
the code pages supported by the font

◆ GetDirectoryOffset()

virtual int iText.IO.Font.TrueTypeFont.GetDirectoryOffset ( )
inlinevirtual

The offset from the start of the file to the table directory.

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.

Returns
directory Offset

◆ GetKerning()

override int iText.IO.Font.TrueTypeFont.GetKerning ( Glyph  first,
Glyph  second 
)
inlinevirtual

Gets the kerning between two glyphs.

Parameters
first the first glyph
second the second glyph
Returns
the kerning to be applied

Implements iText.IO.Font.FontProgram.

◆ GetNumberOfCmaps()

virtual int iText.IO.Font.TrueTypeFont.GetNumberOfCmaps ( )
inlinevirtual

Gets the number of the “cmap” subtables for the current TrueTypeFont program.

Returns
the number of the “cmap” subtables

◆ GetSubset()

virtual byte [] iText.IO.Font.TrueTypeFont.GetSubset ( ICollection< int >  glyphs,
bool  subsetTables 
)
inlinevirtual

Gets subset based on the passed glyphs.

Parameters
glyphs the glyphs to subset the font
subsetTables whether subset tables (remove name and post tables) or not. It's used in case of ttc (true type collection) font where single "full" font is needed. Despite the value of that flag, only used glyphs will be left in the font
Returns
the subset font

◆ IsBuiltWith()

override bool iText.IO.Font.TrueTypeFont.IsBuiltWith ( String  fontName )
inlinevirtual

Checks whether the FontProgram was built with corresponding fontName.

Checks whether the FontProgram was built with corresponding fontName. Default value is false unless overridden.

Parameters
fontName a font name or path to a font program
Returns
true, if the FontProgram was built with the fontProgram. Otherwise false.

Reimplemented from iText.IO.Font.FontProgram.

Reimplemented in iText.Kernel.Font.DocTrueTypeFont.

◆ IsCmapPresent()

virtual bool iText.IO.Font.TrueTypeFont.IsCmapPresent ( int  platformID,
int  encodingID 
)
inlinevirtual

Checks whether current TrueTypeFont program contains the “cmap” subtable with provided platform ID and encoding ID.

Parameters
platformID platform ID
encodingID encoding ID
Returns

true if “cmap” subtable with provided platform ID and encoding ID is present in the font program, false otherwise

◆ MapGlyphsCidsToGids()

virtual ICollection iText.IO.Font.TrueTypeFont.MapGlyphsCidsToGids ( ICollection< int >  glyphs )
inlinevirtual

Maps a set of glyph CIDs (as used in PDF file) to corresponding GID values (as a glyph primary identifier in the font file).

Maps a set of glyph CIDs (as used in PDF file) to corresponding GID values (as a glyph primary identifier in the font file). This call is only meaningful for fonts that return true for IsCff(). For other types of fonts, GID and CID are always the same, so that call would essentially return a set of the same values.

Parameters
glyphs a set of glyph CIDs
Returns
a set of glyph ids corresponding to the passed glyph CIDs

◆ Merge() [1/2]

static byte [] iText.IO.Font.TrueTypeFont.Merge ( IDictionary< iText.IO.Font.TrueTypeFont, ICollection< int >>  toMerge,
String  fontName 
)
inlinestatic

Merges the passed font into one.

Merges the passed font into one. Used glyphs per each font are applied to subset the merged font.

Parameters
toMerge the fonts to merge with used glyphs per each font
fontName the name of fonts to merge
Returns
the raw data of merged font

◆ Merge() [2/2]

static byte [] iText.IO.Font.TrueTypeFont.Merge ( IDictionary< iText.IO.Font.TrueTypeFont, ICollection< int >>  toMerge,
String  fontName,
bool  isCmapCheckRequired 
)
inlinestatic

Merges the passed font into one.

Merges the passed font into one. Used glyphs per each font are applied to subset the merged font.

Parameters
toMerge the fonts to merge with used glyphs per each font
fontName the name of fonts to merge
isCmapCheckRequired the flag which specifies whether 'cmap' table should be checked while merging or not
Returns
the raw data of merged font

◆ Subset()

virtual Tuple2 iText.IO.Font.TrueTypeFont.Subset ( ICollection< int >  glyphs,
bool  subsetTables 
)
inlinevirtual

Gets subset and a number of glyphs in it based on the passed glyphs.

Gets subset and a number of glyphs in it based on the passed glyphs.

The number of glyphs in a subset is not just glyphs.size() here. It's the biggest glyph id + 1 (for glyph 0). It also may include possible composite glyphs.

Parameters
glyphs the glyphs to subset the font
subsetTables whether subset tables (remove name and post tables) or not. It's used in case of ttc (true type collection) font where single "full" font is needed. Despite the value of that flag, only used glyphs will be left in the font
Returns
the subset of the font and the number of glyphs in it

◆ UpdateUsedGlyphs() [1/2]

virtual void iText.IO.Font.TrueTypeFont.UpdateUsedGlyphs ( IDictionary< int, Glyph usedGlyphs,
bool  subset,
IList< int[]>  subsetRanges 
)
inlinevirtual

The method will update usedGlyphs with additional range or with all glyphs if there is no subset.

The method will update usedGlyphs with additional range or with all glyphs if there is no subset. This map of used glyphs can be used for building width array and ToUnicode CMAP.

Parameters
usedGlyphs a map of glyph ids to glyphs. This map is updated inside the method if needed
subset subset status
subsetRanges additional subset ranges

◆ UpdateUsedGlyphs() [2/2]

virtual void iText.IO.Font.TrueTypeFont.UpdateUsedGlyphs ( SortedSet< int >  usedGlyphs,
bool  subset,
IList< int[]>  subsetRanges 
)
inlinevirtual

The method will update usedGlyphs with additional range or with all glyphs if there is no subset.

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.

Parameters
usedGlyphs a set of integers, which are glyph ids that denote used glyphs. This set is updated inside the method if needed.
subset subset status
subsetRanges additional subset ranges

Member Data Documentation

◆ kerning

IntHashtable iText.IO.Font.TrueTypeFont.kerning = new IntHashtable()
package

The map containing the kerning information.

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.