Followup to 9fe101e8: remove unused method.

This commit is contained in:
Jean-Marc Lasgouttes 2018-10-08 16:03:20 +02:00
parent 9fe101e890
commit 17e2ad927e
3 changed files with 3 additions and 48 deletions

View File

@ -260,6 +260,7 @@ GuiFontMetrics::getTextLayout(docstring const & s, bool const rtl,
QFont copy = font_;
copy.setWordSpacing(wordspacing);
ptl->setFont(copy);
// FIXME: This might not work in all cases. See breakAt_helper.
// Note that both setFlags and the enums are undocumented
ptl->setFlags(rtl ? Qt::TextForceRightToLeft : Qt::TextForceLeftToRight);
ptl->beginLayout();

View File

@ -284,47 +284,6 @@ void GuiPainter::text(int x, int y, docstring const & s, FontInfo const & f)
}
void GuiPainter::do_drawText(int x, int y, QString str,
GuiPainter::Direction const dir,
FontInfo const & f, QFont ff)
{
setQPainterPen(computeColor(f.realColor()));
if (font() != ff)
setFont(ff);
/* In LyX, the character direction is forced by the language.
* Therefore, we have to signal that fact to Qt.
*/
#if 1
/* Use unicode override characters to enforce drawing direction
* Source: http://www.iamcal.com/understanding-bidirectional-text/
*/
if (dir == RtL)
// Right-to-left override: forces to draw text right-to-left
str = QChar(0x202E) + str;
else if (dir == LtR)
// Left-to-right override: forces to draw text left-to-right
str = QChar(0x202D) + str;
drawText(x, y, str);
#else
/* This looks like a cleaner solution, but it has drawbacks
* - does not work reliably (Mac OS X, ...)
* - it is not really documented
* Keep it here for now, in case it can be helpful
*/
//This is much stronger than setLayoutDirection.
int flag = 0;
if (dir == RtL)
flag = Qt::TextForceRightToLeft;
else if (dir == LtR)
flag = Qt::TextForceLeftToRight;
drawText(x + ((dir == RtL) ? textwidth : 0), y - fm.maxAscent(), 0, 0,
flag | Qt::TextDontClip,
str);
#endif
}
void GuiPainter::text(int x, int y, docstring const & s,
FontInfo const & f, Direction const dir,
double const wordspacing, double const tw)
@ -369,11 +328,9 @@ void GuiPainter::text(int x, int y, docstring const & s,
setQPainterPen(computeColor(f.realColor()));
if (dir != Auto) {
shared_ptr<QTextLayout const> ptl =
fm.getTextLayout(s, dir == RtL, wordspacing);
auto ptl = fm.getTextLayout(s, dir == RtL, wordspacing);
ptl->draw(this, QPointF(x, y - fm.maxAscent()));
}
else {
} else {
if (font() != ff)
setFont(ff);
drawText(x, y, str);

View File

@ -184,9 +184,6 @@ private:
// Direction for painting text
enum Direction { LtR, RtL, Auto };
// Helper for text() method
void do_drawText(int x, int y, QString str, Direction dir, FontInfo const & f, QFont ff);
// Real text() method
void text(int x, int y, docstring const & s,
FontInfo const & f, Direction const dir,