Parasol Framework
  • Gallery
  • API
  • Wiki
  • GitHub
    • Audio
    • Core
    • Display
    • Fluid
    • Font
    • Network
    • Vector
    • Audio
    • Sound
    • File
    • MetaClass
    • Module
    • StorageDevice
    • Task
    • Thread
    • Time
    • Compression
    • Config
    • Script
    • XML
    • Controller
    • BlurFX
    • ColourFX
    • CompositeFX
    • ConvolveFX
    • DisplacementFX
    • FilterEffect
    • FloodFX
    • ImageFX
    • LightingFX
    • MergeFX
    • MorphologyFX
    • OffsetFX
    • RemapFX
    • SourceFX
    • TurbulenceFX
    • WaveFunctionFX
    • Scintilla
    • ScintillaSearch
    • Bitmap
    • Clipboard
    • Display
    • Document
    • Font
    • Picture
    • Pointer
    • Surface
    • SVG
    • ClientSocket
    • HTTP
    • NetSocket
    • Proxy
    • Vector
    • VectorClip
    • VectorColour
    • VectorEllipse
    • VectorFilter
    • VectorGradient
    • VectorGroup
    • VectorImage
    • VectorPath
    • VectorPattern
    • VectorPolygon
    • VectorRectangle
    • VectorScene
    • VectorShape
    • VectorSpiral
    • VectorText
    • VectorTransition
    • VectorViewport
    • VectorWave

Font Class

Draws bitmap fonts and manages font meta information.

The Font class is provided for the purpose of bitmap font rendering and querying font meta information. It supports styles such as bold, italic and underlined text, along with extra features such as adjustable spacing and word alignment. Fixed-point bitmap fonts are supported through the Windows .fon file format. Truetype fonts are not supported (refer to the VectorText class for this feature).

Bitmap fonts must be stored in the fonts:fixed/ directory in order to be recognised. The process of font installation and file management is managed by functions supplied in the Font module.

The Font class includes full support for the unicode character set through its support for UTF-8. This gives you the added benefit of being able to support international character sets with ease, but you must be careful not to use character codes above #127 without being sure that they follow UTF-8 guidelines. Find out more about UTF-8 at this web page.

Initialisation of a new font object can be as simple as declaring its Point size and Face name. Font objects can be difficult to alter post-initialisation, so all style and graphical selections must be defined on creation. For example, it is not possible to change styling from regular to bold format dynamically. To support multiple styles of the same font, create a font object for every style that requires support. Basic settings such as colour, the font string and text positioning are not affected by these limitations.

To draw a font string to a Bitmap object, start by setting the Bitmap and String fields. The X and Y fields determine string positioning and you can also use the Align field to position a string to the right or center of the surface area.

To clarify the terminology used in this documentation, please note the definitions for the following terms:

  • 'Point' determines the size of a font. The value is relative only to other point sizes of the same font face, i.e. two faces at the same point size are not necessarily the same height.
  • 'Height' represents the 'vertical bearing' or point of the font, expressed as a pixel value. The height does not cover for any leading at the top of the font, or the gutter space used for the tails on characters like 'g' and 'y'.
  • 'Gutter' is the amount of space that a character can descend below the base line. Characters like 'g' and 'y' are examples of characters that utilise the gutter space. The gutter is also sometimes known as the 'external leading' or 'descent' of a character.
  • 'LineSpacing' is the recommended pixel distance between each line that is printed with the font.
  • 'Glyph' refers to a single font character.

Please note that in the majority of cases the VectorText class should be used for drawing strings because the Font class is not integrated with the display's 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.

Use this field to set the alignment of a font string within its surface area. This is an abstract means of positioning in comparison to setting the X and Y fields directly.

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.

If the VERTICAL or TOP alignment options are used in the Align field, the AlignHeight should be set so that the alignment of the font string can be correctly calculated. If the AlignHeight is not defined, the target Bitmap's height will be used when computing alignment.

  AlignWidthINTThe width to use when aligning the font string.

If the HORIZONTAL or RIGHT alignment options are used in the Align field, the AlignWidth should be set so that the alignment of the font string can be correctly calculated. If the AlignWidth is not defined, the target Bitmap's width will be used when computing alignment.

  AscentINTThe total number of pixels above the baseline.

The Ascent value reflects the total number of pixels above the baseline, including the Leading value.

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

Setting the Bold field to true prior to initialisation will enable bold styling. This field is provided only for convenience - we recommend that you set the Style field for determining font styling where possible.

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

The EndX and EndY fields reflect the final coordinate of the font String, following the most recent call to the Draw() action.

  EndYINTIndicates the final vertical coordinate after completing a draw operation.

The EndX and EndY fields reflect the final coordinate of the font String, following the most recent call to the Draw() action.

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

The name of an installed font face must be specified here for initialisation. If this field is undefined then the initialisation process will use the user's preferred face. A list of available faces can be obtained from the GetList() function.

For convenience, the face string can also be extended with extra parameters so that the point size and style are defined at the same time. Extra parameters are delimited with the colon character and must follow a set order defined as face:pointsize:style:colour.

Here are some examples:

Noto Sans:12:Bold Italic:#ff0000
Courier:10.6
Charter:120%::255,128,255

Multiple font faces can be specified in CSV format, e.g. Sans Serif,Noto Sans, which allows the closest matching font to be selected if the first face is unavailable or unable to match the requested point size.

  FixedWidthINTForces a fixed pixel width to use for all glyphs.

The FixedWidth value imposes a preset pixel width for all glyphs in the font. It is important to note that if the fixed width value is less than the widest glyph, the glyphs will overlap each other.

  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.

This field adjusts the horizontal spacing between each glyph, technically known as kerning between each font character. The value is expressed as a multiplier of the width of each character, and defaults to 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.

This field reflects the 'external leading' value (also known as the 'gutter'), measured in pixels.

  HeightINTThe point size of the font, expressed in pixels.

The point size of the font is expressed in this field as a pixel measurement. It does not not include the leading value (refer to Ascent if leading is required).

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

  ItalicINTSet to true to enable italic styling.

Setting the Italic field to true prior to initialisation will enable italic styling. This field is provided for convenience only - we recommend that you set the Style field for determining font styling where possible.

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

This field indicates the number of lines that are present in a #font's String field. If word wrapping is enabled, this will be taken into account in the resulting figure.

  LineSpacingINTThe amount of spacing between each line.

This field defines the amount of space between each line that is printed with a font object. It is set automatically during initialisation to reflect the recommended distance between each line. The client can increase or decrease this value to make finer adjustments to the line spacing. If negative, the text will be printed in a reverse vertical direction with each new line.

If set prior to initialisation, the value will be added to the font's normal line-spacing instead of over-riding 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.

This field reflects the maximum possible pixel height per character, covering the entire character set at the current point size.

  OpacityDOUBLEDetermines the level of translucency applied to a font.

This field determines the translucency level of a font graphic. The default setting is 100%, which means that the font will not be translucent. Any other value set here will alter the impact of a font's graphic over the destination Bitmap. High values will retain the boldness of the font, while low values can render it close to invisible.

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.

An outline can be drawn around a font by setting the Outline field to an RGB8 colour. The outline can be turned off by writing this field with a NULL value or setting the alpha component to zero. Outlining is currently supported for bitmap fonts only.

  PathSTRINGThe path to a font file.

This field can be defined prior to initialisation. It can be used to refer to the exact location of a font data file, in opposition to the normal practice of loading fonts that are installed on the host system.

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

  PointDOUBLEThe point size of a font.

The point size defines the size of a font in point units, at a ratio of 1:72 DPI.

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 in order to draw text with a font object. A string must consist of a valid sequence of UTF-8 characters. Line feeds are allowed (whenever a line feed is reached, the Draw() action will start printing on the next line). Drawing will stop when the null termination character is reached.

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.

The style of a font can be selected by setting the Style field. This comes into effect only if the font actually supports the specified style as part of its graphics set. If the style is unsupported, the regular styling of the face will be used on initialisation.

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.

The TabSize value controls the interval between tabs, measured in characters.

The default tab size is 8 and the TabSize only comes into effect when tab characters are used in the font String.

  UnderlineRGB8Enables font underlining when set.

To underline a font string, set the Underline field to the colour that should be used to draw the underline. Underlining can be turned off by writing this field with a NULL value or setting the alpha component to zero.

  WidthINTReturns the pixel width of a string.

Read this virtual field to obtain the pixel width of a font string. You must have already set a string in the font for this to work, or a width of zero will be returned.

  WrapEdgeINTEnables word wrapping at a given boundary.

Word wrapping is enabled by setting the WrapEdge field to a value greater than zero. Wrapping occurs whenever the right-most edge of any word in the font string extends past the coordinate indicated by the WrapEdge.

  XINTThe starting horizontal position when drawing the font string.

When drawing font strings, the X and Y fields define the position that the string will be drawn to in the target surface. The default coordinates are (0, 0).

  YINTThe starting vertical position when drawing the font string.

When drawing font strings, the X and Y fields define the position that the string will be drawn to in the target surface. The default coordinates are (0, 0).

  YOffsetINTAdditional offset value that is added to vertically aligned fonts.

Fonts that are aligned vertically (either in the center or bottom edge of the drawing area) will have a vertical offset value. Reading that value from this field and adding it to the Y field will give you an accurate reading of where the string will be drawn.

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 a font to a target Bitmap, starting at the coordinates of X and Y, using the characters in the font String.

Error Codes
OkayOperation successful.
FieldNotSetThe Bitmap and/or String field has not been set.
Font class documentation © Paul Manias © 1998-2025

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-2025

FMETA Type

Result flags for the SelectFont() function.

NameDescription
FMETA::HIDDENThe font should not appear in any named list shown to the user.
FMETA::HINT_INTERNALThe Freetype hinter should be used.
FMETA::HINT_LIGHTThe light version of the Freetype hinter should be used.
FMETA::HINT_NORMALThe hinting information provided by the font should be given preference.
FMETA::SCALEDThe font is scalable (assume fixed otherwise).
FMETA::VARIABLEThis is a scalable font featuring variable metrics.
Font module documentation © Paul Manias © 1998-2025

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-2025

FontList Structure

For GetList(), describes a system font.

FieldTypeDescription
Nextstruct FontList *Pointer to the next entry in the list.
NameSTRINGThe name of the font face.
AliasSTRINGReference to another font Name if this is an alias.
PointsINT *Pointer to an array of fixed point sizes supported by the font.
StylesSTRINGSupported styles are listed here in CSV format.
AxesSTRINGFor variable fonts, lists all supported axis codes in CSV format
ScalableBYTETRUE if the font is scalable.
VariableBYTETRUE if the font has variable metrics.
HintingHINTHinting options
HiddenBYTETRUE if the font should be hidden from user font lists.
Font class documentation © Paul Manias © 1998-2025

RGB8 Structure

8-bit RGB colour value.

FieldTypeDescription
RedUBYTERed component value
GreenUBYTEGreen component value
BlueUBYTEBlue component value
AlphaUBYTEAlpha component value
Font class documentation © Paul Manias © 1998-2025