Hatch Game Engine Documentation v1.4.0
The documentation for the Hatch Game Engine
Loading...
Searching...
No Matches
Font Class Reference

Representation of a TrueType font. More...

Public Member Functions

decimal GetPixelsPerUnit ()
 Gets the pixels per unit value of the font. The default for all fonts is 40.
decimal GetAscent ()
 Gets the distance in pixels above the baseline.
decimal GetDescent ()
 Gets the distance in pixels below the baseline.
decimal GetLeading ()
 Gets the distance between lines in pixels.
decimal GetSpaceWidth ()
 Gets the width of the space character.
integer GetOversampling ()
 Gets the oversampling value. The default is 1 for all fonts.
decimal GetPixelCoverageThreshold ()
 Gets the pixel coverage threshold value. Pixels with coverage under this value become fully transparent, and pixels with coverage equal to or above this value become fully opaque. The default is 0.5 for all fonts.
decimal GetGlyphAdvance (integer codepoint)
 Gets the advance width of a given glyph through its code point, if it exists in the font.
boolean IsAntialiasingEnabled ()
 Gets whether the font has anti-aliasing enabled.
boolean HasGlyph (integer codepoint)
 Checks if the font has a glyph for the given code point.
void SetPixelsPerUnit (number pixelsPerUnit)
 Sets the pixels per unit value of the font. Higher values improve the clarity, at the cost of increased memory usage. Note that this causes all glyphs to be reloaded, so this should usually only be called once.
void SetAscent (number ascent)
 Sets the distance in pixels above the baseline.
void SetDescent (number descent)
 Sets the distance in pixels below the baseline.
void SetLeading (number leading)
 Sets the distance between lines in pixels.
void SetSpaceWidth (number spaceWidth)
 Sets the width of the space character.
void SetOversampling (integer oversampling)
 Sets the oversampling value. Higher values increase font quality. Changing this value causes all font glyphs to be reloaded.
void SetPixelCoverageThreshold (decimal threshold)
 Sets the pixel coverage threshold value. Pixels with coverage under this value become fully transparent, and pixels with coverage equal to or above this value become fully opaque. This only has an effect on fonts with anti-aliasing disabled.
void SetAntialiasing (boolean useAntialiasing)
 Enables or disables anti-aliasing on the font. If disabling, you may want to increase the pixel coverage value with Font.SetPixelCoverageThreshold.
 Font (string font)
 Loads a font from the given resource path.
 Font (stream font)
 Loads a font from the given stream.
 Font (array font)
 Loads a font from the given array containing resource paths or streams.

Detailed Description

Representation of a TrueType font.

Constructor & Destructor Documentation

◆ Font() [1/3]

Font.Font ( string font)

Loads a font from the given resource path.

Parameters
fontThe font. If this argument is not given, it will use font the application was built with, if one is present.

◆ Font() [2/3]

Font.Font ( stream font)

Loads a font from the given stream.

Parameters
fontThe font. If this argument is not given, it will use font the application was built with, if one is present.

◆ Font() [3/3]

Font.Font ( array font)

Loads a font from the given array containing resource paths or streams.

Parameters
fontThe list of fonts. If this argument is not given, it will use font the application was built with, if one is present.

Member Function Documentation

◆ GetAscent()

decimal Font.GetAscent ( )

Gets the distance in pixels above the baseline.

Returns
Returns a decimal value.

◆ GetDescent()

decimal Font.GetDescent ( )

Gets the distance in pixels below the baseline.

Returns
Returns a decimal value.

◆ GetGlyphAdvance()

decimal Font.GetGlyphAdvance ( integer codepoint)

Gets the advance width of a given glyph through its code point, if it exists in the font.

Parameters
codepointAn Unicode code point.
Returns
Returns a decimal value, or null if no glyph representing the given code point exists in the font.

◆ GetLeading()

decimal Font.GetLeading ( )

Gets the distance between lines in pixels.

Returns
Returns a decimal value.

◆ GetOversampling()

integer Font.GetOversampling ( )

Gets the oversampling value. The default is 1 for all fonts.

Returns
Returns an integer value.

◆ GetPixelCoverageThreshold()

decimal Font.GetPixelCoverageThreshold ( )

Gets the pixel coverage threshold value. Pixels with coverage under this value become fully transparent, and pixels with coverage equal to or above this value become fully opaque. The default is 0.5 for all fonts.

Returns
Returns a decimal value.

◆ GetPixelsPerUnit()

decimal Font.GetPixelsPerUnit ( )

Gets the pixels per unit value of the font. The default for all fonts is 40.

Returns
Returns a decimal value.

◆ GetSpaceWidth()

decimal Font.GetSpaceWidth ( )

Gets the width of the space character.

Returns
Returns a decimal value.

◆ HasGlyph()

boolean Font.HasGlyph ( integer codepoint)

Checks if the font has a glyph for the given code point.

Parameters
codepointAn Unicode code point.
Returns
Returns whether there is a glyph for the given code point.

◆ IsAntialiasingEnabled()

boolean Font.IsAntialiasingEnabled ( )

Gets whether the font has anti-aliasing enabled.

Returns
Returns whether anti-aliasing is enabled.

◆ SetAntialiasing()

void Font.SetAntialiasing ( boolean useAntialiasing)

Enables or disables anti-aliasing on the font. If disabling, you may want to increase the pixel coverage value with Font.SetPixelCoverageThreshold.

Parameters
useAntialiasingWhether or not to use anti-aliasing.

◆ SetAscent()

void Font.SetAscent ( number ascent)

Sets the distance in pixels above the baseline.

Parameters
ascentThe distance.

◆ SetDescent()

void Font.SetDescent ( number descent)

Sets the distance in pixels below the baseline.

Parameters
descentThe distance.

◆ SetLeading()

void Font.SetLeading ( number leading)

Sets the distance between lines in pixels.

Parameters
leadingThe distance.

◆ SetOversampling()

void Font.SetOversampling ( integer oversampling)

Sets the oversampling value. Higher values increase font quality. Changing this value causes all font glyphs to be reloaded.

Parameters
oversamplingThe oversampling value.

◆ SetPixelCoverageThreshold()

void Font.SetPixelCoverageThreshold ( decimal threshold)

Sets the pixel coverage threshold value. Pixels with coverage under this value become fully transparent, and pixels with coverage equal to or above this value become fully opaque. This only has an effect on fonts with anti-aliasing disabled.

Parameters
thresholdThe threshold value, from 0.0 to 1.0.

◆ SetPixelsPerUnit()

void Font.SetPixelsPerUnit ( number pixelsPerUnit)

Sets the pixels per unit value of the font. Higher values improve the clarity, at the cost of increased memory usage. Note that this causes all glyphs to be reloaded, so this should usually only be called once.

Parameters
pixelsPerUnitThe pixels per unit value.

◆ SetSpaceWidth()

void Font.SetSpaceWidth ( number spaceWidth)

Sets the width of the space character.

Parameters
spaceWidthThe width.