prepare_text
Mojo function 🡭
prepare_text
fn def prepare_text(text: String, size: Float64, family: String = "Sans", slant: FontSlant = FontSlant.NORMAL, weight: FontWeight = FontWeight.NORMAL, rotation: Float64 = 0, align: TextAlign = TextAlign.LEFT, kerning: Bool = True, ligatures: Bool = True, *, mut cache: FontCache) -> TextLayoutShape and lay text out once, for measure_layout and draw_layout to share.
Args:
- text (
String): Text to lay out, “\n”-separated lines. - size (
Float64): Font size in pixels. - family (
String): Font family name or generic alias. - slant (
FontSlant): Requested upright/italic slant. - weight (
FontWeight): Requested normal/bold weight. - rotation (
Float64): Radians, rotating the whole block around the anchor. - align (
TextAlign): Horizontal alignment of each line. - kerning (
Bool): Apply the font’s pair kerning between adjacent glyphs. - ligatures (
Bool): Apply the font’sGSUBshaping – ligatures and Arabic contextual forms. False lays out one glyph per character. - cache (
FontCache): Shared cache for font resolution and parsed faces. The same cache has to be passed todraw_layoutlater.
Returns:
TextLayout: The prepared layout.
Raises: