forked from godotengine/godot
-
Notifications
You must be signed in to change notification settings - Fork 0
class_font
reduz edited this page Feb 23, 2014
·
11 revisions
Inherits: resource\ Category: Core\
Internationalized font and text drawing support.
- void #set_height( real px )
- real #get_height(****) const
- void #set_ascent( real px )
- real #get_ascent(****) const
- real #get_descent(****) const
- void #add_kerning_pair( int char_a, int char_b, int kerning )
- int #get_kerning_pair( int arg0, int arg1 ) const
- void #add_texture( Texture texture )
- void #add_char( int character, int texture, Rect2 rect, Vector2 align=Vector2(0,0), real advance=-1 )
- Vector2 #get_char_size( int char, int next=0 ) const
- Vector2 #get_string_size( String string ) const
- void #clear(****)
- void #draw( RID canvas_item, Vector2 pos, String string, Color modulate=Color(1,1,1,1), int clip_w=-1 ) const
- real #draw_char( RID canvas_item, Vector2 pos, int char, int next=-1, Color modulate=Color(1,1,1,1) ) const
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.
== set_height ==
- void #set_height( real px ) \ Set the total font height (ascent plus descent) in pixels. == get_height ==
- real #get_height(****) const \ Return the total font height (ascent plus descent) in pixels. == set_ascent ==
- void #set_ascent( real px ) \ Set the font ascent (number of pixels above the baseline). == get_ascent ==
- real #get_ascent(****) const \ Return the font ascent (number of pixels above the baseline). == get_descent ==
- real #get_descent(****) const \ Return the font descent (number of pixels below the baseline). == add_kerning_pair ==
- 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. == get_kerning_pair ==
- 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. == add_texture ==
- void #add_texture( Texture texture ) \ Add a texture to the font. == add_char ==
- void #add_char( int character, int texture, Rect2 rect, Vector2 align=Vector2(0,0), real advance=-1 ) \ 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. == get_char_size ==
- Vector2 #get_char_size( int char, int next=0 ) const \ Return the size of a character, optionally taking kerning into account if the next character is provided. == get_string_size ==
- Vector2 #get_string_size( String string ) const \ Return the size of a string, taking kerning and advance into account. == clear ==
- void #clear(****) \ Clear all the font data. == draw ==
- void #draw( RID canvas_item, Vector2 pos, String string, Color modulate=Color(1,1,1,1), int clip_w=-1 ) const \ 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_char ==
- real #draw_char( RID canvas_item, Vector2 pos, int char, int next=-1, Color modulate=Color(1,1,1,1) ) const \ 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.