~ireas/genpdf-rs#21: 
Calculate line height per line in paragraphs

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:

  • Add the Metrics struct with the glyph_height and line_height fields to the fonts module.
  • Add a metrics(font_size: u8) method to Font and a metrics() method to Style that return the scaled metrics.
  • Change render::TextSection::new to take a Metrics instance instead of a Style.
  • Update Paragraph::render to calculate the maximum Metrics per line and use them for the TextSection.
  • Update Paragraph documentation accordingly.
Status
RESOLVED IMPLEMENTED
Submitter
~ireas
Assigned to
No-one
Submitted
4 years ago
Updated
3 years ago
Labels
good first issue v0.3.0

~ireas referenced this from #31 3 years ago

~ap4sc 3 years ago

I can do this one as well

~ireas 3 years ago

That would be great! Let me know if anything is unclear or not working as expected.

~ap4sc 3 years ago*

Finished here:

https://git.sr.ht/~ap4sc/genpdf-rs/commit/67eb37c4cccba82a0a1330c0e357a7aff4ada4e1

However setting with_line_spacing on the Paragraph still doesn't seem to do anything. I'm not sure where to add this calculation in Paragraph render()

~ap4sc referenced this from #31 3 years ago

~ireas 3 years ago

Thanks! Can you please submit a patch? Then I’ll have a look at the line spacing issue.

~ireas REPORTED IMPLEMENTED 3 years ago

~ap4sc referenced this from #50 3 years ago

Register here or Log in to comment, or comment via email.