Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

LabelSettings

繼承: Resource < RefCounted < Object

提供能夠在 Label 中自訂文字的常見設定。

說明

LabelSettings is a resource that provides common settings to customize the text in a Label. It will take priority over the properties defined in Control.theme. The resource can be shared between multiple labels and changed on the fly, making it a convenient and flexible way to set up text style.

屬性

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

float

paragraph_spacing

0.0

Color

shadow_color

Color(0, 0, 0, 0)

Vector2

shadow_offset

Vector2(1, 1)

int

shadow_size

1

int

stacked_outline_count

0

Color

stacked_outline_{index}/color

Color(0, 0, 0, 1)

int

stacked_outline_{index}/size

0

int

stacked_shadow_count

0

Color

stacked_shadow_{index}/color

Color(0, 0, 0, 1)

Vector2

stacked_shadow_{index}/offset

Vector2(1, 1)

int

stacked_shadow_{index}/outline_size

0

方法

void

add_stacked_outline(index: int = -1)

void

add_stacked_shadow(index: int = -1)

Color

get_stacked_outline_color(index: int) const

int

get_stacked_outline_size(index: int) const

Color

get_stacked_shadow_color(index: int) const

Vector2

get_stacked_shadow_offset(index: int) const

int

get_stacked_shadow_outline_size(index: int) const

void

move_stacked_outline(from_index: int, to_position: int)

void

move_stacked_shadow(from_index: int, to_position: int)

void

remove_stacked_outline(index: int)

void

remove_stacked_shadow(index: int)

void

set_stacked_outline_color(index: int, color: Color)

void

set_stacked_outline_size(index: int, size: int)

void

set_stacked_shadow_color(index: int, color: Color)

void

set_stacked_shadow_offset(index: int, offset: Vector2)

void

set_stacked_shadow_outline_size(index: int, size: int)


屬性說明

Font font 🔗

  • void set_font(value: Font)

  • Font get_font()

文字使用的 Font。


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

  • void set_font_color(value: Color)

  • Color get_font_color()

文字的顏色。


int font_size = 16 🔗

  • void set_font_size(value: int)

  • int get_font_size()

文字的大小。


float line_spacing = 3.0 🔗

  • void set_line_spacing(value: float)

  • float get_line_spacing()

行與行之間的額外縱向留白(單位為像素),留白會被新增到行的降部。該值可以為負數。


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

  • void set_outline_color(value: Color)

  • Color get_outline_color()

輪廓的顏色。


int outline_size = 0 🔗

  • void set_outline_size(value: int)

  • int get_outline_size()

文字輪廓大小。


float paragraph_spacing = 0.0 🔗

  • void set_paragraph_spacing(value: float)

  • float get_paragraph_spacing()

段落之間的垂直空間。在 line_spacing 上新增。


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

  • void set_shadow_color(value: Color)

  • Color get_shadow_color()

陰影效果的顏色。如果 Alpha 為 0 ,則不會繪製陰影。


Vector2 shadow_offset = Vector2(1, 1) 🔗

陰影效果的偏移,單位為圖元。


int shadow_size = 1 🔗

  • void set_shadow_size(value: int)

  • int get_shadow_size()

陰影效果的大小。


int stacked_outline_count = 0 🔗

  • void set_stacked_outline_count(value: int)

  • int get_stacked_outline_count()

堆疊輪廓的數量。


Color stacked_outline_{index}/color = Color(0, 0, 0, 1) 🔗

索引為 index 的輪廓的顏色。

注意: index 的取值範圍為 0 .. stacked_outline_count - 1。


int stacked_outline_{index}/size = 0 🔗

索引為 index 的輪廓的大小。

注意: index 的取值範圍為 0 .. stacked_outline_count - 1。


int stacked_shadow_count = 0 🔗

  • void set_stacked_shadow_count(value: int)

  • int get_stacked_shadow_count()

堆疊陰影的數量。


Color stacked_shadow_{index}/color = Color(0, 0, 0, 1) 🔗

索引為 index 的陰影的顏色。

注意: index 的取值範圍為 0 .. stacked_shadow_count - 1。


Vector2 stacked_shadow_{index}/offset = Vector2(1, 1) 🔗

索引為 index 的陰影的偏移量。

注意: index 的取值範圍為 0 .. stacked_shadow_count - 1。


int stacked_shadow_{index}/outline_size = 0 🔗

索引為 index 的陰影輪廓的大小。

注意: index 的取值範圍為 0 .. stacked_shadow_count - 1。


方法說明

void add_stacked_outline(index: int = -1) 🔗

為標籤在索引為 index 處新增新的堆疊輪廓。如果 index 為 -1,則新的堆疊輪廓會新增到清單的末尾。


void add_stacked_shadow(index: int = -1) 🔗

為標籤在索引為 index 處新增新的堆疊陰影。如果 index 為 -1,則新的堆疊陰影會新增到清單的末尾。


Color get_stacked_outline_color(index: int) const 🔗

回傳索引為 index 的堆疊輪廓的顏色。


int get_stacked_outline_size(index: int) const 🔗

回傳索引為 index 的堆疊輪廓的大小。


Color get_stacked_shadow_color(index: int) const 🔗

回傳索引為 index 的堆疊陰影的顏色。


Vector2 get_stacked_shadow_offset(index: int) const 🔗

回傳索引為 index 的堆疊陰影的偏移量。


int get_stacked_shadow_outline_size(index: int) const 🔗

回傳索引為 index 的堆疊陰影的輪廓大小。


void move_stacked_outline(from_index: int, to_position: int) 🔗

將索引為 from_index 的堆疊輪廓移動至陣列中的 to_position 位置。


void move_stacked_shadow(from_index: int, to_position: int) 🔗

將索引為 from_index 的堆疊陰影移動至陣列中的 to_position 位置。


void remove_stacked_outline(index: int) 🔗

移除索引為 index 的堆疊輪廓。


void remove_stacked_shadow(index: int) 🔗

移除索引為 index 的堆疊陰影。


void set_stacked_outline_color(index: int, color: Color) 🔗

將索引為 index 的堆疊輪廓的顏色設為 color。


void set_stacked_outline_size(index: int, size: int) 🔗

將索引為 index 的堆疊輪廓的大小設為 size。


void set_stacked_shadow_color(index: int, color: Color) 🔗

將索引為 index 的堆疊陰影的顏色設為 color。


void set_stacked_shadow_offset(index: int, offset: Vector2) 🔗

將索引為 index 的堆疊陰影的偏移量設為 offset。


void set_stacked_shadow_outline_size(index: int, size: int) 🔗

將索引為 index 的堆疊陰影的輪廓大小設為 size。