An instance of a text font.
Heaps comes with a default Font that covers basic ASCII characters, and can be retrieved via hxd.res.DefaultFont.get()
.
Variables
read onlybaseLine:Float
The baseline value of the font represents the base on which characters will sit.
Used primarily with HtmlText
to sit multiple fonts and images at the same line.
charset:Charset
Font charset allows to resolve specific char codes that are not directly present in glyph map as well as detect spaces.
Defaults to hxd.Charset.getDefault()
.
read onlyname:String
The font name. Assigned on font creation and can be used to identify font instances.
read onlytilePath:String
The resource path of the source Tile. Either relative to .fnt or to resources root.
type:FontType
The font type. BitmapFonts rendered as-is, but SDF fonts will use an extra shader to produce scalable smooth fonts.
See FontType.SignedDistanceField
for more details.
Methods
inlinegetChar(code:Int):Null<FontChar>
Returns a FontChar
instance corresponding to the code
.
If font char is not present in glyph list, charset.resolveChar
is called.
Returns null
if glyph under specified charcode does not exist.
Parameters:
code | The charcode to search for. |
---|
hasChar(code:Int):Bool
Checks if character is present in glyph list.
Compared to getChar
does not check if it exists through Font.charset
.
Parameters:
code | The charcode to look up. |
---|
resizeTo(size:Int):Void
Resizes the Font instance to specified size.
For BitmapFonts it can be used to create smoother fonts by rasterizing them with double size while still keeping the original glyph size by downscaling the font. And SDF fonts can be resized to arbitrary sizes to produce scalable fonts of any size.
Parameters:
size | The new font size. |
---|