Skip to content
Lukas Sägesser edited this page Jun 22, 2015 · 11 revisions

Font

####Inherits: Resource ####Category: Core

Brief Description

Internationalized font and text drawing support.

Member Functions

Description

Font contains an unicode compatible character set, as well as the ability to draw it with variable width, ascent, descent and kerning. For creating fonts from TTF files (or other font formats), see the editor support for fonts. TODO check wikipedia for graph of ascent/baseline/descent/height/etc.

Member Function Description

  • void set_height ( float px )

Set the total font height (ascent plus descent) in pixels.

  • float get_height ( ) const

Return the total font height (ascent plus descent) in pixels.

  • void set_ascent ( float px )

Set the font ascent (number of pixels above the baseline).

  • float get_ascent ( ) const

Return the font ascent (number of pixels above the baseline).

  • float get_descent ( ) const

Return the font descent (number of pixels below the baseline).

  • void add_kerning_pair ( int char_a, int char_b, int kerning )

Add a kerning pair to the Font as a difference. Kerning pairs are special cases where a typeface advance is determined by the next character.

  • int get_kerning_pair ( int arg0, int arg1 ) const

Return a kerning pair as a difference. Kerning pairs are special cases where a typeface advance is determined by the next character.

  • void add_texture ( Texture texture )

Add a texture to the Font.

Add a character to the font, where "character" is the unicode value, "texture" is the texture index, "rect" is the region in the texture (in pixels!), "align" is the (optional) alignment for the character and "advance" is the (optional) advance.

Return the size of a character, optionally taking kerning into account if the next character is provided.

Return the size of a string, taking kerning and advance into account.

  • void clear ( )

Clear all the font data.

Draw "string" into a canvas item using the font at a given "pos" position, with "modulate" color, and optionally clipping the width. "pos" specifies te baseline, not the top. To draw from the top, ascent must be added to the Y axis.

Draw character "char" into a canvas item using the font at a given "pos" position, with "modulate" color, and optionally kerning if "next" is apassed. clipping the width. "pos" specifies te baseline, not the top. To draw from the top, ascent must be added to the Y axis. The width used by the character is returned, making this function useful for drawing strings character by character.

Clone this wiki locally