Class FontMetrics
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected floatMultiplier that converts values expressed in the source font's units per em to normalized 1000-unit glyph space. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintGets the largest horizontal advance width in the font.intGets the horizontal ascender.int[]getBbox()Gets the font bounding box.intGets the capital letters height.intGets the horizontal descender.int[]Gets the glyph width array.floatGets the PostScript italic angle.intGets the line spacing.intGets the number of glyphs declared by the font.intgetStemH()Gets the dominant horizontal stem width.intgetStemV()Gets the dominant vertical stem width.intGets the strikeout position relative to the baseline.intGets the strikeout thickness.intGets the subscript baseline offset.intGets the recommended vertical size for subscripts.intGets the superscript baseline offset.intGets the recommended vertical size for superscripts.intGets typo (a.k.a.intGets typo (a.k.a.intGets the underline center position relative to the baseline.intGets the recommended underline thickness.intGets the units per em value declared by the source font.intGets the Windows ascender metric.intGets the Windows descender metric.intGets the height of lowercase flat characters above the baseline.booleanChecks whether all glyphs use a common width.protected voidsetAdvanceWidthMax(int advanceWidthMax) Sets the largest horizontal advance width declared by the source font.protected voidsetAscender(int ascender) Sets the source horizontal ascender.voidsetBbox(int llx, int lly, int urx, int ury) Replaces the normalized font bounding box.protected voidsetCapHeight(int capHeight) Sets the capital letters height.protected voidsetDescender(int descender) Sets the source horizontal descender.protected voidsetGlyphWidths(int[] glyphWidths) Stores the glyph width table.protected voidsetIsFixedPitch(boolean isFixedPitch) Sets whether the font declares a common width for all glyphs.protected voidsetItalicAngle(float italicAngle) Sets the PostScript italic angle without unit normalization.protected voidsetLineGap(int lineGap) Sets the line space.protected voidsetNumberOfGlyphs(int numOfGlyphs) Sets the glyph count declared by the font.protected voidsetStemH(int stemH) Sets the dominant horizontal stem width.voidsetStemV(int stemV) Sets the dominant vertical stem width.protected voidsetStrikeoutPosition(int strikeoutPosition) Sets the source strikeout position.protected voidsetStrikeoutSize(int strikeoutSize) Sets the source strikeout thickness.protected voidsetSubscriptOffset(int subscriptOffset) Sets the source subscript vertical offset.protected voidsetSubscriptSize(int subscriptSize) Sets the source subscript vertical size.protected voidsetSuperscriptOffset(int superscriptOffset) Sets the source superscript vertical offset.protected voidsetSuperscriptSize(int superscriptSize) Sets the superscript vertical size.protected voidsetTypoAscender(int typoAscender) Sets typo (a.k.a.protected voidsetTypoDescender(int typoDescender) Sets typo (a.k.a.protected voidsetUnderlinePosition(int underlinePosition) Sets the source underline position.protected voidsetUnderlineThickness(int underlineThickness) Sets the underline thickness.protected voidsetUnitsPerEm(int unitsPerEm) Sets source units per em.protected voidsetWinAscender(int winAscender) Sets the source Windows ascender metric.protected voidsetWinDescender(int winDescender) Sets the source Windows descender metric.protected voidsetXHeight(int xHeight) Sets the source font x-height.protected voidupdateBbox(float llx, float lly, float urx, float ury) Converts and stores a font bounding box in source units.
-
Field Details
-
normalizationCoef
protected float normalizationCoefMultiplier that converts values expressed in the source font's units per em to normalized 1000-unit glyph space. Font readers update it after readinghead.unitsPerEm.
-
-
Constructor Details
-
FontMetrics
public FontMetrics()
-
-
Method Details
-
getUnitsPerEm
public int getUnitsPerEm()Gets the units per em value declared by the source font.- Returns:
- source font design units in one em
-
getNumberOfGlyphs
public int getNumberOfGlyphs()Gets the number of glyphs declared by the font.- Returns:
- glyph count
-
getGlyphWidths
public int[] getGlyphWidths()Gets the glyph width array.- Returns:
- glyph widths indexed by glyph ID
-
getTypoAscender
public int getTypoAscender()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
public int getTypoDescender()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
-
getCapHeight
public int getCapHeight()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
-
getXHeight
public int getXHeight()Gets the height of lowercase flat characters above the baseline.- Returns:
- x-height in normalized glyph units, or zero when not present
-
getItalicAngle
public float getItalicAngle()Gets the PostScript italic angle.- Returns:
- counterclockwise degrees from vertical; negative values lean right
-
getBbox
public int[] getBbox()Gets the font bounding box.- Returns:
- array containing lower-left x/y and upper-right x/y in normalized glyph units
-
setBbox
public void setBbox(int llx, int lly, int urx, int ury) 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
-
getAscender
public int getAscender()Gets the horizontal ascender.- Returns:
- ascender in normalized glyph units
-
getDescender
public int getDescender()Gets the horizontal descender.- Returns:
- descender in normalized glyph units
-
getLineGap
public int getLineGap()Gets the line spacing.- Returns:
- horizontal line gap in normalized glyph units
-
getWinAscender
public int getWinAscender()Gets the Windows ascender metric.- Returns:
-
OS/2
usWinAscentin normalized glyph units
-
getWinDescender
public int getWinDescender()Gets the Windows descender metric.- Returns:
-
OS/2
usWinDescentin normalized glyph units
-
getAdvanceWidthMax
public int getAdvanceWidthMax()Gets the largest horizontal advance width in the font.- Returns:
- maximum advance width in normalized glyph units
-
getUnderlinePosition
public int getUnderlinePosition()Gets the underline center position relative to the baseline.- Returns:
- normalized underline position, adjusted from the stored edge by half its thickness
-
getUnderlineThickness
public int getUnderlineThickness()Gets the recommended underline thickness.- Returns:
- stored thickness value; readers currently supply it in source font units
-
getStrikeoutPosition
public int getStrikeoutPosition()Gets the strikeout position relative to the baseline.- Returns:
- OS/2 strikeout position in normalized glyph units
-
getStrikeoutSize
public int getStrikeoutSize()Gets the strikeout thickness.- Returns:
- OS/2 strikeout size in normalized glyph units
-
getSubscriptSize
public int getSubscriptSize()Gets the recommended vertical size for subscripts.- Returns:
- subscript y-size in normalized glyph units
-
getSubscriptOffset
public int getSubscriptOffset()Gets the subscript baseline offset.- Returns:
- subscript y-offset in normalized glyph units
-
getSuperscriptSize
public int getSuperscriptSize()Gets the recommended vertical size for superscripts.- Returns:
- superscript y-size in source font units
-
getSuperscriptOffset
public int getSuperscriptOffset()Gets the superscript baseline offset.- Returns:
- superscript y-offset in normalized glyph units
-
getStemV
public int getStemV()Gets the dominant vertical stem width.- Returns:
-
Type 1/CFF
StdVWvalue, or the reader's fallback, in glyph units
-
getStemH
public int getStemH()Gets the dominant horizontal stem width.- Returns:
-
Type 1/CFF
StdHWvalue, or the reader's fallback, in glyph units
-
isFixedPitch
public boolean isFixedPitch()Checks whether all glyphs use a common width.- Returns:
-
truewhen the font declares fixed pitch
-
setUnitsPerEm
protected void setUnitsPerEm(int unitsPerEm) Sets source units per em.It recalculates the normalization multiplier used by subsequent setters.
- Parameters:
-
unitsPerEm- positive number of design units in an em
-
updateBbox
protected void updateBbox(float llx, float lly, float urx, float ury) 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
-
setNumberOfGlyphs
protected void setNumberOfGlyphs(int numOfGlyphs) Sets the glyph count declared by the font.- Parameters:
-
numOfGlyphs- number of glyphs
-
setGlyphWidths
protected void setGlyphWidths(int[] glyphWidths) Stores the glyph width table.- Parameters:
-
glyphWidths- width array indexed by glyph ID
-
setTypoAscender
protected void setTypoAscender(int typoAscender) 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
protected void setTypoDescender(int typoDescender) 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
-
setCapHeight
protected void setCapHeight(int capHeight) 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
-
setXHeight
protected void setXHeight(int xHeight) Sets the source font x-height.- Parameters:
-
xHeight- OS/2sxHeightin source units
-
setItalicAngle
protected void setItalicAngle(float italicAngle) Sets the PostScript italic angle without unit normalization.- Parameters:
-
italicAngle- counterclockwise degrees from vertical
-
setAscender
protected void setAscender(int ascender) Sets the source horizontal ascender.- Parameters:
-
ascender-hhea.Ascenderin source units
-
setDescender
protected void setDescender(int descender) Sets the source horizontal descender.- Parameters:
-
descender-hhea.Descenderin source units
-
setLineGap
protected void setLineGap(int lineGap) Sets the line space.- Parameters:
-
lineGap-hhea.LineGapin source units
-
setWinAscender
protected void setWinAscender(int winAscender) Sets the source Windows ascender metric.- Parameters:
-
winAscender- OS/2usWinAscentin source units
-
setWinDescender
protected void setWinDescender(int winDescender) Sets the source Windows descender metric.- Parameters:
-
winDescender- OS/2usWinDescentin source units
-
setAdvanceWidthMax
protected void setAdvanceWidthMax(int advanceWidthMax) Sets the largest horizontal advance width declared by the source font.- Parameters:
-
advanceWidthMax-hhea.advanceWidthMaxin source units
-
setUnderlinePosition
protected void setUnderlinePosition(int underlinePosition) Sets the source underline position.- Parameters:
-
underlinePosition-post.underlinePositionin source units
-
setUnderlineThickness
protected void setUnderlineThickness(int underlineThickness) Sets the underline thickness.- Parameters:
-
underlineThickness-post.underlineThickness; stored without normalization
-
setStrikeoutPosition
protected void setStrikeoutPosition(int strikeoutPosition) Sets the source strikeout position.- Parameters:
-
strikeoutPosition- OS/2yStrikeoutPositionin source units
-
setStrikeoutSize
protected void setStrikeoutSize(int strikeoutSize) Sets the source strikeout thickness.- Parameters:
-
strikeoutSize- OS/2yStrikeoutSizein source units
-
setSubscriptSize
protected void setSubscriptSize(int subscriptSize) Sets the source subscript vertical size.- Parameters:
-
subscriptSize- OS/2ySubscriptYSizein source units
-
setSubscriptOffset
protected void setSubscriptOffset(int subscriptOffset) Sets the source subscript vertical offset.- Parameters:
-
subscriptOffset- OS/2ySubscriptYOffsetin source units
-
setSuperscriptSize
protected void setSuperscriptSize(int superscriptSize) Sets the superscript vertical size.- Parameters:
-
superscriptSize- OS/2ySuperscriptYSize; stored without normalization
-
setSuperscriptOffset
protected void setSuperscriptOffset(int superscriptOffset) Sets the source superscript vertical offset.- Parameters:
-
superscriptOffset- OS/2ySuperscriptYOffsetin source units
-
setStemV
public void setStemV(int stemV) Sets the dominant vertical stem width.- Parameters:
-
stemV- Type 1/CFFStdVWvalue in glyph units
-
setStemH
protected void setStemH(int stemH) Sets the dominant horizontal stem width.- Parameters:
-
stemH- Type 1/CFFStdHWvalue in glyph units
-
setIsFixedPitch
protected void setIsFixedPitch(boolean isFixedPitch) Sets whether the font declares a common width for all glyphs.- Parameters:
-
isFixedPitch-truefor fixed pitch fonts
-