The OpenD Programming Language

MeasurableFont

Interface with the common functionality for font measurements between OperatingSystemFont and DrawableFont.

Members

Aliases

fnum
alias fnum = float

Functions

ascent
fnum ascent()

The maximum ascent of a glyph above the baseline.

averageWidth
fnum averageWidth()

The average width of glyphs in the font, traditionally equal to the width of the lowercase x. Can be used to estimate bounding boxes, especially if the font isMonospace.

descent
fnum descent()

The maximum descent of a glyph below the baseline. For example, how low the g might go.

height
fnum height()

The height of the bounding box of a line.

isMonospace
bool isMonospace()

Returns true if it is a monospace font, meaning each of the glyphs (at least the ascii characters) have matching width and no kerning, so you can determine the display width of some strings by simply multiplying the string width by averageWidth.

stringWidth
fnum stringWidth(const(char)[] s, SimpleWindow window)

The display width of the given string, and if you provide a window, it will use it to make the pixel count on screen more accurate too, but this shouldn't generally be necessary.

Meta

History

Added October 24, 2022. The methods were already on OperatingSystemFont before that.