Fix bug 3181.

* 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
This commit is contained in:
Enrico Forestieri 2007-02-01 03:56:23 +00:00
parent d85bdf6d45
commit bdbe6d3d7d

View 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);