gewel.draw.walk_text
- gewel.draw.walk_text(ctx: cairocffi.context.Context, text: str, x: float, y: float, box_width: float, font_size: float, line_spacing: float, justification: gewel.draw.TextJustification) List[Tuple[float, float, Optional[str]]][source]
A subroutine for chopping strings into lines to be rendered. This is used as a subroutine by text-rendering classes such as
TextBoxandTeleprompter. It is only public so that code ingewel.contribcan access it when needed.- Parameters
ctx – The low-level drawing context we intend to render to.
text – The text to be rendered.
x – The x location.
y – The y location.
box_width – The width of the text in pixels. Lines will be broken so that rendered text does not exceed this width.
font_size – Font size.
line_spacing – Line spacing (relative to the font size, e.g. 2.0 means double spaced).
justification – The justification.
- Returns
A list of tuples, one per line of text. Each tuple has three elements: the x position of the line, the y position of the line, and the text that goes on that line.
- Return type
List[Tuple[float, float, Optional[str]]]