Canvas Toolkit
← Class index

CFontMetrics

GUI and styling

Provides measurements for text rendered with a specific font.

Module gui/CFontMetrics.js. This class is available through the browser modules in the download.

Declared members

constructor(font: CFont);

Creates a new CFontMetrics instance. @param font Font.

font(): CFont;

Returns the font used by these metrics. @returns The resulting value.

textWidth(text: string): number;

Returns the rendered width of the specified text. @param text Text. @returns The resulting value.

height(): number;

Returns the line height of the configured font. @returns The resulting value.