]> git.lyx.org Git - features.git/commitdiff
Fix bug 3181.
authorEnrico Forestieri <forenr@lyx.org>
Thu, 1 Feb 2007 03:56:23 +0000 (03:56 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Thu, 1 Feb 2007 03:56:23 +0000 (03:56 +0000)
* src/frontends/qt4/QLPainter.C
(QLPainter::text): Render the symbol whose codepoint is 0x00ad
through a one-column QTextLine in order to fool Qt, which displays
what it thinks is a soft-hyphen only when occurring at a line-break.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16997 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/QLPainter.C

index d16525fc65399a8e7db43e7ec490709616b6c949..c0090210b29e09fa9255f282a3dd4f6525f23b02 100644 (file)
@@ -11,6 +11,8 @@
 
 #include <config.h>
 
+#include <QTextLayout>
+
 #include "QLPainter.h"
 
 #include "GuiApplication.h"
@@ -240,7 +242,21 @@ int QLPainter::text(int x, int y, char_type const * s, size_t ls,
                                lyxerr[Debug::PAINTING] << "draw " << std::string(str.toUtf8())
                                        << " at " << x << "," << y << std::endl;
                        }
-                       drawText(x, y, str);
+                       // Qt4 does not display a glyph whose codepoint is the
+                       // same as that of a soft-hyphen (0x00ad), unless it
+                       // occurs at a line-break. As a kludge, we force Qt to
+                       // render this glyph using a one-column line.
+                       if (ls == 1 && str[0].unicode() == 0x00ad) {
+                               QTextLayout adsymbol(str);
+                               adsymbol.setFont(fi.font);
+                               adsymbol.beginLayout();
+                               QTextLine line = adsymbol.createLine();
+                               line.setNumColumns(1);
+                               line.setPosition(QPointF(0, -line.ascent()));
+                               adsymbol.endLayout();
+                               line.draw(this, QPointF(x, y));
+                       } else
+                               drawText(x, y, str);
                }
                // Here we use the font width cache instead of
                //   textwidth = fontMetrics().width(str);