Class Font

Instance of font with specific size, weight, face, etc.

class Font
  : RefCountedObject;

Allows to measure text string and draw it on DrawBuf

Use FontManager.instance.getFont() to retrieve font instance.

Constructors

NameDescription
this ()

Fields

NameTypeDescription
_allowKerning bool
_spaceWidth int
_textSizeBuffer int[]Buffer to reuse while measuring strings to avoid GC
_refCount intcount of references to this object from Ref

Properties

NameTypeDescription
allowKerning[get, set] booloverride to enable kerning support
antialiased[get] boolreturn true if antialiasing is enabled, false if not enabled
baseline[get] intreturns baseline offset
face[get] stringreturns font face name
family[get] FontFamilyreturns font family
height[get] intreturns actual font height including interline space
isFixed[get] boolreturns true if font has fixed pitch (all characters have equal width)
isNull[get] boolreturns true if font object is not yet initialized / loaded
italic[get] boolreturns true if font is italic
size[get] intreturns font size (as requested from font engine)
spaceWidth[get] intreturns true if font is fixed
weight[get] intreturns font weight
refCount[get] intreturns current value of reference counter

Methods

NameDescription
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

NameDescription
textSizeMemoized
~this