Class LazyFont

java.lang.Object
org.docx4j.fonts.fop.fonts.Typeface
org.docx4j.fonts.fop.fonts.LazyFont
All Implemented Interfaces:
FontDescriptor, FontMetrics

public class LazyFont
extends Typeface
implements FontDescriptor
This class is used to defer the loading of a font until it is really used.
  • Field Summary

    Fields inherited from class org.docx4j.fonts.fop.fonts.Typeface

    eventListener, NOT_FOUND
  • Constructor Summary

    Constructors 
    Constructor Description
    LazyFont​(EmbedFontInfo fontInfo, FontResolver resolver)
    Main constructor
  • Method Summary

    Modifier and Type Method Description
    int getAscender()
    Returns the ascender value of the font.
    int getAscender​(int size)
    Returns the ascent of the font described by this FontMetrics object.
    int getCapHeight()
    Returns the capital height of the font.
    int getCapHeight​(int size)
    Returns the size of a capital letter measured from the font's baseline.
    int getDescender()
    Returns the descender value of the font.
    int getDescender​(int size)
    Returns the descent of the font described by this FontMetrics object.
    java.lang.String getEmbedFontName()
    Returns the font name for font embedding (may include a prefix, Example: "1E28bcArialMT").
    java.lang.String getEncodingName()
    Get the encoding of the font.
    java.util.Set getFamilyNames()
    Returns the font's family names as a Set of Strings (Example: "Helvetica").
    int getFlags()
    Returns the flags for the font.
    int[] getFontBBox()
    Returns the font's bounding box.
    java.lang.String getFontName()
    Returns the "PostScript" font name (Example: "Helvetica-BoldOblique").
    FontType getFontType()
    Returns the type of the font.
    java.lang.String getFullName()
    Returns the font's full name (Example: "Helvetica Bold Oblique").
    int getItalicAngle()
    Returns the italic angle for the font.
    java.util.Map getKerningInfo()
    Returns the kerning map for the font.
    int getMaxAscent​(int size)
    Returns the maximum ascent of the font described by this FontMetrics object.
    Typeface getRealFont()
    Gets the real font.
    int getStemV()
    Returns the vertical stem width for the font.
    int getWidth​(int i, int size)
    Return the width (in 1/1000ths of point size) of the character at code point i.
    int[] getWidths()
    Return the array of widths.
    int getXHeight​(int size)
    Determines the typical font height of this FontMetrics object
    boolean hadMappingOperations()
    Indicates whether this font had to do any character mapping operations.
    boolean hasChar​(char c)
    Determines whether this font contains a particular character/glyph.
    boolean hasKerningInfo()
    Indicates if the font has kering information.
    boolean isEmbeddable()
    Indicates if this font may be embedded.
    boolean isMultiByte()
    Determines whether the font is a multibyte font.
    boolean isSymbolicFont()
    Indicates whether the font is a symbolic font.
    char mapChar​(char c)
    Map a Unicode character to a code point in the font.
    java.lang.String toString()

    Methods inherited from class org.docx4j.fonts.fop.fonts.Typeface

    notifyMapOperation, setEventListener, warnMissingGlyph

    Methods inherited from class java.lang.Object

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

    • LazyFont

      public LazyFont​(EmbedFontInfo fontInfo, FontResolver resolver)
      Main constructor
      Parameters:
      fontInfo - the font info to embed
      resolver - the font resolver to handle font URIs
  • Method Details

    • toString

      public java.lang.String toString()
      Overrides:
      toString in class Typeface
    • getRealFont

      public Typeface getRealFont()
      Gets the real font.
      Returns:
      the real font
    • getEncodingName

      public java.lang.String getEncodingName()
      Get the encoding of the font.
      Specified by:
      getEncodingName in class Typeface
      Returns:
      the encoding
    • mapChar

      public char mapChar​(char c)
      Map a Unicode character to a code point in the font.
      Specified by:
      mapChar in class Typeface
      Parameters:
      c - character to map
      Returns:
      the mapped character
    • hadMappingOperations

      public boolean hadMappingOperations()
      Indicates whether this font had to do any character mapping operations. If that was not the case, it's an indication that the font has never actually been used.
      Overrides:
      hadMappingOperations in class Typeface
      Returns:
      true if the font had to do any character mapping operations
    • hasChar

      public boolean hasChar​(char c)
      Determines whether this font contains a particular character/glyph.
      Specified by:
      hasChar in class Typeface
      Parameters:
      c - character to check
      Returns:
      True if the character is supported, Falso otherwise
    • isMultiByte

      public boolean isMultiByte()
      Determines whether the font is a multibyte font.
      Overrides:
      isMultiByte in class Typeface
      Returns:
      True if it is multibyte
    • getFontName

      public java.lang.String getFontName()
      Returns the "PostScript" font name (Example: "Helvetica-BoldOblique").
      Specified by:
      getFontName in interface FontMetrics
      Returns:
      the font name
    • getEmbedFontName

      public java.lang.String getEmbedFontName()
      Returns the font name for font embedding (may include a prefix, Example: "1E28bcArialMT").
      Specified by:
      getEmbedFontName in interface FontMetrics
      Returns:
      the name for font embedding
    • getFullName

      public java.lang.String getFullName()
      Returns the font's full name (Example: "Helvetica Bold Oblique").
      Specified by:
      getFullName in interface FontMetrics
      Returns:
      the font's full name
    • getFamilyNames

      public java.util.Set getFamilyNames()
      Returns the font's family names as a Set of Strings (Example: "Helvetica").
      Specified by:
      getFamilyNames in interface FontMetrics
      Returns:
      the font's family names (a Set of Strings)
    • getMaxAscent

      public int getMaxAscent​(int size)
      Returns the maximum ascent of the font described by this FontMetrics object. Note: This is not the same as getAscender().
      Specified by:
      getMaxAscent in interface FontMetrics
      Overrides:
      getMaxAscent in class Typeface
      Parameters:
      size - font size
      Returns:
      ascent in milliponts
    • getAscender

      public int getAscender​(int size)
      Returns the ascent of the font described by this FontMetrics object. It returns the nominal ascent within the em box.
      Specified by:
      getAscender in interface FontMetrics
      Parameters:
      size - font size
      Returns:
      ascent in milliponts
    • getCapHeight

      public int getCapHeight​(int size)
      Returns the size of a capital letter measured from the font's baseline.
      Specified by:
      getCapHeight in interface FontMetrics
      Parameters:
      size - font size
      Returns:
      height of capital characters
    • getDescender

      public int getDescender​(int size)
      Returns the descent of the font described by this FontMetrics object.
      Specified by:
      getDescender in interface FontMetrics
      Parameters:
      size - font size
      Returns:
      descent in milliponts
    • getXHeight

      public int getXHeight​(int size)
      Determines the typical font height of this FontMetrics object
      Specified by:
      getXHeight in interface FontMetrics
      Parameters:
      size - font size
      Returns:
      font height in millipoints
    • getWidth

      public int getWidth​(int i, int size)
      Return the width (in 1/1000ths of point size) of the character at code point i.
      Specified by:
      getWidth in interface FontMetrics
      Parameters:
      i - code point index
      size - font size
      Returns:
      the width of the character
    • getWidths

      public int[] getWidths()
      Return the array of widths.

      This is used to get an array for inserting in an output format. It should not be used for lookup.

      Specified by:
      getWidths in interface FontMetrics
      Returns:
      an array of widths
    • hasKerningInfo

      public boolean hasKerningInfo()
      Indicates if the font has kering information.
      Specified by:
      hasKerningInfo in interface FontMetrics
      Returns:
      True, if kerning is available.
    • getKerningInfo

      public java.util.Map getKerningInfo()
      Returns the kerning map for the font.
      Specified by:
      getKerningInfo in interface FontMetrics
      Returns:
      the kerning map
    • getCapHeight

      public int getCapHeight()
      Returns the capital height of the font.
      Specified by:
      getCapHeight in interface FontDescriptor
      Returns:
      the capital height
    • getDescender

      public int getDescender()
      Returns the descender value of the font. (Descent in pdf spec)
      Specified by:
      getDescender in interface FontDescriptor
      Returns:
      the descender value
    • getAscender

      public int getAscender()
      Returns the ascender value of the font. (Ascent in pdf spec)
      Specified by:
      getAscender in interface FontDescriptor
      Returns:
      the ascender
    • getFlags

      public int getFlags()
      Returns the flags for the font. (See pdf spec)
      Specified by:
      getFlags in interface FontDescriptor
      Returns:
      the flags
    • isSymbolicFont

      public boolean isSymbolicFont()
      Indicates whether the font is a symbolic font.
      Specified by:
      isSymbolicFont in interface FontDescriptor
      Returns:
      true if the font is a symbolic font (i.e. Symbol or ZapfDingbats)
    • getFontBBox

      public int[] getFontBBox()
      Returns the font's bounding box.
      Specified by:
      getFontBBox in interface FontDescriptor
      Returns:
      the bounding box
    • getItalicAngle

      public int getItalicAngle()
      Returns the italic angle for the font.
      Specified by:
      getItalicAngle in interface FontDescriptor
      Returns:
      the italic angle
    • getStemV

      public int getStemV()
      Returns the vertical stem width for the font.
      Specified by:
      getStemV in interface FontDescriptor
      Returns:
      the vertical stem width
    • getFontType

      public FontType getFontType()
      Returns the type of the font.
      Specified by:
      getFontType in interface FontMetrics
      Returns:
      the font type
    • isEmbeddable

      public boolean isEmbeddable()
      Indicates if this font may be embedded.
      Specified by:
      isEmbeddable in interface FontDescriptor
      Returns:
      True, if embedding is possible/permitted