TextAlign
Mojo struct 🡭
TextAlign
@memory_only
struct TextAlignHorizontal alignment of each line relative to draw_text’s (x, y) anchor.
Measured against a line’s advance width (TextMetrics.advance, the logical cursor-advance distance) rather than its tight ink bounds, matching HTML5 Canvas’s textAlign, so trailing whitespace shifts centering instead of being ignored.
Aliases
LEFT = TextAlign(Int(0))CENTER = TextAlign(Int(1))RIGHT = TextAlign(Int(2))
Implemented traits
AnyType, Copyable, Deinitable, Equatable, ImplicitlyCopyable, Movable, Writable
Methods
__init__
fn def __init__(out self, value: Int)Prefer the LEFT/CENTER/RIGHT comptime constants over constructing one directly.
Args:
- value (
Int): 0 for LEFT, 1 for CENTER, 2 for RIGHT. - self (
Self)
Returns:
Self
__eq__
fn def __eq__(self, other: Self) -> BoolArgs:
- self (
Self) - other (
Self)
Returns:
Bool
write_to
fn def write_to[W: Writer](self, mut writer: W)Parameters:
- W (
Writer)
Args:
- self (
Self) - writer (
W)
__str__
fn def __str__(self) -> StringArgs:
- self (
Self)
Returns:
String