Bug 28161 - Text Scaling Inconsistent for Windows Print Preview
Summary: Text Scaling Inconsistent for Windows Print Preview
Status: RESOLVED MOVED
Alias: None
Product: cairo
Classification: Unclassified
Component: win32 backend (show other bugs)
Version: 1.9.7
Hardware: x86 (IA32) Windows (All)
: medium normal
Assignee: cairo-bugs mailing list
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-18 11:44 UTC by Brent Fulgham
Modified: 2018-08-25 13:59 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Screen display of example (79.95 KB, image/png)
2010-05-18 11:44 UTC, Brent Fulgham
Details
Print Preview at 'full page' level (72.31 KB, image/png)
2010-05-18 11:45 UTC, Brent Fulgham
Details
Print Preview at maximum zoom level (72.70 KB, image/png)
2010-05-18 11:45 UTC, Brent Fulgham
Details
Example project demonstrating the problem (84.64 KB, application/octet-stream)
2010-05-18 11:48 UTC, Brent Fulgham
Details
Example project demonstrating the problem. (80.47 KB, application/octet-stream)
2010-05-18 13:34 UTC, Brent Fulgham
Details
Win32-only Test (20.18 KB, application/octet-stream)
2010-05-18 14:11 UTC, Brent Fulgham
Details
Scaled Context example (123.24 KB, image/png)
2010-05-18 14:13 UTC, Brent Fulgham
Details

Description Brent Fulgham 2010-05-18 11:44:45 UTC
Created attachment 35729 [details]
Screen display of example

If you use the Print Preview context provided by MFC with Cairo, text elements are not scaled the same way as other parts of the Cairo scene.

The attached example displays the following:
1.  The text "Drawn With cairo_show_glyphs", drawn with the API call 'cairo_show_glyphs'.
2.  The text "cairo_text_path", drawn with the API call 'cairo_text_path'
3.  The text "cairo_show_text", drawn with the API call 'cairo_show_text'

The attached image "Screen.PNG" shows what this example looks like on screen.
The attached image "Preview_Max.PNG" shows the print preview displaying the full printed page.
The attached image "Preview_Zoomed.PNG" shows the print preview at maximum zoom.

As you can see, the scaling of the text is not consistent at the different zoom levels.  The text generated by 'cairo_show_text' and 'cairo_show_glyphs' seem to be rendered at a consistent size no matter what zoom level is used in the preview.
Comment 1 Brent Fulgham 2010-05-18 11:45:27 UTC
Created attachment 35730 [details]
Print Preview at 'full page' level
Comment 2 Brent Fulgham 2010-05-18 11:45:57 UTC
Created attachment 35731 [details]
Print Preview at maximum zoom level
Comment 3 Brent Fulgham 2010-05-18 11:48:34 UTC
Created attachment 35732 [details]
Example project demonstrating the problem

Unfortunately, this is an MFC application example.  However, it's the best approximation to the application where the problem was originally noticed.
Comment 4 Brent Fulgham 2010-05-18 13:34:01 UTC
Created attachment 35739 [details]
Example project demonstrating the problem.

Scaled down with less visual-studio generated cruft.

All the drawing logic is in the file 'cairo_test.cpp', and consists of some sample code from the cairographics.org website, and the glyph test code from the cairo sources.

The only other file of interest is 'Cairo_Preview_TestView.cpp', in its "OnDraw" function.  This sets up a drawing context (either a print surface or a display surface) and performs the drawing.

Setup of the HDC used in printing, display, or previewing is done somewhere in the bowels of the MFC runtime.
Comment 5 Brent Fulgham 2010-05-18 14:11:53 UTC
Created attachment 35740 [details]
Win32-only Test

The attached test project illustrates the problem outside of MFC, using only win32 calls.  Basically, I hijacked the "About" menu item to display a dialog with a scaled version of the main drawing, pretending that it was being drawn to a device with four times greater resolution.

The attached "Scaled_Contents.PNG" shows what the two views look like.  As you can see, the 'scaled' view has inconsistent font scales.
Comment 6 Brent Fulgham 2010-05-18 14:13:34 UTC
Created attachment 35741 [details]
Scaled Context example

Shows the main drawing context and a 'scaled' context side-by-side.  Note that the different text sections in the scaled context are not drawn the same way.
Comment 7 Brent Fulgham 2010-05-19 09:05:03 UTC
As adrianj pointed out on IRC, this issue can be worked around by extracting the scale from the HDC, reset the HDC scale to identity, and setting the scale in the cairo context.

This is the solution I eventually used http://whtconstruct.blogspot.com/2010/05/successful-print-preview.html.
Comment 8 GitLab Migration User 2018-08-25 13:59:17 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/cairo/cairo/issues/302.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.