Skip to content

TextStyle

A style describing how to format and paint text.

属性 ​

名称类型默认值说明
sizeOptional[Number]NoneThe size of glyphs (in logical pixels) to use when painting the text. Defaults to 14.
heightOptional[Number]NoneThe height of this text span, as a multiple of the font size. See detailed explanation here.
weightOptional[FontWeight]NoneThe typeface thickness to use when painting the text (e.g., bold). Defaults to NORMAL.
italicboolFalseWhether to use italic typeface.
decorationOptional[TextDecoration]NoneThe decorations to paint near the text (e.g., an underline).
decoration_colorOptional[ColorValue]NoneThe color in which to paint the text decorations.
decoration_thicknessOptional[Number]NoneThe thickness of the decoration stroke as a multiplier of the thickness defined by the font.
decoration_styleOptional[TextDecorationStyle]NoneThe style in which to paint the text decorations (e.g., dashed). Defaults to TextDecorationStyle.SOLID.
font_familyOptional[str]NoneSee https://flet.dev/docs/controls/text#font_family.
font_family_fallbackOptional[list[str]]NoneOrdered fallback font families to use when glyphs are not available in font_family.
colorOptional[ColorValue]NoneText foreground https://flet.dev/docs/types/colors.
bgcolorOptional[ColorValue]NoneText background https://flet.dev/docs/types/colors.
shadowOptional[BoxShadowValue]NoneA list of shadows painted underneath the text. Multiple shadows can be used to simulate lighting from multiple sources. Shadow order matters because different orders can produce different transparency results.
foregroundOptional[Paint]NoneThe paint drawn as a foreground for the text.
letter_spacingOptional[Number]NoneThe amount of space (in logical pixels) to add between each letter. A negative value can be used to bring the letters closer.
word_spacingOptional[Number]NoneThe amount of space (in logical pixels) to add at each sequence of white-space (i.e. between each word). A negative value can be used to bring the words closer.
overflowOptional[TextOverflow]NoneHow visual text overflow should be handled.
baselineOptional[TextBaseline]NoneThe common baseline that should be aligned between this text span and its parent text span, or, for the root text spans, with the line box.

方法 ​

名称类型默认值说明
copy——返回此对象的副本,可覆盖指定属性。

关注我,学习大模型、大数据、Python等热门技术。