iText 9.8.0 API
iText.IO.Font.FontMetrics Class Reference

Holds the typographic metrics parsed from a font program. More...

Public Member Functions

virtual int  GetUnitsPerEm ()
  Gets the units per em value declared by the source font. More...
 
virtual int  GetNumberOfGlyphs ()
  Gets the number of glyphs declared by the font. More...
 
virtual int[]  GetGlyphWidths ()
  Gets the glyph width array. More...
 
virtual int  GetTypoAscender ()
  Gets typo (a.k.a. sTypo or OS/2) vertical metric corresponding to ascender. More...
 
virtual int  GetTypoDescender ()
  Gets typo (a.k.a. sTypo or OS/2) vertical metric corresponding to descender. More...
 
virtual int  GetCapHeight ()
  Gets the capital letters height. More...
 
virtual int  GetXHeight ()
  Gets the height of lowercase flat characters above the baseline. More...
 
virtual float  GetItalicAngle ()
  Gets the PostScript italic angle. More...
 
virtual int[]  GetBbox ()
  Gets the font bounding box. More...
 
virtual void  SetBbox (int llx, int lly, int urx, int ury)
  Replaces the normalized font bounding box. More...
 
virtual int  GetAscender ()
  Gets the horizontal ascender. More...
 
virtual int  GetDescender ()
  Gets the horizontal descender. More...
 
virtual int  GetLineGap ()
  Gets the line spacing. More...
 
virtual int  GetWinAscender ()
  Gets the Windows ascender metric. More...
 
virtual int  GetWinDescender ()
  Gets the Windows descender metric. More...
 
virtual int  GetAdvanceWidthMax ()
  Gets the largest horizontal advance width in the font. More...
 
virtual int  GetUnderlinePosition ()
  Gets the underline center position relative to the baseline. More...
 
virtual int  GetUnderlineThickness ()
  Gets the recommended underline thickness. More...
 
virtual int  GetStrikeoutPosition ()
  Gets the strikeout position relative to the baseline. More...
 
virtual int  GetStrikeoutSize ()
  Gets the strikeout thickness. More...
 
virtual int  GetSubscriptSize ()
  Gets the recommended vertical size for subscripts. More...
 
virtual int  GetSubscriptOffset ()
  Gets the subscript baseline offset. More...
 
virtual int  GetSuperscriptSize ()
  Gets the recommended vertical size for superscripts. More...
 
virtual int  GetSuperscriptOffset ()
  Gets the superscript baseline offset. More...
 
virtual int  GetStemV ()
  Gets the dominant vertical stem width. More...
 
virtual int  GetStemH ()
  Gets the dominant horizontal stem width. More...
 
virtual bool  IsFixedPitch ()
  Checks whether all glyphs use a common width. More...
 
virtual void  SetStemV (int stemV)
  Sets the dominant vertical stem width. More...
 

Package Functions

virtual void  SetUnitsPerEm (int unitsPerEm)
  Sets source units per em. More...
 
virtual void  UpdateBbox (float llx, float lly, float urx, float ury)
  Converts and stores a font bounding box in source units. More...
 
virtual void  SetNumberOfGlyphs (int numOfGlyphs)
  Sets the glyph count declared by the font. More...
 
virtual void  SetGlyphWidths (int[] glyphWidths)
  Stores the glyph width table. More...
 
virtual void  SetTypoAscender (int typoAscender)
  Sets typo (a.k.a. sTypo or OS/2) vertical metric corresponding to ascender. More...
 
virtual void  SetTypoDescender (int typoDescender)
  Sets typo (a.k.a. sTypo or OS/2) vertical metric corresponding to descender. More...
 
virtual void  SetCapHeight (int capHeight)
  Sets the capital letters height. More...
 
virtual void  SetXHeight (int xHeight)
  Sets the source font x-height. More...
 
virtual void  SetItalicAngle (float italicAngle)
  Sets the PostScript italic angle without unit normalization. More...
 
virtual void  SetAscender (int ascender)
  Sets the source horizontal ascender. More...
 
virtual void  SetDescender (int descender)
  Sets the source horizontal descender. More...
 
virtual void  SetLineGap (int lineGap)
  Sets the line space. More...
 
virtual void  SetWinAscender (int winAscender)
  Sets the source Windows ascender metric. More...
 
virtual void  SetWinDescender (int winDescender)
  Sets the source Windows descender metric. More...
 
virtual void  SetAdvanceWidthMax (int advanceWidthMax)
  Sets the largest horizontal advance width declared by the source font. More...
 
virtual void  SetUnderlinePosition (int underlinePosition)
  Sets the source underline position. More...
 
virtual void  SetUnderlineThickness (int underlineThickness)
  Sets the underline thickness. More...
 
virtual void  SetStrikeoutPosition (int strikeoutPosition)
  Sets the source strikeout position. More...
 
virtual void  SetStrikeoutSize (int strikeoutSize)
  Sets the source strikeout thickness. More...
 
virtual void  SetSubscriptSize (int subscriptSize)
  Sets the source subscript vertical size. More...
 
virtual void  SetSubscriptOffset (int subscriptOffset)
  Sets the source subscript vertical offset. More...
 
virtual void  SetSuperscriptSize (int superscriptSize)
  Sets the superscript vertical size. More...
 
virtual void  SetSuperscriptOffset (int superscriptOffset)
  Sets the source superscript vertical offset. More...
 
virtual void  SetStemH (int stemH)
  Sets the dominant horizontal stem width. More...
 
virtual void  SetIsFixedPitch (bool isFixedPitch)
  Sets whether the font declares a common width for all glyphs. More...
 

Package Attributes

float  normalizationCoef = 1f
  Multiplier that converts values expressed in the source font's units per em to normalized 1000-unit glyph space. More...
 

Detailed Description

Holds the typographic metrics parsed from a font program.

Holds the typographic metrics parsed from a font program.

Unless stated otherwise, dimensional values are normalized to the PDF glyph space of 1000 units per em when they are assigned by the font readers.

Member Function Documentation

◆ GetAdvanceWidthMax()

virtual int iText.IO.Font.FontMetrics.GetAdvanceWidthMax ( )
inlinevirtual

Gets the largest horizontal advance width in the font.

Returns
maximum advance width in normalized glyph units

◆ GetAscender()

virtual int iText.IO.Font.FontMetrics.GetAscender ( )
inlinevirtual

Gets the horizontal ascender.

Returns
ascender in normalized glyph units

◆ GetBbox()

virtual int [] iText.IO.Font.FontMetrics.GetBbox ( )
inlinevirtual

Gets the font bounding box.

Returns
array containing lower-left x/y and upper-right x/y in normalized glyph units

◆ GetCapHeight()

virtual int iText.IO.Font.FontMetrics.GetCapHeight ( )
inlinevirtual

Gets the capital letters height.

Gets the capital letters height.

This property defines the vertical coordinate of the top of flat capital letters, measured from the baseline.

Returns
cap height in 1000-units

◆ GetDescender()

virtual int iText.IO.Font.FontMetrics.GetDescender ( )
inlinevirtual

Gets the horizontal descender.

Returns
descender in normalized glyph units

◆ GetGlyphWidths()

virtual int [] iText.IO.Font.FontMetrics.GetGlyphWidths ( )
inlinevirtual

Gets the glyph width array.

Returns
glyph widths indexed by glyph ID

◆ GetItalicAngle()

virtual float iText.IO.Font.FontMetrics.GetItalicAngle ( )
inlinevirtual

Gets the PostScript italic angle.

Returns
counterclockwise degrees from vertical; negative values lean right

◆ GetLineGap()

virtual int iText.IO.Font.FontMetrics.GetLineGap ( )
inlinevirtual

Gets the line spacing.

Returns
horizontal line gap in normalized glyph units

◆ GetNumberOfGlyphs()

virtual int iText.IO.Font.FontMetrics.GetNumberOfGlyphs ( )
inlinevirtual

Gets the number of glyphs declared by the font.

Returns
glyph count

◆ GetStemH()

virtual int iText.IO.Font.FontMetrics.GetStemH ( )
inlinevirtual

Gets the dominant horizontal stem width.

Returns
Type 1/CFF StdHW value, or the reader's fallback, in glyph units

◆ GetStemV()

virtual int iText.IO.Font.FontMetrics.GetStemV ( )
inlinevirtual

Gets the dominant vertical stem width.

Returns
Type 1/CFF StdVW value, or the reader's fallback, in glyph units

◆ GetStrikeoutPosition()

virtual int iText.IO.Font.FontMetrics.GetStrikeoutPosition ( )
inlinevirtual

Gets the strikeout position relative to the baseline.

Returns
OS/2 strikeout position in normalized glyph units

◆ GetStrikeoutSize()

virtual int iText.IO.Font.FontMetrics.GetStrikeoutSize ( )
inlinevirtual

Gets the strikeout thickness.

Returns
OS/2 strikeout size in normalized glyph units

◆ GetSubscriptOffset()

virtual int iText.IO.Font.FontMetrics.GetSubscriptOffset ( )
inlinevirtual

Gets the subscript baseline offset.

Returns
subscript y-offset in normalized glyph units

◆ GetSubscriptSize()

virtual int iText.IO.Font.FontMetrics.GetSubscriptSize ( )
inlinevirtual

Gets the recommended vertical size for subscripts.

Returns
subscript y-size in normalized glyph units

◆ GetSuperscriptOffset()

virtual int iText.IO.Font.FontMetrics.GetSuperscriptOffset ( )
inlinevirtual

Gets the superscript baseline offset.

Returns
superscript y-offset in normalized glyph units

◆ GetSuperscriptSize()

virtual int iText.IO.Font.FontMetrics.GetSuperscriptSize ( )
inlinevirtual

Gets the recommended vertical size for superscripts.

Returns
superscript y-size in source font units

◆ GetTypoAscender()

virtual int iText.IO.Font.FontMetrics.GetTypoAscender ( )
inlinevirtual

Gets typo (a.k.a. sTypo or OS/2) vertical metric corresponding to ascender.

Gets typo (a.k.a. sTypo or OS/2) vertical metric corresponding to ascender.

Typo vertical metrics are the primary source for iText ascender/descender calculations.

Returns
typo ascender value in normalized 1000-units

◆ GetTypoDescender()

virtual int iText.IO.Font.FontMetrics.GetTypoDescender ( )
inlinevirtual

Gets typo (a.k.a. sTypo or OS/2) vertical metric corresponding to descender.

Gets typo (a.k.a. sTypo or OS/2) vertical metric corresponding to descender.

Typo vertical metrics are the primary source for iText ascender/descender calculations.

Returns
typo descender value in normalized 1000-units

◆ GetUnderlinePosition()

virtual int iText.IO.Font.FontMetrics.GetUnderlinePosition ( )
inlinevirtual

Gets the underline center position relative to the baseline.

Returns
normalized underline position, adjusted from the stored edge by half its thickness

◆ GetUnderlineThickness()

virtual int iText.IO.Font.FontMetrics.GetUnderlineThickness ( )
inlinevirtual

Gets the recommended underline thickness.

Returns
stored thickness value; readers currently supply it in source font units

◆ GetUnitsPerEm()

virtual int iText.IO.Font.FontMetrics.GetUnitsPerEm ( )
inlinevirtual

Gets the units per em value declared by the source font.

Returns
source font design units in one em

◆ GetWinAscender()

virtual int iText.IO.Font.FontMetrics.GetWinAscender ( )
inlinevirtual

Gets the Windows ascender metric.

Returns
OS/2 usWinAscent in normalized glyph units

◆ GetWinDescender()

virtual int iText.IO.Font.FontMetrics.GetWinDescender ( )
inlinevirtual

Gets the Windows descender metric.

Returns
OS/2 usWinDescent in normalized glyph units

◆ GetXHeight()

virtual int iText.IO.Font.FontMetrics.GetXHeight ( )
inlinevirtual

Gets the height of lowercase flat characters above the baseline.

Returns
x-height in normalized glyph units, or zero when not present

◆ IsFixedPitch()

virtual bool iText.IO.Font.FontMetrics.IsFixedPitch ( )
inlinevirtual

Checks whether all glyphs use a common width.

Returns

true when the font declares fixed pitch

◆ SetAdvanceWidthMax()

virtual void iText.IO.Font.FontMetrics.SetAdvanceWidthMax ( int  advanceWidthMax )
inlinepackagevirtual

Sets the largest horizontal advance width declared by the source font.

Parameters
advanceWidthMax

hhea.advanceWidthMax in source units

◆ SetAscender()

virtual void iText.IO.Font.FontMetrics.SetAscender ( int  ascender )
inlinepackagevirtual

Sets the source horizontal ascender.

Parameters
ascender

hhea.Ascender in source units

◆ SetBbox()

virtual void iText.IO.Font.FontMetrics.SetBbox ( int  llx,
int  lly,
int  urx,
int  ury 
)
inlinevirtual

Replaces the normalized font bounding box.

Parameters
llx lower-left x coordinate
lly lower-left y coordinate
urx upper-right x coordinate
ury upper-right y coordinate

◆ SetCapHeight()

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

Sets the capital letters height.

Sets the capital letters height.

This property defines the vertical coordinate of the top of flat capital letters, measured from the baseline.

Parameters
capHeight cap height in 1000-units

◆ SetDescender()

virtual void iText.IO.Font.FontMetrics.SetDescender ( int  descender )
inlinepackagevirtual

Sets the source horizontal descender.

Parameters
descender

hhea.Descender in source units

◆ SetGlyphWidths()

virtual void iText.IO.Font.FontMetrics.SetGlyphWidths ( int[]  glyphWidths )
inlinepackagevirtual

Stores the glyph width table.

Parameters
glyphWidths width array indexed by glyph ID

◆ SetIsFixedPitch()

virtual void iText.IO.Font.FontMetrics.SetIsFixedPitch ( bool  isFixedPitch )
inlinepackagevirtual

Sets whether the font declares a common width for all glyphs.

Parameters
isFixedPitch

true for fixed pitch fonts

◆ SetItalicAngle()

virtual void iText.IO.Font.FontMetrics.SetItalicAngle ( float  italicAngle )
inlinepackagevirtual

Sets the PostScript italic angle without unit normalization.

Parameters
italicAngle counterclockwise degrees from vertical

◆ SetLineGap()

virtual void iText.IO.Font.FontMetrics.SetLineGap ( int  lineGap )
inlinepackagevirtual

Sets the line space.

Parameters
lineGap

hhea.LineGap in source units

◆ SetNumberOfGlyphs()

virtual void iText.IO.Font.FontMetrics.SetNumberOfGlyphs ( int  numOfGlyphs )
inlinepackagevirtual

Sets the glyph count declared by the font.

Parameters
numOfGlyphs number of glyphs

◆ SetStemH()

virtual void iText.IO.Font.FontMetrics.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.FontMetrics.SetStemV ( int  stemV )
inlinevirtual

Sets the dominant vertical stem width.

Parameters
stemV Type 1/CFF StdVW value in glyph units

◆ SetStrikeoutPosition()

virtual void iText.IO.Font.FontMetrics.SetStrikeoutPosition ( int  strikeoutPosition )
inlinepackagevirtual

Sets the source strikeout position.

Parameters
strikeoutPosition OS/2 yStrikeoutPosition in source units

◆ SetStrikeoutSize()

virtual void iText.IO.Font.FontMetrics.SetStrikeoutSize ( int  strikeoutSize )
inlinepackagevirtual

Sets the source strikeout thickness.

Parameters
strikeoutSize OS/2 yStrikeoutSize in source units

◆ SetSubscriptOffset()

virtual void iText.IO.Font.FontMetrics.SetSubscriptOffset ( int  subscriptOffset )
inlinepackagevirtual

Sets the source subscript vertical offset.

Parameters
subscriptOffset OS/2 ySubscriptYOffset in source units

◆ SetSubscriptSize()

virtual void iText.IO.Font.FontMetrics.SetSubscriptSize ( int  subscriptSize )
inlinepackagevirtual

Sets the source subscript vertical size.

Parameters
subscriptSize OS/2 ySubscriptYSize in source units

◆ SetSuperscriptOffset()

virtual void iText.IO.Font.FontMetrics.SetSuperscriptOffset ( int  superscriptOffset )
inlinepackagevirtual

Sets the source superscript vertical offset.

Parameters
superscriptOffset OS/2 ySuperscriptYOffset in source units

◆ SetSuperscriptSize()

virtual void iText.IO.Font.FontMetrics.SetSuperscriptSize ( int  superscriptSize )
inlinepackagevirtual

Sets the superscript vertical size.

Parameters
superscriptSize OS/2 ySuperscriptYSize ; stored without normalization

◆ SetTypoAscender()

virtual void iText.IO.Font.FontMetrics.SetTypoAscender ( int  typoAscender )
inlinepackagevirtual

Sets typo (a.k.a. sTypo or OS/2) vertical metric corresponding to ascender.

Sets typo (a.k.a. sTypo or OS/2) vertical metric corresponding to ascender.

Typo vertical metrics are the primary source for iText ascender/descender calculations.

Parameters
typoAscender typo ascender value in normalized 1000-units

◆ SetTypoDescender()

virtual void iText.IO.Font.FontMetrics.SetTypoDescender ( int  typoDescender )
inlinepackagevirtual

Sets typo (a.k.a. sTypo or OS/2) vertical metric corresponding to descender.

Sets typo (a.k.a. sTypo or OS/2) vertical metric corresponding to descender.

Typo vertical metrics are the primary source for iText ascender/descender calculations.

Parameters
typoDescender typo descender value in normalized 1000-units

◆ SetUnderlinePosition()

virtual void iText.IO.Font.FontMetrics.SetUnderlinePosition ( int  underlinePosition )
inlinepackagevirtual

Sets the source underline position.

Parameters
underlinePosition

post.underlinePosition in source units

◆ SetUnderlineThickness()

virtual void iText.IO.Font.FontMetrics.SetUnderlineThickness ( int  underlineThickness )
inlinepackagevirtual

Sets the underline thickness.

Parameters
underlineThickness

post.underlineThickness ; stored without normalization

◆ SetUnitsPerEm()

virtual void iText.IO.Font.FontMetrics.SetUnitsPerEm ( int  unitsPerEm )
inlinepackagevirtual

Sets source units per em.

Sets source units per em.

It recalculates the normalization multiplier used by subsequent setters.

Parameters
unitsPerEm positive number of design units in an em

◆ SetWinAscender()

virtual void iText.IO.Font.FontMetrics.SetWinAscender ( int  winAscender )
inlinepackagevirtual

Sets the source Windows ascender metric.

Parameters
winAscender OS/2 usWinAscent in source units

◆ SetWinDescender()

virtual void iText.IO.Font.FontMetrics.SetWinDescender ( int  winDescender )
inlinepackagevirtual

Sets the source Windows descender metric.

Parameters
winDescender OS/2 usWinDescent in source units

◆ SetXHeight()

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

Sets the source font x-height.

Parameters
xHeight OS/2 sxHeight in source units

◆ UpdateBbox()

virtual void iText.IO.Font.FontMetrics.UpdateBbox ( float  llx,
float  lly,
float  urx,
float  ury 
)
inlinepackagevirtual

Converts and stores a font bounding box in source units.

Parameters
llx lower-left x coordinate in source units
lly lower-left y coordinate in source units
urx upper-right x coordinate in source units
ury upper-right y coordinate in source units

Member Data Documentation

◆ normalizationCoef

float iText.IO.Font.FontMetrics.normalizationCoef = 1f
package

Multiplier that converts values expressed in the source font's units per em to normalized 1000-unit glyph space.

Multiplier that converts values expressed in the source font's units per em to normalized 1000-unit glyph space. Font readers update it after reading head.unitsPerEm.