Ir para o conteúdo

Text

TextAssetParams

Bases: BaseModel

Represents the parameters for a text assets.

position class-attribute instance-attribute

position: Position = Field(default_factory=AbsolutePosition)

The positioning of the text assets in the video.

font_family class-attribute instance-attribute

font_family: str = 'Arial Bold'

The font family.

font_size class-attribute instance-attribute

font_size: NonNegativeInt = 70

The font size.

font_color class-attribute instance-attribute

font_color: Color = Field(
    default_factory=lambda: Color("#000000")
)

The font color hexadecimal code.

font_kerning class-attribute instance-attribute

font_kerning: float = 0

The font kerning.

line_height class-attribute instance-attribute

line_height: int = 10

The line height.

stroke_color class-attribute instance-attribute

stroke_color: Color = Field(
    default_factory=lambda: Color("#000000")
)

The font stroke color hexadecimal code.

stroke_width class-attribute instance-attribute

stroke_width: NonNegativeFloat = 0

The font stroke width.

shadow_color class-attribute instance-attribute

shadow_color: Color = Field(
    default_factory=lambda: Color("#000000")
)

The shadow color hexadecimal code.

shadow_blur class-attribute instance-attribute

shadow_blur: int = 0

The shadow blur.

shadow_opacity class-attribute instance-attribute

shadow_opacity: Annotated[float, Field(ge=0, le=1)] = 1

The shadow opacity.

shadow_angle class-attribute instance-attribute

shadow_angle: int = 0

The shadow angle.

shadow_distance class-attribute instance-attribute

shadow_distance: NonNegativeInt = 0

The shadow distance.

background_color class-attribute instance-attribute

background_color: Color = Field(
    default_factory=lambda: Color("transparent")
)

The background color hexadecimal code.

align class-attribute instance-attribute

align: Literal['left', 'center', 'right'] = 'left'

The text alignment.

z_index class-attribute instance-attribute

z_index: int = 0

The z-index of the assets.

serialize_color

serialize_color(value: Color) -> str

Serialize the color to its hexadecimal code.

Source code in src/mosaico/assets/text.py
@field_serializer("font_color", "stroke_color", "shadow_color", "background_color", when_used="always")
def serialize_color(self, value: Color) -> str:
    """Serialize the color to its hexadecimal code."""
    return value.as_hex()

BaseTextAsset

Bases: BaseAsset[TextAssetParams]

Represents a text assets with various properties.

params class-attribute instance-attribute

params: TextAssetParams = Field(
    default_factory=TextAssetParams
)

The parameters for the text assets.

has_background property

has_background: bool

Check if the text asset has a background.

has_shadow property

has_shadow: bool

Check if the text asset has a shadow.

TextAsset

Bases: BaseTextAsset

Represents a text assets with various properties.

type class-attribute instance-attribute

type: Literal['text'] = 'text'

¨The type of the assets. Defaults to "text".