:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/LabelSettings.xml. .. _class_LabelSettings: LabelSettings ============= **继承:** :ref:`Resource` **<** :ref:`RefCounted` **<** :ref:`Object` 提供能够在 :ref:`Label` 中自定义文本的常见设置。 .. rst-class:: classref-introduction-group 描述 ---- **LabelSettings** 是一种提供在 :ref:`Label` 中自定义文本的常见设置的资源。优先于 :ref:`Control.theme` 中定义的属性。该资源可以在多个标签之间共享,可以随时替换,因此可以方便、灵活地设置文本样式。 .. rst-class:: classref-reftable-group 属性 ---- .. table:: :widths: auto +-------------------------------+----------------------------------------------------------------------------------+-----------------------+ | :ref:`Font` | :ref:`font` | | +-------------------------------+----------------------------------------------------------------------------------+-----------------------+ | :ref:`Color` | :ref:`font_color` | ``Color(1, 1, 1, 1)`` | +-------------------------------+----------------------------------------------------------------------------------+-----------------------+ | :ref:`int` | :ref:`font_size` | ``16`` | +-------------------------------+----------------------------------------------------------------------------------+-----------------------+ | :ref:`float` | :ref:`line_spacing` | ``3.0`` | +-------------------------------+----------------------------------------------------------------------------------+-----------------------+ | :ref:`Color` | :ref:`outline_color` | ``Color(1, 1, 1, 1)`` | +-------------------------------+----------------------------------------------------------------------------------+-----------------------+ | :ref:`int` | :ref:`outline_size` | ``0`` | +-------------------------------+----------------------------------------------------------------------------------+-----------------------+ | :ref:`float` | :ref:`paragraph_spacing` | ``0.0`` | +-------------------------------+----------------------------------------------------------------------------------+-----------------------+ | :ref:`Color` | :ref:`shadow_color` | ``Color(0, 0, 0, 0)`` | +-------------------------------+----------------------------------------------------------------------------------+-----------------------+ | :ref:`Vector2` | :ref:`shadow_offset` | ``Vector2(1, 1)`` | +-------------------------------+----------------------------------------------------------------------------------+-----------------------+ | :ref:`int` | :ref:`shadow_size` | ``1`` | +-------------------------------+----------------------------------------------------------------------------------+-----------------------+ | :ref:`int` | :ref:`stacked_outline_count` | ``0`` | +-------------------------------+----------------------------------------------------------------------------------+-----------------------+ | :ref:`int` | :ref:`stacked_shadow_count` | ``0`` | +-------------------------------+----------------------------------------------------------------------------------+-----------------------+ .. rst-class:: classref-reftable-group 方法 ---- .. table:: :widths: auto +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`add_stacked_outline`\ (\ index\: :ref:`int` = -1\ ) | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`add_stacked_shadow`\ (\ index\: :ref:`int` = -1\ ) | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Color` | :ref:`get_stacked_outline_color`\ (\ index\: :ref:`int`\ ) |const| | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_stacked_outline_size`\ (\ index\: :ref:`int`\ ) |const| | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Color` | :ref:`get_stacked_shadow_color`\ (\ index\: :ref:`int`\ ) |const| | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`get_stacked_shadow_offset`\ (\ index\: :ref:`int`\ ) |const| | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_stacked_shadow_outline_size`\ (\ index\: :ref:`int`\ ) |const| | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`move_stacked_outline`\ (\ from_index\: :ref:`int`, to_position\: :ref:`int`\ ) | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`move_stacked_shadow`\ (\ from_index\: :ref:`int`, to_position\: :ref:`int`\ ) | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`remove_stacked_outline`\ (\ index\: :ref:`int`\ ) | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`remove_stacked_shadow`\ (\ index\: :ref:`int`\ ) | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_stacked_outline_color`\ (\ index\: :ref:`int`, color\: :ref:`Color`\ ) | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_stacked_outline_size`\ (\ index\: :ref:`int`, size\: :ref:`int`\ ) | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_stacked_shadow_color`\ (\ index\: :ref:`int`, color\: :ref:`Color`\ ) | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_stacked_shadow_offset`\ (\ index\: :ref:`int`, offset\: :ref:`Vector2`\ ) | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_stacked_shadow_outline_size`\ (\ index\: :ref:`int`, size\: :ref:`int`\ ) | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group 属性说明 -------- .. _class_LabelSettings_property_font: .. rst-class:: classref-property :ref:`Font` **font** :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_font**\ (\ value\: :ref:`Font`\ ) - :ref:`Font` **get_font**\ (\ ) 文本使用的 :ref:`Font`\ 。 .. rst-class:: classref-item-separator ---- .. _class_LabelSettings_property_font_color: .. rst-class:: classref-property :ref:`Color` **font_color** = ``Color(1, 1, 1, 1)`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_font_color**\ (\ value\: :ref:`Color`\ ) - :ref:`Color` **get_font_color**\ (\ ) 文本的颜色。 .. rst-class:: classref-item-separator ---- .. _class_LabelSettings_property_font_size: .. rst-class:: classref-property :ref:`int` **font_size** = ``16`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_font_size**\ (\ value\: :ref:`int`\ ) - :ref:`int` **get_font_size**\ (\ ) 文本的大小。 .. rst-class:: classref-item-separator ---- .. _class_LabelSettings_property_line_spacing: .. rst-class:: classref-property :ref:`float` **line_spacing** = ``3.0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_line_spacing**\ (\ value\: :ref:`float`\ ) - :ref:`float` **get_line_spacing**\ (\ ) 行与行之间的额外纵向留白(单位为像素),留白会被添加到行的降部。该值可以为负数。 .. rst-class:: classref-item-separator ---- .. _class_LabelSettings_property_outline_color: .. rst-class:: classref-property :ref:`Color` **outline_color** = ``Color(1, 1, 1, 1)`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_outline_color**\ (\ value\: :ref:`Color`\ ) - :ref:`Color` **get_outline_color**\ (\ ) 轮廓的颜色。 .. rst-class:: classref-item-separator ---- .. _class_LabelSettings_property_outline_size: .. rst-class:: classref-property :ref:`int` **outline_size** = ``0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_outline_size**\ (\ value\: :ref:`int`\ ) - :ref:`int` **get_outline_size**\ (\ ) 文本轮廓大小。 .. rst-class:: classref-item-separator ---- .. _class_LabelSettings_property_paragraph_spacing: .. rst-class:: classref-property :ref:`float` **paragraph_spacing** = ``0.0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_paragraph_spacing**\ (\ value\: :ref:`float`\ ) - :ref:`float` **get_paragraph_spacing**\ (\ ) 段落之间的垂直空间。在 :ref:`line_spacing` 上添加。 .. rst-class:: classref-item-separator ---- .. _class_LabelSettings_property_shadow_color: .. rst-class:: classref-property :ref:`Color` **shadow_color** = ``Color(0, 0, 0, 0)`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_shadow_color**\ (\ value\: :ref:`Color`\ ) - :ref:`Color` **get_shadow_color**\ (\ ) 阴影效果的颜色。如果 Alpha 为 ``0`` ,则不会绘制阴影。 .. rst-class:: classref-item-separator ---- .. _class_LabelSettings_property_shadow_offset: .. rst-class:: classref-property :ref:`Vector2` **shadow_offset** = ``Vector2(1, 1)`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_shadow_offset**\ (\ value\: :ref:`Vector2`\ ) - :ref:`Vector2` **get_shadow_offset**\ (\ ) 阴影效果的偏移,单位为像素。 .. rst-class:: classref-item-separator ---- .. _class_LabelSettings_property_shadow_size: .. rst-class:: classref-property :ref:`int` **shadow_size** = ``1`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_shadow_size**\ (\ value\: :ref:`int`\ ) - :ref:`int` **get_shadow_size**\ (\ ) 阴影效果的大小。 .. rst-class:: classref-item-separator ---- .. _class_LabelSettings_property_stacked_outline_count: .. rst-class:: classref-property :ref:`int` **stacked_outline_count** = ``0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_stacked_outline_count**\ (\ value\: :ref:`int`\ ) - :ref:`int` **get_stacked_outline_count**\ (\ ) 堆叠轮廓的数量。 .. rst-class:: classref-item-separator ---- .. _class_LabelSettings_property_stacked_shadow_count: .. rst-class:: classref-property :ref:`int` **stacked_shadow_count** = ``0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_stacked_shadow_count**\ (\ value\: :ref:`int`\ ) - :ref:`int` **get_stacked_shadow_count**\ (\ ) 堆叠阴影的数量。 .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group 方法说明 -------- .. _class_LabelSettings_method_add_stacked_outline: .. rst-class:: classref-method |void| **add_stacked_outline**\ (\ index\: :ref:`int` = -1\ ) :ref:`🔗` 为标签在索引为 ``index`` 处添加新的堆叠轮廓。如果 ``index`` 为 ``-1``\ ,则新的堆叠轮廓会添加到列表的末尾。 .. rst-class:: classref-item-separator ---- .. _class_LabelSettings_method_add_stacked_shadow: .. rst-class:: classref-method |void| **add_stacked_shadow**\ (\ index\: :ref:`int` = -1\ ) :ref:`🔗` 为标签在索引为 ``index`` 处添加新的堆叠阴影。如果 ``index`` 为 ``-1``\ ,则新的堆叠阴影会添加到列表的末尾。 .. rst-class:: classref-item-separator ---- .. _class_LabelSettings_method_get_stacked_outline_color: .. rst-class:: classref-method :ref:`Color` **get_stacked_outline_color**\ (\ index\: :ref:`int`\ ) |const| :ref:`🔗` 返回索引为 ``index`` 的堆叠轮廓的颜色。 .. rst-class:: classref-item-separator ---- .. _class_LabelSettings_method_get_stacked_outline_size: .. rst-class:: classref-method :ref:`int` **get_stacked_outline_size**\ (\ index\: :ref:`int`\ ) |const| :ref:`🔗` 返回索引为 ``index`` 的堆叠轮廓的大小。 .. rst-class:: classref-item-separator ---- .. _class_LabelSettings_method_get_stacked_shadow_color: .. rst-class:: classref-method :ref:`Color` **get_stacked_shadow_color**\ (\ index\: :ref:`int`\ ) |const| :ref:`🔗` 返回索引为 ``index`` 的堆叠阴影的颜色。 .. rst-class:: classref-item-separator ---- .. _class_LabelSettings_method_get_stacked_shadow_offset: .. rst-class:: classref-method :ref:`Vector2` **get_stacked_shadow_offset**\ (\ index\: :ref:`int`\ ) |const| :ref:`🔗` 返回索引为 ``index`` 的堆叠阴影的偏移量。 .. rst-class:: classref-item-separator ---- .. _class_LabelSettings_method_get_stacked_shadow_outline_size: .. rst-class:: classref-method :ref:`int` **get_stacked_shadow_outline_size**\ (\ index\: :ref:`int`\ ) |const| :ref:`🔗` 返回索引为 ``index`` 的堆叠阴影的轮廓大小。 .. rst-class:: classref-item-separator ---- .. _class_LabelSettings_method_move_stacked_outline: .. rst-class:: classref-method |void| **move_stacked_outline**\ (\ from_index\: :ref:`int`, to_position\: :ref:`int`\ ) :ref:`🔗` 将索引为 ``from_index`` 的堆叠轮廓移动至数组中的 ``to_position`` 位置。 .. rst-class:: classref-item-separator ---- .. _class_LabelSettings_method_move_stacked_shadow: .. rst-class:: classref-method |void| **move_stacked_shadow**\ (\ from_index\: :ref:`int`, to_position\: :ref:`int`\ ) :ref:`🔗` 将索引为 ``from_index`` 的堆叠阴影移动至数组中的 ``to_position`` 位置。 .. rst-class:: classref-item-separator ---- .. _class_LabelSettings_method_remove_stacked_outline: .. rst-class:: classref-method |void| **remove_stacked_outline**\ (\ index\: :ref:`int`\ ) :ref:`🔗` 移除索引为 ``index`` 的堆叠轮廓。 .. rst-class:: classref-item-separator ---- .. _class_LabelSettings_method_remove_stacked_shadow: .. rst-class:: classref-method |void| **remove_stacked_shadow**\ (\ index\: :ref:`int`\ ) :ref:`🔗` 移除索引为 ``index`` 的堆叠阴影。 .. rst-class:: classref-item-separator ---- .. _class_LabelSettings_method_set_stacked_outline_color: .. rst-class:: classref-method |void| **set_stacked_outline_color**\ (\ index\: :ref:`int`, color\: :ref:`Color`\ ) :ref:`🔗` 将索引为 ``index`` 的堆叠轮廓的颜色设为 ``color``\ 。 .. rst-class:: classref-item-separator ---- .. _class_LabelSettings_method_set_stacked_outline_size: .. rst-class:: classref-method |void| **set_stacked_outline_size**\ (\ index\: :ref:`int`, size\: :ref:`int`\ ) :ref:`🔗` 将索引为 ``index`` 的堆叠轮廓的大小设为 ``size``\ 。 .. rst-class:: classref-item-separator ---- .. _class_LabelSettings_method_set_stacked_shadow_color: .. rst-class:: classref-method |void| **set_stacked_shadow_color**\ (\ index\: :ref:`int`, color\: :ref:`Color`\ ) :ref:`🔗` 将索引为 ``index`` 的堆叠阴影的颜色设为 ``color``\ 。 .. rst-class:: classref-item-separator ---- .. _class_LabelSettings_method_set_stacked_shadow_offset: .. rst-class:: classref-method |void| **set_stacked_shadow_offset**\ (\ index\: :ref:`int`, offset\: :ref:`Vector2`\ ) :ref:`🔗` 将索引为 ``index`` 的堆叠阴影的偏移量设为 ``offset``\ 。 .. rst-class:: classref-item-separator ---- .. _class_LabelSettings_method_set_stacked_shadow_outline_size: .. rst-class:: classref-method |void| **set_stacked_shadow_outline_size**\ (\ index\: :ref:`int`, size\: :ref:`int`\ ) :ref:`🔗` 将索引为 ``index`` 的堆叠阴影的轮廓大小设为 ``size``\ 。 .. |virtual| replace:: :abbr:`virtual (本方法通常需要用户覆盖才能生效。)` .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)` .. |const| replace:: :abbr:`const (本方法无副作用,不会修改该实例的任何成员变量。)` .. |vararg| replace:: :abbr:`vararg (本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。)` .. |constructor| replace:: :abbr:`constructor (本方法用于构造某个类型。)` .. |static| replace:: :abbr:`static (调用本方法无需实例,可直接使用类名进行调用。)` .. |operator| replace:: :abbr:`operator (本方法描述的是使用本类型作为左操作数的有效运算符。)` .. |bitfield| replace:: :abbr:`BitField (这个值是由下列位标志构成位掩码的整数。)` .. |void| replace:: :abbr:`void (无返回值。)`