Currently, we calculate the line height for paragraphs based on the paragraph’s style, ignoring the style of the text elements. Instead, we should calculate the height for every line based on the line content.
Steps to implement this:
Metrics
struct with the glyph_height
and line_height
fields to the fonts
module.metrics(font_size: u8)
method to Font
and a metrics()
method to Style
that return the scaled metrics.render::TextSection::new
to take a Metrics
instance instead of a Style
.Paragraph::render
to calculate the maximum Metrics
per line and use them for the TextSection
.Paragraph
documentation accordingly.I can do this one as well
That would be great! Let me know if anything is unclear or not working as expected.
Finished here:
https://git.sr.ht/~ap4sc/genpdf-rs/commit/67eb37c4cccba82a0a1330c0e357a7aff4ada4e1
However setting
with_line_spacing
on theParagraph
still doesn't seem to do anything. I'm not sure where to add this calculation inParagraph render()
Thanks! Can you please submit a patch? Then I’ll have a look at the line spacing issue.
Applied as commit 7aa4ac78d6e4eb45cc36258d95dbb790ae5f2dba.