iText 9.8.0 API
iText.IO.Font.FontProgram Class Referenceabstract

Base representation of a font program and its glyph, naming, and metric data. More...

Inheritance diagram for iText.IO.Font.FontProgram:
iText.IO.Font.CidFont iText.IO.Font.TrueTypeFont iText.IO.Font.Type1Font iText.Kernel.Font.Type3Font iText.Kernel.Font.DocTrueTypeFont

Public Member Functions

virtual int  CountOfGlyphs ()
  Gets the amount of glyphs in this font program. More...
 
virtual FontNames  GetFontNames ()
  Gets the parsed font naming data. More...
 
virtual FontMetrics  GetFontMetrics ()
  Gets the parsed font metric data. More...
 
virtual FontIdentification  GetFontIdentification ()
  Gets the parsed font identification data. More...
 
virtual String  GetRegistry ()
  Gets the CID registry name. More...
 
abstract int  GetPdfFontFlags ()
  Computes the PDF font descriptor flags for this program. More...
 
virtual bool  IsFontSpecific ()
  Checks whether this program uses its built-in character encoding. More...
 
virtual int  GetWidth (int unicode)
  Get glyph's width. More...
 
virtual int  GetAvgWidth ()
  Gets the average glyph width. More...
 
virtual int[]  GetCharBBox (int unicode)
  Get glyph's bbox. More...
 
virtual Glyph  GetGlyph (int unicode)
  Looks up a glyph by Unicode value. More...
 
virtual Glyph  GetGlyphByCode (int charCode)
  Looks up a glyph by its format-specific code. More...
 
virtual bool  HasKernPairs ()
  Checks whether this program supplies kerning pairs. More...
 
virtual int  GetKerning (int first, int second)
  Gets the kerning between two glyphs. More...
 
abstract int  GetKerning (Glyph first, Glyph second)
  Gets the kerning between two glyphs. More...
 
virtual bool  IsBuiltWith (String fontName)
  Checks whether the FontProgram was built with corresponding fontName. More...
 
override String  ToString ()
 

Static Public Member Functions

static float  ConvertTextSpaceToGlyphSpace (float value)
  Converts a PDF text-space value to normalized glyph space. More...
 
static float  ConvertGlyphSpaceToTextSpace (float value)
  Converts a normalized glyph-space value to PDF text space. More...
 
static double  ConvertGlyphSpaceToTextSpace (double value)
  Converts a normalized glyph-space value to PDF text space without losing double precision. More...
 
static int  ConvertGlyphSpaceToTextSpace (int value)
  Converts an integral normalized glyph-space value to PDF text space. More...
 

Static Public Attributes

const int  HORIZONTAL_SCALING_FACTOR = 100
 
const int  DEFAULT_WIDTH = 1000
 
const int  UNITS_NORMALIZATION = 1000
 

Package Functions

virtual void  SetRegistry (String registry)
  Sets the CID registry associated with this font program. More...
 
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)
  Sets the x-height in source font units. More...
 
virtual void  SetItalicAngle (int italicAngle)
  Sets the PostScript italic angle. More...
 
virtual void  SetStemV (int stemV)
  Sets the dominant vertical stem width. More...
 
virtual void  SetStemH (int stemH)
  Sets the dominant horizontal stem width. More...
 
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)
  Sets whether the font declares a fixed width. More...
 
virtual void  SetBold (bool isBold)
 
virtual void  SetBbox (int[] bbox)
  Sets the normalized font bounding box from a four-element coordinate array. More...
 
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 ()
  Ensures that an existing Unicode space glyph is also addressable through its font code. More...
 

Package Attributes

IDictionary< int, Glyph >  codeToGlyph = new DictionaryGlyph>()
 
IDictionary< int, Glyph >  unicodeToGlyph = new DictionaryGlyph>()
 
bool  isFontSpecific
  Indicates that character codes are interpreted using the font's built-in encoding rather than a Unicode-oriented encoding. More...
 
FontNames  fontNames
  Naming data extracted from the font program. More...
 
FontMetrics  fontMetrics = new FontMetrics()
  Metrics extracted from the font program. More...
 
FontIdentification  fontIdentification = new FontIdentification()
 
int  avgWidth
  Average glyph width in normalized glyph units. More...
 
String  encodingScheme = FontEncoding.FONT_SPECIFIC
  The font's encoding name. More...
 
String  registry
  CID registry name associated with this font, or null for fonts without a CID registry. More...
 

Detailed Description

Base representation of a font program and its glyph, naming, and metric data.

Base representation of a font program and its glyph, naming, and metric data.

Glyph metrics exposed by this abstraction use the normalized 1000-unit PDF glyph space.

Member Function Documentation

◆ ConvertGlyphSpaceToTextSpace() [1/3]

static double iText.IO.Font.FontProgram.ConvertGlyphSpaceToTextSpace ( double  value )
inlinestatic

Converts a normalized glyph-space value to PDF text space without losing double precision.

Parameters
value value in normalized glyph space
Returns
value multiplied by UNITS_NORMALIZATION

◆ ConvertGlyphSpaceToTextSpace() [2/3]

static float iText.IO.Font.FontProgram.ConvertGlyphSpaceToTextSpace ( float  value )
inlinestatic

Converts a normalized glyph-space value to PDF text space.

Parameters
value value in normalized glyph space
Returns
value multiplied by UNITS_NORMALIZATION

◆ ConvertGlyphSpaceToTextSpace() [3/3]

static int iText.IO.Font.FontProgram.ConvertGlyphSpaceToTextSpace ( int  value )
inlinestatic

Converts an integral normalized glyph-space value to PDF text space.

Parameters
value value in normalized glyph space
Returns
value multiplied by UNITS_NORMALIZATION

◆ ConvertTextSpaceToGlyphSpace()

static float iText.IO.Font.FontProgram.ConvertTextSpaceToGlyphSpace ( float  value )
inlinestatic

Converts a PDF text-space value to normalized glyph space.

Parameters
value value in text space
Returns
value divided by UNITS_NORMALIZATION

◆ CountOfGlyphs()

virtual int iText.IO.Font.FontProgram.CountOfGlyphs ( )
inlinevirtual

Gets the amount of glyphs in this font program.

Returns
the amount of glyphs in this font program

◆ FixSpaceIssue()

virtual void iText.IO.Font.FontProgram.FixSpaceIssue ( )
inlinepackagevirtual

Ensures that an existing Unicode space glyph is also addressable through its font code.

◆ GetAvgWidth()

virtual int iText.IO.Font.FontProgram.GetAvgWidth ( )
inlinevirtual

Gets the average glyph width.

Returns
average width in normalized glyph units

◆ GetCharBBox()

virtual int [] iText.IO.Font.FontProgram.GetCharBBox ( int  unicode )
inlinevirtual

Get glyph's bbox.

Parameters
unicode a unicode symbol or FontSpecif code.
Returns
Gets bbox in normalized 1000 units.

◆ GetFontIdentification()

virtual FontIdentification iText.IO.Font.FontProgram.GetFontIdentification ( )
inlinevirtual

Gets the parsed font identification data.

Returns
identification data owned by this program

◆ GetFontMetrics()

virtual FontMetrics iText.IO.Font.FontProgram.GetFontMetrics ( )
inlinevirtual

Gets the parsed font metric data.

Returns
metric data owned by this program

◆ GetFontNames()

virtual FontNames iText.IO.Font.FontProgram.GetFontNames ( )
inlinevirtual

Gets the parsed font naming data.

Returns
naming data owned by this program

◆ GetGlyph()

virtual Glyph iText.IO.Font.FontProgram.GetGlyph ( int  unicode )
inlinevirtual

Looks up a glyph by Unicode value.

Parameters
unicode Unicode scalar value
Returns
matching glyph, or null when unmapped

◆ GetGlyphByCode()

virtual Glyph iText.IO.Font.FontProgram.GetGlyphByCode ( int  charCode )
inlinevirtual

Looks up a glyph by its format-specific code.

Parameters
charCode Type 1 character code or OpenType glyph index
Returns
matching glyph, or null when absent

◆ GetKerning() [1/2]

abstract int iText.IO.Font.FontProgram.GetKerning ( Glyph  first,
Glyph  second 
)
pure virtual

Gets the kerning between two glyphs.

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

Implemented in iText.Kernel.Font.Type3Font, iText.IO.Font.CidFont, iText.IO.Font.Type1Font, and iText.IO.Font.TrueTypeFont.

◆ GetKerning() [2/2]

virtual int iText.IO.Font.FontProgram.GetKerning ( int  first,
int  second 
)
inlinevirtual

Gets the kerning between two glyphs.

Parameters
first the first unicode value
second the second unicode value
Returns
the kerning to be applied

◆ GetPdfFontFlags()

abstract int iText.IO.Font.FontProgram.GetPdfFontFlags ( )
pure virtual

Computes the PDF font descriptor flags for this program.

Returns
bit set defined by the PDF font descriptor specification

Implemented in iText.IO.Font.Type1Font, iText.IO.Font.TrueTypeFont, iText.Kernel.Font.Type3Font, and iText.IO.Font.CidFont.

◆ GetRegistry()

virtual String iText.IO.Font.FontProgram.GetRegistry ( )
inlinevirtual

Gets the CID registry name.

Returns
CID registry, or null when none was supplied

◆ GetWidth()

virtual int iText.IO.Font.FontProgram.GetWidth ( int  unicode )
inlinevirtual

Get glyph's width.

Parameters
unicode a unicode symbol or FontSpecif code.
Returns
Gets width in normalized 1000 units.

◆ HasKernPairs()

virtual bool iText.IO.Font.FontProgram.HasKernPairs ( )
inlinevirtual

Checks whether this program supplies kerning pairs.

Returns

true if supplies, false otherwise

Reimplemented in iText.IO.Font.Type1Font, and iText.IO.Font.TrueTypeFont.

◆ IsBuiltWith()

virtual bool iText.IO.Font.FontProgram.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 in iText.IO.Font.TrueTypeFont, iText.IO.Font.Type1Font, iText.Kernel.Font.DocTrueTypeFont, and iText.IO.Font.CidFont.

◆ IsFontSpecific()

virtual bool iText.IO.Font.FontProgram.IsFontSpecific ( )
inlinevirtual

Checks whether this program uses its built-in character encoding.

Returns

true when character codes are font-specific

Reimplemented in iText.Kernel.Font.Type3Font, and iText.IO.Font.CidFont.

◆ SetBbox()

virtual void iText.IO.Font.FontProgram.SetBbox ( int[]  bbox )
inlinepackagevirtual

Sets the normalized font bounding box from a four-element coordinate array.

Parameters
bbox lower-left x/y and upper-right x/y coordinates

◆ SetCapHeight()

virtual void iText.IO.Font.FontProgram.SetCapHeight ( int  capHeight )
inlinepackagevirtual

Sets the capital letters height.

Sets the capital letters height. See also FontMetrics.SetCapHeight(int).

Parameters
capHeight cap height in 1000-units

Reimplemented in iText.Kernel.Font.Type3Font.

◆ SetFixedPitch()

virtual void iText.IO.Font.FontProgram.SetFixedPitch ( bool  isFixedPitch )
inlinepackagevirtual

Sets whether the font declares a fixed width.

Parameters
isFixedPitch

true for a monospaced font

◆ SetFontFamily()

virtual void iText.IO.Font.FontProgram.SetFontFamily ( String  fontFamily )
inlinepackagevirtual

Sets a preferred font family name.

Parameters
fontFamily a preferred font family name.

Reimplemented in iText.Kernel.Font.Type3Font.

◆ SetFontName()

virtual void iText.IO.Font.FontProgram.SetFontName ( String  fontName )
inlinepackagevirtual

Sets the PostScript name of the font.

Sets the PostScript name of the font.

If full name is null, it will be set as well.

Parameters
fontName the PostScript name of the font, shall not be null or empty.

Reimplemented in iText.Kernel.Font.Type3Font.

◆ SetFontStretch()

virtual void iText.IO.Font.FontProgram.SetFontStretch ( String  fontWidth )
inlinepackagevirtual

Sets font width in css notation (font-stretch property)

Parameters
fontWidth

iText.IO.Font.Constants.FontStretches.

Reimplemented in iText.Kernel.Font.Type3Font.

◆ SetFontWeight()

virtual void iText.IO.Font.FontProgram.SetFontWeight ( int  fontWeight )
inlinepackagevirtual

Sets font weight.

Parameters
fontWeight integer form 100 to 900. See iText.IO.Font.Constants.FontWeights.

Reimplemented in iText.Kernel.Font.Type3Font.

◆ SetItalicAngle()

virtual void iText.IO.Font.FontProgram.SetItalicAngle ( int  italicAngle )
inlinepackagevirtual

Sets the PostScript italic angle.

Sets the PostScript italic angle.

Italic angle in counterclockwise degrees from the vertical. Zero for upright text, negative for text that leans to the right (forward).

Parameters
italicAngle in counterclockwise degrees from the vertical

Reimplemented in iText.Kernel.Font.Type3Font.

◆ SetRegistry()

virtual void iText.IO.Font.FontProgram.SetRegistry ( String  registry )
inlinepackagevirtual

Sets the CID registry associated with this font program.

Parameters
registry CID registry name, or null when unavailable

◆ SetStemH()

virtual void iText.IO.Font.FontProgram.SetStemH ( int  stemH )
inlinepackagevirtual

Sets the dominant horizontal stem width.

Parameters
stemH Type 1/CFF StdHW value in glyph units

◆ SetStemV()

virtual void iText.IO.Font.FontProgram.SetStemV ( int  stemV )
inlinepackagevirtual

Sets the dominant vertical stem width.

Parameters
stemV Type 1/CFF StdVW value in glyph units

◆ SetTypoAscender()

virtual void iText.IO.Font.FontProgram.SetTypoAscender ( int  ascender )
inlinepackagevirtual

Sets typo ascender.

Sets typo ascender. See also FontMetrics.SetTypoAscender(int).

Parameters
ascender typo ascender value in 1000-units

Reimplemented in iText.Kernel.Font.Type3Font.

◆ SetTypoDescender()

virtual void iText.IO.Font.FontProgram.SetTypoDescender ( int  descender )
inlinepackagevirtual

Sets typo descender.

Sets typo descender. See also FontMetrics.SetTypoDescender(int).

Parameters
descender typo descender value in 1000-units

Reimplemented in iText.Kernel.Font.Type3Font.

◆ SetXHeight()

virtual void iText.IO.Font.FontProgram.SetXHeight ( int  xHeight )
inlinepackagevirtual

Sets the x-height in source font units.

Parameters
xHeight height of lowercase flat characters above the baseline

Member Data Documentation

◆ avgWidth

int iText.IO.Font.FontProgram.avgWidth
package

Average glyph width in normalized glyph units.

◆ encodingScheme

String iText.IO.Font.FontProgram.encodingScheme = FontEncoding.FONT_SPECIFIC
package

The font's encoding name.

The font's encoding name. This encoding is 'StandardEncoding' or 'AdobeStandardEncoding' for a font that can be totally encoded according to the characters names. For all other names the font is treated as symbolic.

◆ fontMetrics

FontMetrics iText.IO.Font.FontProgram.fontMetrics = new FontMetrics()
package

Metrics extracted from the font program.

◆ fontNames

FontNames iText.IO.Font.FontProgram.fontNames
package

Naming data extracted from the font program.

◆ isFontSpecific

bool iText.IO.Font.FontProgram.isFontSpecific
package

Indicates that character codes are interpreted using the font's built-in encoding rather than a Unicode-oriented encoding.

◆ registry

String iText.IO.Font.FontProgram.registry
package

CID registry name associated with this font, or null for fonts without a CID registry.