Forum Bugs

Subtle differences in font size causing `justify` blocks to break at different words

nwmd
Hi everyone!

First of all: I've checked the forums for similar-sounding issues but couldn't find a solution to my problem—if this has been discussed before, please let me know :)

We're working on a project that includes text-editing in the browser and are (happily) using Prince to convert the results to PDF. Lately, we've been noticing that font sizes in our result files appear to be a tiny bit smaller than in the browser; this becomes esp. noticeable when rendering multiple paragraphs of (small) text with `text-align: justify` as lines will start to break at different words.

I'm suspecting this _might_ be related to us using very small font sizes (e. g. 4px in the example) and scaling them up via `transform` causing rounding "errors" during the PDF conversion?

I've attached a screenshot showing the difference—font sizes are consistent across browsers but will "shrink" in the PDF—as well as a minimal input HTML file that allows to reproduce the issue.

We're converting with a plain `prince -o ./out.pdf ./in.html` (no additional stylesheets).

Any help would be highly appreciated, thank you very much in advance!

Best,
Nico
  1. Screenshot 2023-07-25 at 12.47.04 PM.png1.7 MB
    Browser vs. PDF
  2. test.html9.5 kB
    Sample HTML input
mikeday
It's difficult to guarantee the exact same line breaking behaviour due to slight differences in width calculation and rounding across different implementations, and that can still be an issue even without transforms.

With some further investigation it might be possible to identify the cause of this issue, for example the sixth line is the first to differ, could the kerning be varying around the punctuation, or is it something else?

However achieving identical output in every case may not be possible.