Class Font
Instance of font with specific size, weight, face, etc.
Allows to measure text string and draw it on DrawBuf
Use FontManager.instance.getFont() to retrieve font instance.
Constructors
| Name | Description |
|---|---|
this
()
|
Fields
| Name | Type | Description |
|---|---|---|
_allowKerning
|
bool | |
_spaceWidth
|
int | |
_textSizeBuffer
|
int[] | Buffer to reuse while measuring strings to avoid GC |
_refCount
|
int | count of references to this object from Ref |
Properties
| Name | Type | Description |
|---|---|---|
allowKerning[get, set]
|
bool | override to enable kerning support |
antialiased[get]
|
bool | return true if antialiasing is enabled, false if not enabled |
baseline[get]
|
int | returns baseline offset |
face[get]
|
string | returns font face name |
family[get]
|
FontFamily | returns font family |
height[get]
|
int | returns actual font height including interline space |
isFixed[get]
|
bool | returns true if font has fixed pitch (all characters have equal width) |
isNull[get]
|
bool | returns true if font object is not yet initialized / loaded |
italic[get]
|
bool | returns true if font is italic |
size[get]
|
int | returns font size (as requested from font engine) |
spaceWidth[get]
|
int | returns true if font is fixed |
weight[get]
|
int | returns font weight |
refCount[get]
|
int | returns current value of reference counter |
Methods
| Name | Description |
|---|---|
charWidth
(ch)
|
returns character width |
checkpoint
()
|
clear usage flags for all entries |
cleanup
()
|
removes entries not used after last call of checkpoint() or cleanup() |
clear
()
|
|
clearGlyphCache
()
|
clears glyph cache |
drawMultilineText
(buf, x, y, text, color, maxLines, maxWidth, tabSize, tabOffset, textFlags)
|
draws multiline text with line splitting |
drawStyledText
(buf, x, y, text, charProps, tabSize, tabOffset, textFlags)
|
Draw text string to buffer. |
drawText
(buf, x, y, text, color, tabSize, tabOffset, textFlags)
|
Draw text string to buffer. |
getCharGlyph
(ch, withImage)
|
get character glyph information |
getKerningOffset
(prevChar, currentChar)
|
override to implement kerning offset calculation |
measureMultilineText
(text, maxLines, maxWidth, tabSize, tabOffset, textFlags)
|
measure multiline text with line splitting, returns width and height in pixels |
measureText
(text, widths, maxWidth, tabSize, tabOffset, textFlags)
|
Measure text string, return accumulated widths[] (distance to end of n-th character), returns number of measured chars. |
textSize
(text, maxWidth, tabSize, tabOffset, textFlags)
|
Measure text string as single line, returns width and height |
textSizeImpl
(font, text, maxWidth, tabSize, tabOffset, textFlags)
|
|
addRef
()
|
increments reference counter |
releaseRef
()
|
decrement reference counter, destroy object if no more references left |
Aliases
| Name | Description |
|---|---|
textSizeMemoized
|
|
~this
|