From d6993e7d88750a55d62bf5acbe7e7d03069dfbdf Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 9 Sep 2009 14:27:18 +0200 Subject: Avoid garbled output on Windows for non-ascii-compatible text In the Windows print engine, we try to send a text item as a raw string of characters to the printer driver if this is possible. This is to facilitate using PDF-printers as much as possible, allowing them to save the text in the document so for searching etc. We can only safely do this if all the characters in the string are ASCII-compatible, i.e. in the 7 bit range, since this is the only part of the set which is guaranteed to be compatible across code pages. Task-number: 180655 Reviewed-by: Trond --- src/gui/painting/qprintengine_win.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gui/painting/qprintengine_win.cpp b/src/gui/painting/qprintengine_win.cpp index d239581..96e8cff 100644 --- a/src/gui/painting/qprintengine_win.cpp +++ b/src/gui/painting/qprintengine_win.cpp @@ -400,11 +400,11 @@ void QWin32PrintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem return ; } - // We only want to convert the glyphs to text if the entire string is latin1 - bool latin1String = true; + // We only want to convert the glyphs to text if the entire string is compatible with ASCII + bool convertToText = true; for (int i=0; i < ti.num_chars; ++i) { - if (ti.chars[i].unicode() >= 0x100) { - latin1String = false; + if (ti.chars[i].unicode() >= 0x80) { + convertToText = false; break; } } @@ -414,7 +414,7 @@ void QWin32PrintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem SelectObject(d->hdc, CreatePen(PS_SOLID, 1, cf)); SetTextColor(d->hdc, cf); - draw_text_item_win(p, ti, d->hdc, latin1String, d->matrix, d->devPaperRect.topLeft()); + draw_text_item_win(p, ti, d->hdc, convertToText, d->matrix, d->devPaperRect.topLeft()); DeleteObject(SelectObject(d->hdc,GetStockObject(HOLLOW_BRUSH))); DeleteObject(SelectObject(d->hdc,GetStockObject(BLACK_PEN))); } -- cgit v0.12