fontutils

Utility functions for working with font resources
FontUtils.findMatchingFamily( families, [defaultFamily] ) static
FontUtils.availableFontFamilies() static
FontUtils.registerFontFamily( key ) static
FontUtils.registerFontFamilyFromResources( [resourceFile...] ) static

Utility functions for working with font resources

Note: A development version of this library defined utility functions in the global namespace. These functions are still defined by this library, but they have been deprecated. Use the versions in FontUtils instead.

FontUtils.findMatchingFamily( families, [defaultFamily] ) static

Returns a font family name that is available on this system. The method for selecting a font is similar to that used by CSS and HTML: The string families is a list of candidate font families separated by commas, and this function returns the first available entry. For example, findMatchingFontFamily( "Bookman Old Style,Times" ) would return Bookman Old Style if that family was available. If not then it would return Times if that family was available. If none of the typefaces in families is available, then defaultFamily is returned (which may be null).

families a string listing candidate families
defaultFamily the value returnes if none of the families matches (default is FAMILY_SANS_SERIF)

The family returned is the first one the first typeface family name in the comma separated list families that is available on this system.

FontUtils.availableFontFamilies() static

Returns a list of the available font families on this system. This will include fonts that have been successfully registered with FontUtils.registerFontFamily or FontUtils.registerFontFamilyFromResources.

FontUtils.registerFontFamily( key ) static

Create a typeface family by creating fonts from font files. The files are found by looking up the setting key, just as with the standard font family keys (body-font, title-font, etc.). As with the standard family keys, the setting value should be a list of font file resources and the plain family member should be listed first. TrueType and PostScript Type 1 fonts are supported; resource file names that end in .ttf are assumed to be TrueType and other files are assumed to be Type 1.

key the setting key containing the list of font files

returns the font family name of the registered family

FontUtils.registerFontFamilyFromResources( [resourceFile...] ) static

Create a typeface family directly from a list of resources instead of reading a list from a key.

resourceFile one or more arguments denoting font file resources

returns the font family name of the registered family

Index    Contents