public 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
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.
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
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
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 and Description
|Modifier and Type
|Method and Description
Adds a handler that will be called if the FontLoader fails to load any of the custom skin fonts.
Adds a handler that will be called when the FontLoader finishes loading any custom skin fonts.
Whether all requested custom fonts have been loaded.
public static boolean isLoadingComplete()
FontLoader won't need to redraw any canvii drawn afterwards, and that a
won't arrive (it may have previously been handled).
public static com.google.gwt.event.shared.HandlerRegistration addFontsLoadedHandler(FontsLoadedHandler handler)
handler - loading finished handler
public static com.google.gwt.event.shared.HandlerRegistration addFontLoadingFailedHandler(FontLoadingFailedHandler handler)
handler - loading failed handler