Kōtuku
  • Gallery
  • API
  • Wiki
  • GitHub
    • Audio
    • Config
    • Core
    • Display
    • Document
    • Font
    • HTTP
    • Network
    • Regex
    • SVG
    • Tiri
    • Vector
    • XML
    • XQuery
    • XRandR
      • Audio
      • MP3
      • Sound
      • File
      • MetaClass
      • Module
      • StorageDevice
      • Task
      • Thread
      • Time
      • Compression
      • CompressedStream
      • Config
      • LZMAStream
      • Script
      • Tiri
      • XML
      • XQuery
      • Controller
      • BlurFX
      • ColourFX
      • CompositeFX
      • ConvolveFX
      • DisplacementFX
      • FilterEffect
      • FloodFX
      • ImageFX
      • LightingFX
      • MergeFX
      • MorphologyFX
      • OffsetFX
      • RemapFX
      • SourceFX
      • TurbulenceFX
      • WaveFunctionFX
      • Scintilla
      • Bitmap
      • Clipboard
      • Display
      • Document
      • Font
      • Image
      • Pointer
      • Surface
      • SVG
      • ClientSocket
      • HTTP
      • NetClient
      • NetLookup
      • NetServer
      • NetSocket
      • Proxy
      • Gradient
      • GradientConic
      • GradientContour
      • GradientDiamond
      • GradientDiffusion
      • GradientDistal
      • GradientGouraud
      • GradientLinear
      • GradientMesh
      • GradientRadial
      • GradientVoronoi
      • Vector
      • VectorClip
      • VectorColour
      • VectorEllipse
      • VectorFilter
      • VectorGradient
      • VectorGroup
      • VectorImage
      • VectorPath
      • VectorPattern
      • VectorPolygon
      • VectorRectangle
      • VectorScene
      • VectorShape
      • VectorSpiral
      • VectorText
      • VectorTransition
      • VectorViewport
      • VectorWave
      • Linux Builds
      • Windows Builds
      • Customising Your Build
      • Kōtuku Objects
      • Kōtuku In Depth
      • Kōtuku Design Patterns
      • Coding With AI
      • Regex Manual
      • XML Comparisons
      • Tiri Reference Manual
      • Config API
      • Defer Syntax
      • GUI API
      • HTTP Server API
      • I/O API
      • JSON API
      • OAuth API
      • Options API
      • Proxy Server API
      • Tempus API
      • URL API
      • VFX API
      • Widgets
      • RIPL Reference Manual
      • Origo
      • Flute / Unit Testing
      • Tuku
      • Embedded Document Format
      • TDL Reference Manual
      • TDL Tools
      • Action Reference Manual
      • System Error Codes

Font Class

Draws bitmap fonts and manages font meta information.

The Font class renders fixed-size bitmap fonts to a Bitmap and exposes metrics for the selected font face. It supports bold, italic and underlined text, as well as adjustable glyph spacing, line spacing, tab width and alignment. Bitmap fonts are loaded from Windows .fon files. Scalable TrueType rendering is provided by VectorText instead.

Bitmap fonts must be stored in the fonts:fixed/ directory to be recognised during font database refreshes. Use the Font module's query and refresh functions to inspect or rebuild the installed font list.

Font strings are interpreted as UTF-8, allowing Unicode text to be supplied through the String field. Do not insert arbitrary byte values above 127 unless they are valid UTF-8 sequences. Invalid or unsupported glyphs fall back to the font's default character.

Initialisation of a new Font object can be as simple as declaring its Point size and Face name. Font face, size and style selections should be set before initialisation because the loaded bitmap data is cached for that combination. To use multiple styles of the same face, create one Font object for each required style. Runtime drawing properties such as colour, String, X, Y and alignment can still be changed between draw operations.

To draw a string, set Bitmap and String, then call Draw(). The X and Y fields set the starting position. Use Align together with AlignWidth and AlignHeight when text needs to be positioned within a larger surface area.

This documentation uses the following font terminology:

  • Point is the requested size of the font. It is relative to other point sizes of the same face; two faces at the same point size are not necessarily the same pixel height.
  • Height is the vertical bearing of the font expressed in pixels. It excludes top leading and the gutter used by descending glyphs.
  • Gutter is the space below the baseline used by descending glyphs such as g and y. It is also known as the external leading or descent.
  • LineSpacing is the recommended pixel distance from one baseline to the next.
  • Glyph is a single rendered character image.

Use VectorText for most display text. The Font class draws directly to a Bitmap and is not integrated with the display vector scene graph.

Structure

The Font class consists of the following fields:

Access
NameTypeComment
 AlignALIGNSets the position of a font string to an abstract alignment.

Sets the alignment of the font string within the AlignWidth and AlignHeight area. This is used in addition to the X and Y drawing coordinates.

NameDescription
ALIGN::BOTTOMAlign to bottom
ALIGN::CENTERSynonym for HORIZONTAL | VERTICAL
ALIGN::HORIZONTALAlign to horizontal center
ALIGN::LEFTAlign to left
ALIGN::MIDDLESynonym for HORIZONTAL | VERTICAL
ALIGN::RIGHTAlign to right
ALIGN::TOPAlign to top
ALIGN::VERTICALAlign to vertical center
 AlignHeightINTThe height to use when aligning the font string.

Defines the height of the area used for vertical alignment. If this field is 0, the target Bitmap height is used.

 AlignWidthINTThe width to use when aligning the font string.

Defines the width of the area used for horizontal alignment. If this field is 0, the target Bitmap width is used.

 AscentINTThe total number of pixels above the baseline.

Reflects the total number of pixels above the baseline, including Leading.

 Bitmap*BitmapThe destination Bitmap to use when drawing a font.
 BoldINTSet to true to enable bold styling.

Setting this field before initialisation selects the Bold style, or Bold Italic if Italic is also set. Prefer Style when setting an exact style name.

 ColourRGB8The font colour in RGB8 format.
 EndXINTIndicates the final horizontal coordinate after completing a draw operation.

Reflects the final horizontal coordinate reached by the most recent Draw() operation.

 EndYINTIndicates the final vertical coordinate after completing a draw operation.

Reflects the final vertical coordinate reached by the most recent Draw() operation.

 FaceSTRINGThe name of a font face that is to be loaded on initialisation.

The name of an installed font face must be specified before initialisation unless Path is set directly. A list of available faces can be obtained from GetList().

Multiple font faces can be specified in CSV format, e.g. Sans Serif,Noto Sans. Names are resolved from left to right.

 FixedWidthINTForces a fixed pixel width to use for all glyphs.

Forces all glyphs to advance by the specified pixel width. If the value is less than the widest glyph, rendered glyphs can overlap.

 FlagsFTFOptional flags.
NameDescription
FTF::BASE_LINEThe Font's Y coordinate is the base line.
FTF::BOLDFont is described as having a bold weight (read only).
FTF::HEAVY_LINEUnderline the font with a double-sized line, using the colour defined in Underline.
FTF::ITALICFont is described as using italics (read only).
 GlyphSpacingDOUBLEAdjusts the amount of spacing between each character.

Adjusts horizontal glyph advance as a multiplier of each glyph's normal width. The default value is 1.0.

Using negative values is valid, and can lead to text being printed backwards.

 GutterINTThe 'external leading' value, measured in pixels. Applies to fixed fonts only.

Reflects the external leading, or descent area, below the baseline.

 HeightINTThe point size of the font, expressed in pixels.

Reflects the initialised font height in pixels. It does not include Leading; use Ascent when the leading-inclusive distance above the baseline is required.

The height is calculated on initialisation and can be read at any time.

 ItalicINTSet to true to enable italic styling.

Setting this field before initialisation selects the Italic style, or Bold Italic if Bold is also set. Prefer Style when setting an exact style name.

 LeadingINT'Internal leading' measured in pixels. Applies to fixed fonts only.
 LineCountINTThe total number of lines in a font string.

Returns the number of lines in String. If WrapEdge is set, wrapped lines are included in the count.

 LineSpacingINTThe amount of spacing between each line.

Defines the vertical distance from one line baseline to the next. It is initialised from the selected font and can be increased or decreased to adjust line spacing. If negative, later lines are drawn upward.

If set before initialisation, the value is added to the font's normal line spacing instead of replacing it. For instance, setting the LineSpacing to 2 will result in an extra 2 pixels being added to the font's spacing.

 MaxHeightINTThe maximum possible pixel height per character.

Reflects the maximum bitmap height for the selected font at the current point size.

 OpacityDOUBLEDetermines the level of translucency applied to a font.

Determines the translucency level of the font fill colour. The default setting is 100, meaning fully opaque. Lower values blend the glyphs with the destination Bitmap.

Please note that the use of translucency will always have an impact on the time it normally takes to draw a font.

 OutlineRGB8Defines the outline colour around a font.

Draws a one-pixel outline around bitmap glyphs when set to an RGB8 colour with a non-zero alpha component. Set the field to NULL or use an alpha value of zero to disable outlining.

 PathSTRINGThe path to a font file.

Defines the exact font file to load before initialisation. This bypasses normal face-name resolution through the font database.

This feature is ideal for use when distributing custom fonts with an application.

 PointDOUBLEThe point size of a font.

Defines the requested font size in points.

When setting the point size of a bitmap font, the system will try and find the closest matching value for the requested point size. For instance, if you request a fixed font at point 11 and the closest size is point 8, the system will drop the font to point 8.

 StringSTRINGThe string to use when drawing a Font.

The String field must be defined to draw text with a Font object. It must contain valid UTF-8. Line feed characters start a new line during Draw().

If a string contains characters that are not supported by a font, those characters will be printed using a default character from the font.

 StyleSTRINGDetermines font styling.

Selects the preferred style for initialisation. If the selected face does not provide that style, regular styling or the first registered style is used.

Bitmap fonts are a special case if a bold or italic style is selected. In this situation the system can automatically convert the font to that style even if the correct graphics set does not exist.

Conventional font styles are Bold, Bold Italic, Italic and Regular (the default).

 TabSizeINTDefines the tab size to use when drawing and manipulating a font string.

Controls the tab interval, measured in character columns.

The default tab size is 8. This field only affects tab characters in String.

 UnderlineRGB8Enables font underlining when set.

Draws an underline using the supplied RGB8 colour. Set the field to NULL or use an alpha value of zero to disable underlining.

 WidthINTReturns the pixel width of a string.

Returns the pixel width of String using the current font metrics and wrapping settings. If String is empty, the result is 0.

 WrapEdgeINTEnables word wrapping at a given boundary.

Enables word wrapping when set to a value greater than zero. Wrapping occurs when a word extends beyond this X coordinate.

 XINTThe starting horizontal position when drawing the font string.

Defines the starting horizontal coordinate for Draw(). The default coordinate is 0.

 YINTThe starting vertical position when drawing the font string.

Defines the starting vertical coordinate for Draw(). The default coordinate is 0.

 YOffsetINTAdditional offset value that is added to vertically aligned fonts.

Returns the vertical offset applied by VERTICAL or BOTTOM alignment. Add this value to Y to determine the aligned drawing baseline.

Actions

The following actions are currently supported:

DrawDraws a font to a Bitmap.
ERR acDraw(*Object, DOUBLE X, DOUBLE Y, DOUBLE Width, DOUBLE Height)
ParameterDescription
XThe X position of the region to be drawn.
YThe Y position of the region to be drawn.
WidthThe width of the region to be drawn.
HeightThe height of the region to be drawn.

Draws String to the target Bitmap, starting at X and Y after any configured alignment and baseline adjustments have been applied.

Error Codes
OkayOperation successful.
FieldNotSetThe Bitmap field has not been set.
Font class documentation © Paul Manias © 1998-2026

ALIGN Type

Universal values for alignment of graphics and text

NameDescription
ALIGN::BOTTOMAlign to bottom
ALIGN::CENTERSynonym for HORIZONTAL | VERTICAL
ALIGN::HORIZONTALAlign to horizontal center
ALIGN::LEFTAlign to left
ALIGN::MIDDLESynonym for HORIZONTAL | VERTICAL
ALIGN::RIGHTAlign to right
ALIGN::TOPAlign to top
ALIGN::VERTICALAlign to vertical center
Font module documentation © Paul Manias © 1998-2026

FTF Type

Font flags

NameDescription
FTF::BASE_LINEThe Font's Y coordinate is the base line.
FTF::BOLDFont is described as having a bold weight (read only).
FTF::HEAVY_LINEUnderline the font with a double-sized line, using the colour defined in Underline.
FTF::ITALICFont is described as using italics (read only).
Font module documentation © Paul Manias © 1998-2026

RGB8 Structure

8-bit RGB colour value.

FieldTypeDescription
RedUINT8Red component value
GreenUINT8Green component value
BlueUINT8Blue component value
AlphaUINT8Alpha component value
Font class documentation © Paul Manias © 1998-2026