字体¶
Inherits: Resource < Reference < Object
继承人: BitmapFont , DynamicFont
类别: 核心
简要说明¶
支持国际化的字体和文本绘制。
方法¶
无效 |
draw ( RID canvas_item, Vector2 position, String string, Color modulate=Color( 1, 1, 1, 1 ), int clip_w=-1, Color outline_modulate=Color( 1, 1, 1, 1 ) ) const |
draw_char ( RID canvas_item, Vector2 position, int char, int next=-1, Color modulate=Color( 1, 1, 1, 1 ), bool outline=false ) const |
|
get_ascent ( ) const |
|
get_descent ( ) const |
|
get_height ( ) const |
|
get_string_size ( String string ) const |
|
get_wordwrap_string_size ( String string, float p_width ) const |
|
has_outline ( ) const |
|
is_distance_field_hint ( ) const |
|
无效 |
update_changes ( ) |
描述¶
字体包含与Unicode兼容的字符集,以及使用可变宽度、升序、降序和紧排绘制它的能力。有关从TTF文件(或其他字体格式)创建字体的信息,请参阅字体的编辑器支持。
方法说明¶
void draw ( RID canvas_item, Vector2 position, String string, Color modulate=Color( 1, 1, 1, 1 ), int clip_w=-1, Color outline_modulate=Color( 1, 1, 1, 1 ) ) const
画 string
在给定位置使用字体的画布项中, modulate
颜色,并可以选择剪切宽度。 position
指定基线,而不是顶部。从上往下画, 上升 必须添加到Y轴。
float draw_char ( RID canvas_item, Vector2 position, int char, int next=-1, Color modulate=Color( 1, 1, 1, 1 ), bool outline=false ) const
绘制字符 char
在给定位置使用字体的画布项中, modulate
颜色,如果 next
已通过。裁剪宽度。 position
指定基线,而不是顶部。从上往下画, 上升 必须添加到Y轴。返回字符使用的宽度,使此函数对逐个字符绘制字符串很有用。
float get_ascent ( ) const
返回字体升序(高于基线的像素数)。
float get_descent ( ) const
返回字体下降(低于基线的像素数)。
float get_height ( ) const
返回以像素为单位的总字体高度(上升加下降)。
返回字符串的大小,同时考虑紧排和前进。
bool has_outline ( ) const
bool is_distance_field_hint ( ) const
void update_changes ( )
编辑字体后(更改大小、升序、字符矩形等)。调用此函数以将更改传播到可能使用它的控件。