Skip to content
TextBlockBounds

TextBlockBounds

Mojo struct 🡭

TextBlockBounds

@memory_only
struct TextBlockBounds

The axis-aligned bounding box draw_text’s ink would occupy for a given text/rotation/align/font, anchor-relative: x/y are the top-left corner relative to draw_text’s (x, y) anchor, and either can be negative (RIGHT-aligned text extends left of the anchor; a label rotated upward extends above it). x + width/y + height is the bottom-right corner.

Rotation and multi-line change a block’s footprint in ways a single line’s unrotated width/height (TextMetrics) can’t capture, so this reports the same box _layout_block computes for rendering.

Fields

  • x (Float64)
  • y (Float64)
  • width (Float64)
  • height (Float64)

Implemented traits

AnyType, Copyable, Deinitable, ImplicitlyCopyable, Movable

Methods

__init__

fn def __init__(out self, x: Float64, y: Float64, width: Float64, height: Float64)

The bounding box draw_text’s ink would occupy, anchor- relative – see the struct docstring above.

Args:

  • x (Float64): Top-left corner x, relative to draw_text’s anchor. Can be negative.
  • y (Float64): Top-left corner y, relative to draw_text’s anchor. Can be negative.
  • width (Float64): Bounding box width.
  • height (Float64): Bounding box height.
  • self (Self)

Returns:

Self