Class Java2DFontResolver

java.lang.Object
com.openhtmltopdf.java2d.Java2DFontResolver
All Implemented Interfaces:
com.openhtmltopdf.extend.FontResolver

public class Java2DFontResolver
extends Object
implements com.openhtmltopdf.extend.FontResolver
REsolves an AWT font instance from a list of CSS font families and characteristics.
Author:
Joshua Marinacci
  • Constructor Summary

    Constructors 
    Constructor Description
    Java2DFontResolver​(com.openhtmltopdf.layout.SharedContext sharedCtx)  
  • Method Summary

    Modifier and Type Method Description
    protected static Font createFont​(com.openhtmltopdf.layout.SharedContext ctx, Font rootFont, float size, com.openhtmltopdf.css.constants.IdentValue weight, com.openhtmltopdf.css.constants.IdentValue style, com.openhtmltopdf.css.constants.IdentValue variant)
    Creates a concrete instance of a font at specified size, weight, style and variant.
    void flushCache()  
    protected static String getFontInstanceHashName​(com.openhtmltopdf.layout.SharedContext ctx, String name, float size, com.openhtmltopdf.css.constants.IdentValue weight, com.openhtmltopdf.css.constants.IdentValue style, com.openhtmltopdf.css.constants.IdentValue variant)
    Gets the hash key for a concrete instance of a font.
    void importFontFaces​(List<com.openhtmltopdf.css.sheet.FontFaceRule> fontFaces)  
    com.openhtmltopdf.render.FSFont resolveFont​(com.openhtmltopdf.layout.SharedContext renderingContext, com.openhtmltopdf.css.value.FontSpecification spec)  
    com.openhtmltopdf.render.FSFont resolveFont​(com.openhtmltopdf.layout.SharedContext ctx, String[] families, float size, com.openhtmltopdf.css.constants.IdentValue weight, com.openhtmltopdf.css.constants.IdentValue style, com.openhtmltopdf.css.constants.IdentValue variant)
    Resolves a list of font families.
    void setFontMapping​(String name, Font font)
    Sets the fontMapping attribute of the FontResolver object

    Methods inherited from class java.lang.Object

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

    • Java2DFontResolver

      public Java2DFontResolver​(com.openhtmltopdf.layout.SharedContext sharedCtx)
  • Method Details

    • flushCache

      public void flushCache()
      Specified by:
      flushCache in interface com.openhtmltopdf.extend.FontResolver
    • importFontFaces

      public void importFontFaces​(List<com.openhtmltopdf.css.sheet.FontFaceRule> fontFaces)
    • resolveFont

      public com.openhtmltopdf.render.FSFont resolveFont​(com.openhtmltopdf.layout.SharedContext ctx, String[] families, float size, com.openhtmltopdf.css.constants.IdentValue weight, com.openhtmltopdf.css.constants.IdentValue style, com.openhtmltopdf.css.constants.IdentValue variant)
      Resolves a list of font families. Search order for each family is: 1. Concrete fonts with correct size that have already been used. 2. Font face fonts. 3. System fonts.
    • setFontMapping

      public void setFontMapping​(String name, Font font)
      Sets the fontMapping attribute of the FontResolver object
      Parameters:
      name - The new fontMapping value
      font - The new fontMapping value
    • createFont

      protected static Font createFont​(com.openhtmltopdf.layout.SharedContext ctx, Font rootFont, float size, com.openhtmltopdf.css.constants.IdentValue weight, com.openhtmltopdf.css.constants.IdentValue style, com.openhtmltopdf.css.constants.IdentValue variant)
      Creates a concrete instance of a font at specified size, weight, style and variant.
    • getFontInstanceHashName

      protected static String getFontInstanceHashName​(com.openhtmltopdf.layout.SharedContext ctx, String name, float size, com.openhtmltopdf.css.constants.IdentValue weight, com.openhtmltopdf.css.constants.IdentValue style, com.openhtmltopdf.css.constants.IdentValue variant)
      Gets the hash key for a concrete instance of a font. This incorporates size, weight, etc.
    • resolveFont

      public com.openhtmltopdf.render.FSFont resolveFont​(com.openhtmltopdf.layout.SharedContext renderingContext, com.openhtmltopdf.css.value.FontSpecification spec)
      Specified by:
      resolveFont in interface com.openhtmltopdf.extend.FontResolver