Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.11.2
-
None
Description
The attached zip file textedit-with-stretch.zip contains a lightly modified version of the standard TextEdit example project. Two additional spinboxes have been added to the toolbar: one sets font stretch on the selected text, and the other sets letter spacing on the selected text.
1. Build and run the project.
2. Select the QTextEdit text on the first line of the example document.
3. Set its font size to (say) 36pt.
4. Using the font stretch spin box, set its stretch to (say) 300.
EXPECTED: The selected text is shown with an appropriate stretch factor, and all other text in the display is unaffected.
ACTUAL: As expected.
5. Click the Export PDF button on the toolbar, and provide a suitable filename and location.
6. Open the resulting PDF.
EXPECTED: The PDF looks the same as the on-screen display.
ACTUAL: The stretched text is stretched as expected, but all of the subsequent Helvetica Bold text in the document is also stretched, and all of the characters overlap because each character is at its original, unstretched position.
In the supplied example project, you can also flip m_UsePDFWriter to false in textedit.h and recompile to use QPrinter rather than QPdfWriter to produce the PDF. You will see similar results.
My hypothesis is that there's some kind of font caching going on down in QPainter that is not taking factors like font stretch into account, meaning that QPainter is assuming that it can reuse a font it has already cached because its family (Helvetica) and weight (bold) is the same as an existing one.