not-fl3 / macroquad

Cross-platform game engine in Rust.
Apache License 2.0
3.04k stars 297 forks source link

add `draw_multiline_text` and `draw_multiline_text_ex` #751

Open cyrgani opened 4 days ago

cyrgani commented 4 days ago

This PR adds two functions for drawing multiline text that breaks on newlines. The new draw_multiline_text and draw_multiline_text_ex functions mirror the existing signatures of the draw_text and draw_text_ex functions.

A different option would be to add a field pub is_multiline: bool to TextParams, which would avoid having two new functions, but that would be a breaking change and would have to wait for 0.5.

not-fl3 commented 4 days ago

I do not know enough about fonts to properly comment on this, but, apparently, there are some hints made by font designers for multiline rendering, for example this field looks relevant? https://docs.rs/fontdue/latest/fontdue/struct.LineMetrics.html#structfield.line_gap