Opened 12 months ago

Last modified 10 months ago

#18475 confirmed defect

Printing text sizes decreased in wxWidgets 3.1.2 and vary by screen density

Reported by: jpd236 Owned by:
Priority: normal Milestone:
Component: printing Version: 3.1.2
Keywords: printing wxOSX Cc:
Blocked By: Blocking:
Patch: no

Description

link to original discussion

I'm testing printing on my Mac running Mojave and the printing sample by going to File -> Print... -> Save as PDF. From 3.1.0 -> 3.1.2, the text sizes have all decreased significantly. Moreover, if I change my screen resolution to one with a higher density, the text gets even smaller. The size of the text in the generated PDF should not change based on the screen density, assuming it is scaled using some reasonable mechanism; a font size in points should always be the same size when printed on a page because points are absolute units. However, it seems that:

(a) From 3.1.0 -> 3.1.2, a fix was made to return the right density from GetScreenPPI. This seems like a step in the right direction, but with no other changes, the scaled print DC draws smaller text.

(b) With 3.1.2, when changing screen resolution from the default Retina resolution to a scaled higher resolution, the text gets even smaller. The DPI increases, but nothing else changes about the print DC, so the text is scaled down even further.

It should be possible to configure printing such that a 10pt font is rendered at that exact absolute size on the page, regardless of the screen parameters.

Attachments (3)

wxWidgets-3.1.0.pdf download (33.1 KB) - added by jpd236 12 months ago.
Sample PDF generated with wxWidgets-3.1.0
wxWidgets-3.1.2-defaultResolution.pdf download (26.6 KB) - added by jpd236 12 months ago.
Sample PDF generated with wxWidgets-3.1.2, default screen resolution
wxWidgets-3.1.2-moreSpaceResolution.pdf download (26.6 KB) - added by jpd236 12 months ago.
Sample PDF generated with wxWidgets-3.1.2, "more space" screen resolution

Download all attachments as: .zip

Change History (8)

Changed 12 months ago by jpd236

Sample PDF generated with wxWidgets-3.1.0

Changed 12 months ago by jpd236

Sample PDF generated with wxWidgets-3.1.2, default screen resolution

Changed 12 months ago by jpd236

Sample PDF generated with wxWidgets-3.1.2, "more space" screen resolution

comment:1 Changed 10 months ago by vadz

  • Milestone 3.1.3 deleted

Do the PDFs appear differently under macOS than under MSW? For me, under MSW, the 2 wx 3.1.2 PDFs look identical. Not only the text, but all the other elements are pixel-by-pixel the same.

And while it's true that the text is smaller in 3.1.2 PDFs compared to 3.1.0 one, everything else is smaller too, so I'm not sure if it's actually wrong.

Looking at the PDFs themselves (after uncompressing), 3.1.0 and 3.1.2 ones seem to be using the same fonts and the same font setting command (/TT1 1 Tf) too, while the 2 3.1.2 PDFs use the identical text drawing commands as well -- no wonder they appear identical to me.

Could you have uploaded the wrong file somehow? Because I definitely don't see anything wrong with the 3.1.2 PDFs on their own. I do see a difference between them and the 3.1.0 one but, again, I'm not sure which one is actually correct.

comment:2 Changed 10 months ago by jpd236

  • Cc jpd236@… added

Thanks for taking a look. The first page of the two 3.1.2 PDFs looks identical to me, but the second page is different. The fonts are smaller, the lines are thinner, and the positioning isn't the same. Were you looking at the second page, or just the first?

(I'm on Mac right now, but could double check Windows later, though I imagine it's the same regardless of platform when viewing the PDF).

comment:3 Changed 10 months ago by MaartenB

It is also noticeable in the page numbering. I encountered this too when simplifying wxGDIPlusPrintingContext (on Windows).
When saving the PDF on a high-dpi screen, the page numbering is smaller. Because this was already present before my changes, I did not look further into it.

comment:4 Changed 10 months ago by vadz

  • Status changed from new to confirmed

Oh, sorry, I didn't realize the differences were on the page two. I definitely see the difference there.

If you look at MyPrintout::DrawPageTwo() in the sample, it does its own calculations using printer and screen DPI and apparently it intentionally tries to make the print output to be of the same size as what is shown on the screen. This is a pretty weird thing to do because IMO the output on the printer should not depend on the screen DPI at all. And it's also not impossible that there is a mistake in the sample code.

Does the actual code of your application do something like this too? I'd say that the real test is whether 10pt font used on the first page results in the same output as using 10pt font in any native Mac application and creating a PDF from it. Unfortunately this doesn't look good for wx neither, as my understanding is that 10pt font should be 10px high when viewing PDF at 100% on a 96DPI system like mine. While in the attached PDFs it's 19px high instead.

comment:5 Changed 10 months ago by jpd236

  • Cc jpd236@… removed

Yes, our app does basically the same thing - indeed, based on the code comments there, I'm fairly sure it was copy-pasted from the sample and adapted.

I might have made faulty assumptions here in terms of how I'd expect this to work. I did a quick test drawing 10pt text with all of the scaling code removed and it seems to behave independently of the screen density and also looks to be about the same size as when I print a simple Google Docs document with 10pt text to a PDF.

So this might be mostly working as intended - not sure what 10pt font you are looking at from the attached PDFs, but the message on the first page is scaled up from the original to fit the page, and messages on the second page are scaled to match screen density, so it does make sense to me that neither of these would actually represent 10pt text in reality.

Note: See TracTickets for help on using tickets.