Font

Various helpers for working with fonts from script.

Functions

void dumpFontCacheStatus()

Dumps to the console a full description of all cached fonts, along with info on the codepoints each contains.

void duplicateCachedFont(string oldFontName, int oldFontSize, string newFontName)

Copy the specified old font to a new name. The new copy will not have a platform font backing it, and so will never have characters added to it. But this is useful for making copies of fonts to add postprocessing effects to via exportCachedFont.

Parameters:
  • oldFontName – The name of the font face to copy.
  • oldFontSize – The size of the font to copy.
  • newFontName – The name of the new font face.
void exportCachedFont(string faceName, int fontSize, string fileName, int padding, int kerning)

Export specified font to the specified filename as a PNG. The image can then be processed in Photoshop or another tool and reimported using importCachedFont. Characters in the font are exported as one long strip.

Parameters:
  • faceName – The name of the font face.
  • fontSize – The size of the font in pixels.
  • fileName – The file name and path for the output PNG.
  • padding – The padding between characters.
  • kerning – The kerning between characters.
void importCachedFont(string faceName, int fontSize, string fileName, int padding, int kerning)

Import an image strip from exportCachedFont. Call with the same parameters you called exportCachedFont.

Parameters:
  • faceName – The name of the font face.
  • fontSize – The size of the font in pixels.
  • fileName – The file name and path for the input PNG.
  • padding – The padding between characters.
  • kerning – The kerning between characters.
void populateAllFontCacheRange(int rangeStart, int rangeEnd)

Populate the font cache for all fonts with Unicode code points in the specified range.

Parameters:
  • rangeStart – The start Unicode point.
  • rangeEnd – The end Unicode point.
void populateAllFontCacheString(string string)

Populate the font cache for all fonts with characters from the specified string.

void populateFontCacheRange(string faceName, int fontSize, int rangeStart, int rangeEnd)

Populate the font cache for the specified font with Unicode code points in the specified range.

Parameters:
  • faceName – The name of the font face.
  • fontSize – The size of the font in pixels.
  • rangeStart – The start Unicode point.
  • rangeEnd – The end Unicode point.
void populateFontCacheString(string faceName, int fontSize, string string)

Populate the font cache for the specified font with characters from the specified string.

Parameters:
  • faceName – The name of the font face.
  • fontSize – The size of the font in pixels.
  • string – The string to populate.
void writeFontCache()

Force all cached fonts to serialize themselves to the cache.