Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

LabelSettings

继承: Resource < RefCounted < Object

提供能够在 Label 中自定义文本的常见设置。

描述

LabelSettings 是一种提供在 Label 中自定义文本的常见设置的资源。优先于 Control.theme 中定义的属性。该资源可以在多个标签之间共享,可以随时替换,因此可以方便、灵活地设置文本样式。

属性

Font

font

Color

font_color

Color(1, 1, 1, 1)

int

font_size

16

float

line_spacing

3.0

Color

outline_color

Color(1, 1, 1, 1)

int

outline_size

0

Color

shadow_color

Color(0, 0, 0, 0)

Vector2

shadow_offset

Vector2(1, 1)

int

shadow_size

1


属性说明

Font font

  • void set_font ( Font value )

  • Font get_font ( )

文本使用的 Font


Color font_color = Color(1, 1, 1, 1)

  • void set_font_color ( Color value )

  • Color get_font_color ( )

文本的颜色。


int font_size = 16

  • void set_font_size ( int value )

  • int get_font_size ( )

文本的大小。


float line_spacing = 3.0

  • void set_line_spacing ( float value )

  • float get_line_spacing ( )

文本为多行时,行与行之间的垂直间距。


Color outline_color = Color(1, 1, 1, 1)

  • void set_outline_color ( Color value )

  • Color get_outline_color ( )

轮廓的颜色。


int outline_size = 0

  • void set_outline_size ( int value )

  • int get_outline_size ( )

文本轮廓大小。


Color shadow_color = Color(0, 0, 0, 0)

  • void set_shadow_color ( Color value )

  • Color get_shadow_color ( )

阴影效果的颜色。如果 Alpha 为 0 ,则不会绘制阴影。


Vector2 shadow_offset = Vector2(1, 1)

  • void set_shadow_offset ( Vector2 value )

  • Vector2 get_shadow_offset ( )

阴影效果的偏移,单位为像素。


int shadow_size = 1

  • void set_shadow_size ( int value )

  • int get_shadow_size ( )

阴影效果的大小。