com.smartgwt.client.util

## Class FontLoader

- java.lang.Object
- - com.smartgwt.client.util.FontLoader

-     public class FontLoader
      extends java.lang.Object

  Force-loads the custom fonts declared in the `current skin's CSS file` and updates any potentially-affected, already-drawn canvii when loading completes. Without FontLoader, auto-sized canvii that use custom fonts may end up with the wrong size if a page is loaded when its custom fonts are not available in the browser cache.

  To disable FontLoader, set `window.isc_loadCustomFonts = false` before Smart GWT is loaded.

  If you want to avoid the Framework redrawing canvii after the fonts load, you may want to code your app to delay drawing anything until the skin fonts are loaded. You can check `isLoadingComplete()` to see whether loading is done, and if it's not, you can call `addFontsLoadedHandler()` to run code when it's done or `addFontLoadingFailedHandler()` to run code if there's an error.

  ### Advanced Usage

  `FontLoader` will use the new CSS Font Loading API in browsers in which it's available and has proven reliable. Otherwise, we fall back to canvas measurement techniques to detect loading. To force fallback and avoid the API, set `window.isc_useCSSFontAPI = false` , or to force the API to be used (where it exists but may be unreliable) set `window.isc_useCSSFontAPI = true` , before Smart GWT is loaded.

  If you're loading additional style sheets, beyond the skin, that declare custom fonts with @font-face, you can request that the `FontLoader` force-load them as well by specifying them in `window.isc_additionalFonts` as an array of the font family names matching those from the @font-face declarations.

  Note that currently, if you have more than one font with the same font family name in your CSS, you'll need to use the CSS Font Loading API approach if you want them all loaded by the FontLoader. Under the measurement approach, the FontLoader is only able to load the default font for each font family, since it has no knowledge beyond the specified family names.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `FontLoader()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static com.google.gwt.event.shared.HandlerRegistration` | `addFontLoadingFailedHandler(FontLoadingFailedHandler handler)` Adds a handler that will be called if the FontLoader fails to load any of the custom skin fonts.
    `static com.google.gwt.event.shared.HandlerRegistration` | `addFontsLoadedHandler(FontsLoadedHandler handler)` Adds a handler that will be called when the FontLoader finishes loading any custom skin fonts.
    `static boolean` | `isLoadingComplete()` Whether all requested custom fonts have been loaded.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### FontLoader

          public FontLoader()

  - ### Method Detail

    - #### isLoadingComplete

          public static boolean isLoadingComplete()

      Whether all requested custom fonts have been loaded. If this method returns true, you know that the `FontLoader` won't need to redraw any canvii drawn afterwards, and that a `FontsLoadedEvent` or `FontLoadingFailedEvent` won't arrive (it may have previously been handled).
      Returns:
        whether all requested fonts have been loaded

    - #### addFontsLoadedHandler

          public static com.google.gwt.event.shared.HandlerRegistration addFontsLoadedHandler(FontsLoadedHandler handler)

      Adds a handler that will be called when the FontLoader finishes loading any custom skin fonts.
      Parameters:
        `handler` - loading finished handler
      Returns:
        registration

    - #### addFontLoadingFailedHandler

          public static com.google.gwt.event.shared.HandlerRegistration addFontLoadingFailedHandler(FontLoadingFailedHandler handler)

      Adds a handler that will be called if the FontLoader fails to load any of the custom skin fonts.
      Parameters:
        `handler` - loading failed handler
      Returns:
        registration