Class FontConfig


  • public class FontConfig
    extends Object
    Used to configure the client that shall use standard 14 fonts for text annotation rendering.

    The general idea is to have the standard 14 fonts Arimo, Tinos and Cousine in all 4 variants (normal, bold, italic, bold+italic) downloadable on the server.

    Upon loading the application in the browser, the client downloads those fonts from the server and uses them for text + stamp annotation rendering. This class is a Singleton implementation. Access to the single instance of this class is only permitted using the #get() method.

    • Field Detail

      • fontHandler

        protected com.levigo.jadice.web.client.util.internal.fonts.WebFontLoader.WebFontHandler fontHandler
        the WebFontLoader.WebFontHandler needed to determine when certain fonts are loaded and when all loading operations are done (successful or not)
      • fontsToLoad

        protected final com.levigo.jadice.web.client.util.internal.fonts.WebFontLoader.WebFonts fontsToLoad
        set of fontsToLoad that will be loaded into the client
      • instance

        protected static FontConfig instance
        The single instance of this class.
    • Constructor Detail

      • FontConfig

        public FontConfig()
        Creates a new instance of the FontConfig. Since this is a singleton implementation this constructor is only to be called from the get()-method .
    • Method Detail

      • get

        public static FontConfig get()
        Returns the only existing instance of this class. If that instance does not yet exist it is created while calling this method. If the instance already exists that instance is returned.
        Returns:
        the sole instance of this class
      • setFontHandler

        protected void setFontHandler​(com.levigo.jadice.web.client.util.internal.fonts.WebFontLoader.WebFontHandler fontHandler)
        Set the WebFontLoader.WebFontHandler to be used.
        Parameters:
        fontHandler - the WebFontLoader.WebFontHandler to be used. This parameter must not be null.
      • addFontToLoad

        protected void addFontToLoad​(String familyName,
                                     FontConfig.FontProperty fontProperty,
                                     String pathToFontManager)
        Adds the font defined in the given parameter to the list of fonts to be loaded by adding a stylesheet to the document
        Parameters:
        familyName - the family name of the font to be loaded
        fontProperty - defines whether the font shall be bold, italic, both or plain.
        pathToFontManager - the path to the fontmanager to retrieve the font from
      • createFontFacePath

        protected static String createFontFacePath​(String pathToFontManager,
                                                   String familyName,
                                                   FontConfig.FontProperty fontProperty)
        Helper to improve readability in the addFontToLoad(String, FontProperty, String) method. This method creates a path to request the given familyName with the given style and weight from a fontManager.
        Parameters:
        pathToFontManager - the path to the fontManager to retrieve the font from
        familyName - the family name of the font to be retrieved using the created path
        fontProperty - the FontConfig.FontProperty to define whether the font shall be italic, plain, both, or plain
        Returns:
        a path at which to request a font with the given family name in the given style and weight based on the given fontManager path.
      • addStandardFontsToLoad

        protected void addStandardFontsToLoad​(String pathToFontManager)
        Add the fonts for the WebFontLoader to load. The standard fonts are Arimo, Cousine and Tinos in all 4 permutations(regular, bold, italic, bold + italic).
        Parameters:
        pathToFontManager - path to the FontDownloadServlet as defined in the web.xml
      • addFontFamilyToLoad

        protected void addFontFamilyToLoad​(com.levigo.jadice.web.client.util.internal.fonts.DefaultFont font,
                                           String pathToFontManager)
        Loads a single DefaultFont in Plain, Italic, Bold and Bold-Italic
        Parameters:
        font - the Font that will be loaded in Plain, Italic, Bold and Bold-Italic
        pathToFontManager - path to the FontDownloadServlet as defined in the web.xml
      • loadFonts

        protected void loadFonts​(String pathToJs)
        load the fontsToLoad that have been added to fontsToLoad
        Parameters:
        pathToJs - The path to the webfonts.js file