TorqueScript Reference

Functions

void clearUncachedFonts ()
void dumpFontCacheStatus ()
void duplicateCachedFont (oldFontName, oldFontSize, newFontName)
void exportCachedFont (fontName, size, fileName, padding, kerning)
String getInstalledFonts ()
String getUncachedFonts ()
void importCachedFont (fontName, size, fileName, padding, kerning)
void populateAllFontCacheRange (rangeStart, rangeEnd)
void populateAllFontCacheString (string inString)
void populateFontCacheRange (faceName, size, rangeStart, rangeEnd)
void populateFontCacheString (faceName, size, string)
void writeFontCache ()
Boolean writeOneFontCache (faceName, size)
void writeSingleFontCache (fontName)

Detailed Description

Function Documentation

◆ clearUncachedFonts()

void clearUncachedFonts ( )

Forget every recorded font cache miss. Called after baking, so the next report lists only what has come up since.

Returns
No return value.

◆ dumpFontCacheStatus()

void dumpFontCacheStatus ( )

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

Returns
No return value

◆ duplicateCachedFont()

void duplicateCachedFont ( oldFontName ,
oldFontSize ,
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
oldFontNameThe original font.
oldFontSizeThe original font's size property.
newFontNameThe name to set the copy to.
Returns
No return value.

◆ exportCachedFont()

void exportCachedFont ( fontName ,
size ,
fileName ,
padding ,
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
fontNameThe name of the font to export.
sizeThe size of the font
fileNameThe export file name.
paddingDesired padding settings.
kerningKerning settings (space between elements)
Returns
No return value.

◆ getInstalledFonts()

String getInstalledFonts ( )

List the font faces installed on this machine. These are the faces the platform can rasterize without any cache on disk – what a tool offers the user to choose from. Sorted and de-duplicated here rather than in script: Windows enumerates a family once per character set, and sorting a few hundred names in TorqueScript is not free. Platforms with no font enumeration (iOS, Android, the web build) return an empty string, so a caller should treat the list as an offer, not the whole truth – a face can still be usable through a cached .uft it finds on disk.

Returns
A tab-separated list of face names.

◆ getUncachedFonts()

String getUncachedFonts ( )

List the face/size pairs that had to be rasterized because no cache existed. A tool bakes exactly these: the face is installed here, so it can be written, but a machine without it would have nothing to fall back on. The list covers sizes no field declares – a control's fontSizeAdjust multiplies its profile's fontSize – which is why it is recorded as it happens rather than derived. Each row also carries the font directory that was searched, so a caller can keep one project's caches out of another's folder.

Returns
Newline-separated rows of "face<tab>size<tab>directory".

◆ importCachedFont()

void importCachedFont ( fontName ,
size ,
fileName ,
padding ,
kerning  )

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

Parameters
fontNameThe name of the font to import.
sizeThe size of the font
fileNameThe imported file name.
paddingDesired padding settings.
kerningKerning settings (space between elements)
Returns
No return value.

◆ populateAllFontCacheRange()

void populateAllFontCacheRange ( rangeStart ,
rangeEnd  )

Populate the font cache for all fonts with Unicode code points in the specified range. Note we only support BMP-0, so code points range from 0 to 65535.

Parameters
rangeStart,rangeEndThe range of the unicode points to populate caches with
Returns
No return value

◆ populateAllFontCacheString()

void populateAllFontCacheString ( string inString)

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

Parameters
inStringThe string to use to set the font caches
Returns
No return value.

◆ populateFontCacheRange()

void populateFontCacheRange ( faceName ,
size ,
rangeStart ,
rangeEnd  )

Populate the font cache for the specified font with Unicode code points in the specified range. Note we only support BMP-0, so code points range from 0 to 65535.

Parameters
faceNameThe name of the font
sizeThe size of the font.
rangeStartThe initial Unicode point
rangeEndThe final Unicode point in range
Returns
No return value

◆ populateFontCacheString()

void populateFontCacheString ( faceName ,
size ,
string  )

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

Parameters
faceNameThe font's name
sizeThe size of the font.
stringThe string to use to fill font cache
Returns
No return value.

◆ writeFontCache()

void writeFontCache ( )

force all cached fonts to serialize themselves to the cache.

Returns
No return value

◆ writeOneFontCache()

Boolean writeOneFontCache ( faceName ,
size  )

Write one font's cache file to disk. The other two writers are broad: writeFontCache() serializes every cached font, and writeSingleFontCache() scans the project for *.uft and rewrites each one whose path contains the face name. This one touches exactly the face and size asked for, which is what a tool wants after populating a single font – the scanning version costs the same second and a half however little changed, and gets slower as caches accumulate. The cache path comes from GFont::getFontCacheFilename, so it lands under $GUI::fontCacheDirectory – the same place populateFontCacheRange reads from.

Parameters
faceNameThe name of the font.
sizeThe size of the font.
Returns
True if the cache was written.

◆ writeSingleFontCache()

void writeSingleFontCache ( fontName )

Force all cached fonts with a given font name in their paths to serialize themselves to the cache.

Parameters
fontNameThe name of the font to search for in the path. Will save if found.
Returns
No return value