Re: Problem printing text with wxWidgets 3.2.2.1
Fulvio Senore <[email protected]>
| Newsgroups | gmane.comp.lib.wxwindows.general |
|---|---|
| Message-ID | <[email protected]> |
Il 06/09/2023 22:01, Vadim Zeitlin ha scritto: > On Wed, 6 Sep 2023 18:47:48 +0200 Fulvio Senore wrote: > > > FS> It took me some time but I was able to solve the problem. > FS> > FS> In the printout, when doing scale computations, the sample uses > FS> > FS> GetPPIScreen(&ppiScreenX, &ppiScreenY); > FS> > FS> while I used > FS> > FS> wxScreenDC sdc; > FS> ppiScreenX = sdc.GetPPI().GetWidth(); > FS> ppiScreenY = sdc.GetPPI().GetHeight(); > FS> > FS> For some reason my code returned a higher PPI value when magnification > FS> is on, leading to smaller text. > > Well, if you use higher DPI for your screen, it's expected that wxScreenDC > returns a higher value, so I don't see any problem here. I agree. I just don't understand because wxPrintout::GetPPIScreen() returns a different value. > > FS> I still would like to know why wxPrintout::GetPPIScreen() and > FS> wxScreenDC::GetPPI() return different values. > FS> > FS> In my Windows computer now wxPrintout::GetPPIScreen() always return 96. > > This was changed in 1a1d19e93b (Improve print preview and printing with > high DPI, 2022-04-20) which was part of 3.1.7 and it looks like it > compensated for the problems previously introduced into this code when > adding high DPI support. You are probably right. Now I had to revert my code to the one used in older versions, before 3.1.3. > > I'm not sure if returning the standard DPI, as wxPrintout::GetPPIScreen() > does by default, is the right thing to do, but it looks like all its code > assumes that this is the case and we'd need to change a lot of things if we > changed this. To be honest, it's not clear at all why should wxPrintout > care about the screen DPI: after all, what's printed shouldn't depend on > whether you print it on a computer with a normal or high DPI monitor (and > what if you have both of them connected to the same computer, as I do right > now?). So I think that perhaps we should explain in the documentation that > wxPrintout "screen PPI" is not really screen PPI at all... And maybe we > should provide GetPrinterScaleFactor() or something like this to make it > unnecessary to use GetPPIScreen(), and GetPPIPrinter(), explicitly. > I must confess that many years ago, when I tried to write code to print text from wxWidgets, I read all the documentation and the sample source code. I did not understand anything so I simply copied some code from the sample: it happened to work, and I was happy. IMHO a feature that is very complicated and difficult to understand, just to accomplish a basic task, has some design flaws. It would be nice to just set the font size and print, like it happened with the venerable Visual Basic long time ago. Anyway, now I have my own code that works (usually) so I am satisfied. Regards Fulvio -- Please read https://www.wxwidgets.org/support/mlhowto.htm before posting. --- You received this message because you are subscribed to the Google Groups "wx-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/wx-users/6e8f6647-702d-37a3-babf-dd3b9265b7b9%40fsoft.it.