text_align_last property

This page explains the text-related text_align_last property.

What property is this?

The text_align_last property updates or gets the text last line’s alignment setting.

Basic usage

The getter and setter interfaces’ type becomes an ap.CssTextAlignLast enum value.

The acceptable enum values are as follows:

  • CssTextAlignLast.AUTO (default)

  • CssTextAlignLast.LEFT

  • CssTextAlignLast.CENTER

  • CssTextAlignLast.RIGHT

  • CssTextAlignLast.JUSTIFY

Example of CssTextAlignLast.AUTO

Notes: This setting is a default setting.

The CssTextAlignLast.AUTO setting inherits the text_align setting.

For example, if the text_align setting is the CssTextAlign.CENTER, the text_align_last property also behaves as the center align.

import apysc as ap

stage: ap.Stage = ap.Stage(
    background_color=ap.Color("#333"),
    stage_width=350,
    stage_height=170,
    stage_elem_id="stage",
)
multi_line_text: ap.MultiLineText = ap.MultiLineText(
    text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, "
    "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "
    "Ut enim ad minim veniam",
    width=300,
    font_size=16,
    fill_color=ap.Color("#00aaff"),
    x=25,
    y=25,
)
multi_line_text.text_align = ap.CssTextAlign.CENTER
multi_line_text.text_align_last = ap.CssTextAlignLast.AUTO

ap.save_overall_html(dest_dir_path="./css_text_align_last_auto/")

Example of CssTextAlignLast.LEFT

import apysc as ap

stage: ap.Stage = ap.Stage(
    background_color=ap.Color("#333"),
    stage_width=350,
    stage_height=170,
    stage_elem_id="stage",
)
multi_line_text: ap.MultiLineText = ap.MultiLineText(
    text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, "
    "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "
    "Ut enim ad minim veniam",
    width=300,
    font_size=16,
    fill_color=ap.Color("#00aaff"),
    x=25,
    y=25,
)
multi_line_text.text_align = ap.CssTextAlign.JUSTIFY
multi_line_text.text_align_last = ap.CssTextAlignLast.LEFT

ap.save_overall_html(dest_dir_path="./css_text_align_last_left/")

Example of CssTextAlignLast.CENTER

import apysc as ap

stage: ap.Stage = ap.Stage(
    background_color=ap.Color("#333"),
    stage_width=350,
    stage_height=170,
    stage_elem_id="stage",
)
multi_line_text: ap.MultiLineText = ap.MultiLineText(
    text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, "
    "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "
    "Ut enim ad minim veniam",
    width=300,
    font_size=16,
    fill_color=ap.Color("#00aaff"),
    x=25,
    y=25,
)
multi_line_text.text_align = ap.CssTextAlign.JUSTIFY
multi_line_text.text_align_last = ap.CssTextAlignLast.CENTER

ap.save_overall_html(dest_dir_path="./css_text_align_last_center/")

Example of CssTextAlignLast.RIGHT

import apysc as ap

stage: ap.Stage = ap.Stage(
    background_color=ap.Color("#333"),
    stage_width=350,
    stage_height=170,
    stage_elem_id="stage",
)
multi_line_text: ap.MultiLineText = ap.MultiLineText(
    text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, "
    "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "
    "Ut enim ad minim veniam",
    width=300,
    font_size=16,
    fill_color=ap.Color("#00aaff"),
    x=25,
    y=25,
)
multi_line_text.text_align = ap.CssTextAlign.JUSTIFY
multi_line_text.text_align_last = ap.CssTextAlignLast.RIGHT

ap.save_overall_html(dest_dir_path="./css_text_align_last_right/")

Example of CssTextAlignLast.JUSTIFY

Notes: This enum setting justifies the last line text evenly.

import apysc as ap

stage: ap.Stage = ap.Stage(
    background_color=ap.Color("#333"),
    stage_width=350,
    stage_height=170,
    stage_elem_id="stage",
)
multi_line_text: ap.MultiLineText = ap.MultiLineText(
    text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, "
    "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "
    "Ut enim ad minim veniam",
    width=300,
    font_size=16,
    fill_color=ap.Color("#00aaff"),
    x=25,
    y=25,
)
multi_line_text.text_align = ap.CssTextAlign.JUSTIFY
multi_line_text.text_align_last = ap.CssTextAlignLast.JUSTIFY

ap.save_overall_html(dest_dir_path="./css_text_align_last_justify/")

text_align_last property API

Note: the document build script generates and updates this API document section automatically. Maybe this section is duplicated compared with previous sections.

[Interface summary]

Get a text-align-last value.


[Returns]

  • text_align_last: CssTextAlignLast

    • A text-align-last value.


[Examples]

>>> import apysc as ap
>>> stage: ap.Stage = ap.Stage(
...     background_color=ap.Color("#333"),
...     stage_width=350,
...     stage_height=170,
...     stage_elem_id="stage",
... )
>>> multi_line_text: ap.MultiLineText = ap.MultiLineText(
...     text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, "
...     "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "
...     "Ut enim ad minim veniam",
...     width=300,
...     font_size=16,
...     fill_color=ap.Color("#00aaff"),
...     x=25,
...     y=25,
... )
>>> multi_line_text.text_align = ap.CssTextAlign.JUSTIFY
>>> multi_line_text.text_align_last = ap.CssTextAlignLast.RIGHT
>>> assert multi_line_text.text_align_last == ap.CssTextAlignLast.RIGHT