hoehrmann / CutyCapt

A Qt WebKit Web Page Rendering Capture Utility
http://cutycapt.sourceforge.net/
99 stars 49 forks source link

Kerning is strange at small font sizes #16

Open hakanai opened 9 years ago

hakanai commented 9 years ago

Given a fairly simple HTML with no style of its own:

<html>
  <head>
    <title></title>
  </head>
  <body>
    <p>This is just one sentence for testing.</p>
  </body>
</html>

Providing the user stylesheet:

--user-style-string=html{font-family:Helvetica;font-size:11pt;line-height:1.0}

The kerning comes out looking very uneven, but if I make the font much larger:

--user-style-string=html{font-family:Helvetica;font-size:40pt;line-height:1.0}

Now it looks perfect.

I get the feeling that the comment about changing the quality settings for the QPrinter is relevant. Perhaps webkit thinks it's rendering to a 72dpi device, so it's moving letters to align them with the pixels, even though it shouldn't?

Screenshot of the 11pt version zoomed in vs. the 40pt version:

screen shot 2015-01-21 at 9 26 37 am

hakanai commented 9 years ago

It seems I'm not the first to notice this quirk and it supposedly behaves differently depending on the display resolution, even though that should not affect printing.

http://www.qtcentre.org/threads/18007-QPrinter-amp-QPainter-Font-Differences-Between-LInux-and-WIndows

http://stackoverflow.com/questions/10299633/qtextdocumentdrawcontents-only-renders-at-96-dpi (the accepted answer here might fix it)

hoehrmann commented 9 years ago

Does this only affect PDF output?

hakanai commented 9 years ago

Good question. We only use PDF output.

Edit: And I can't seem to see the command-line parameter to choose the DPI for a PNG, so I'm not sure how I could compare it.