Skip to content

ScaledTextFieldLeft

src.text_layers.ScaledTextFieldLeft

Bases: TextField

A TextField which automatically scales down its font size until the left bound no longer overlaps with the reference layer's right bound.

Source code in src\text_layers.py
class ScaledTextFieldLeft (TextField):
    """A TextField which automatically scales down its font size until the left bound
        no longer overlaps with the `reference` layer's right bound."""

    def execute(self):
        super().execute()

        # Scale down the text layer until it doesn't overlap with a reference layer
        if self.reference:
            scale_text_left_overlap(self.layer, self.reference)

Attributes

TI: TextItem

The TextItem object within the ArtLayer.

color: SolidColor

A SolidColor object provided, or fallback on current TextItem color.

doc_selection: Selection

The Selection object from the active document.

docref: Document

The currently active Photoshop document.

font: str

Font provided, or fallback on global constant.

input: str

Raw contents provided to fill the TextItem.

is_text_layer: bool

Checks if the layer provided is a TextLayer.

kw_color: Optional[SolidColor]

Color to apply to the TextItem.

kw_font: Optional[str]

Font to apply to the root TextItem.

kw_font_bold: Optional[str]

Font to apply to any bold text in the TextItem.

kw_font_italic: Optional[str]

Font to apply to any italicized text in the TextItem.

kw_font_mana: Optional[str]

Font to apply to any mana symbols in the TextItem.

kw_symbol_map: dict[str, tuple[str, list[ColorObject]]]

Symbol map to use for formatting mana symbols.

kwargs: dict

Contains optional parameters to modify text formatting behavior.

layer: ArtLayer

ArtLayer containing the TextItem.

reference: Optional[ArtLayer]

A reference layer, typically used for scaling the TextItem.

reference_dims: Optional[type[LayerDimensions]]

Optional[type[LayerDimensions]]: Dimensions of the scaling reference layer.

Functions

validate()

Ensure the Text Layer provided is valid.

Source code in src\text_layers.py
def validate(self):
    """Ensure the Text Layer provided is valid."""
    if self.layer and self.is_text_layer:
        # Layer is valid, select and show it
        select_layer(self.layer, True)
        return True
    with suppress(Exception):
        # Layer provided doesn't exist or isn't a text layer
        name = self.layer.name if self.layer else '[Non-Layer]'
        print(f'Text Field class: {self.__class__.__name__}\n'
              f'Invalid layer provided: {name}')
        self.layer.visible = False
    return False