Class FontLoader
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
-
Method Summary
Modifier and TypeMethodDescriptionstatic HandlerRegistration
Adds a handler that will be called if the FontLoader fails to load any of the custom skin fonts.static HandlerRegistration
addFontsLoadedHandler
(FontsLoadedHandler handler) Adds a handler that will be called when the FontLoader finishes loading any custom skin fonts.static boolean
Whether all requested custom fonts have been loaded.
-
Constructor Details
-
FontLoader
public FontLoader()
-
-
Method Details
-
isLoadingComplete
public static boolean isLoadingComplete()Whether all requested custom fonts have been loaded. If this method returns true, you know that theFontLoader
won't need to redraw any canvii drawn afterwards, and that aFontsLoadedEvent
orFontLoadingFailedEvent
won't arrive (it may have previously been handled).- Returns:
- whether all requested fonts have been loaded
-
addFontsLoadedHandler
Adds a handler that will be called when the FontLoader finishes loading any custom skin fonts.- Parameters:
handler
- loading finished handler- Returns:
- registration
-
addFontLoadingFailedHandler
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
-