Class Java2DFontResolver

  • All Implemented Interfaces:
    FontResolver

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

      • Java2DFontResolver

        public Java2DFontResolver​(SharedContext sharedCtx,
                                  boolean useEnvironmentFonts)
    • Method Detail

      • flushCache

        @Deprecated
        public void flushCache()
        Deprecated.
      • importFontFaces

        public void importFontFaces​(List<FontFaceRule> fontFaces)
      • addFontFile

        public void addFontFile​(File fontFile,
                                String fontFamilyNameOverride,
                                Integer fontWeightOverride,
                                IdentValue fontStyleOverride)
        Add a font using a existing file. Does not handle true type collections.
      • resolveFont

        public FSFont resolveFont​(SharedContext ctx,
                                  String[] families,
                                  float size,
                                  IdentValue weight,
                                  IdentValue style,
                                  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
      • getFontInstanceHashName

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