When I have multiple lines of text, how should the line height be calculated? #215
-
Thank you for your great work. This is how I calculate it now. ref line_height = extents.ascender - extents.descender + extents.line_gap
cursor_x, cursor_y = -300, 0
texts = 'i love you\n我爱你\n愛してます'
"""
some code
"""
for pos, c in zip(positions, texts):
if c == "\n":
cursor_x = -300
cursor_y += line_height * scale
continue
outline = get_glyph_outline(font_path, c)
draw_outline_with_turtle(outline, scale=scale,
offset=(cursor_x + pos.x_offset * scale, cursor_y + pos.y_offset * scale))
cursor_x += pos.x_advance * scale
cursor_y += pos.y_advance * scale Is there any better way to calculate line_height? |
Beta Was this translation helpful? Give feedback.
Answered by
khaledhosny
Sep 24, 2024
Replies: 1 comment 1 reply
-
That is as good as it gets. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
khaledhosny
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That is as good as it gets.