[LyX/master] Amend 08b4a01fd33f
Udi Fogiel
ufogiel at lyx.org
Sat Aug 15 01:10:41 UTC 2026
commit db168dc6bba9c33603eec5045aeec7569f3d21dc
Author: Udi Fogiel <ufogiel at lyx.org>
Date: Sat Aug 15 03:23:19 2026 +0300
Amend 08b4a01fd33f
That commit forced LtR direction on mathed glyph draws to fix #12928,
but this also routed them through Qt's text shaping (QTextLayout),
which corrupts raw glyph-index symbols such as \int that are
not real Unicode text. Decouple direction enforcement from shaping in
GuiPainter::text() so mathed keeps forced LtR ordering without
triggering the shaper.
---
src/frontends/qt/GuiPainter.cpp | 12 +++++++++---
src/frontends/qt/GuiPainter.h | 3 ++-
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/frontends/qt/GuiPainter.cpp b/src/frontends/qt/GuiPainter.cpp
index 0121fe5dfc..600bcfa20f 100644
--- a/src/frontends/qt/GuiPainter.cpp
+++ b/src/frontends/qt/GuiPainter.cpp
@@ -290,14 +290,14 @@ void GuiPainter::text(int x, int y, char_type c, FontInfo const & f, Direction c
void GuiPainter::text(int x, int y, docstring const & s, FontInfo const & f, Direction const dir)
{
- text(x, y, s, f, dir, 0.0, 0.0);
+ text(x, y, s, f, dir, 0.0, 0.0, false, false);
}
void GuiPainter::text(int x, int y, docstring const & s,
FontInfo const & f, Direction const dir,
double const wordspacing, double const tw,
- bool const invert)
+ bool const invert, bool const shape)
{
//LYXERR0("text: x=" << x << ", s=" << s);
if (s.empty())
@@ -336,11 +336,17 @@ void GuiPainter::text(int x, int y, docstring const & s,
// Brighten that for workarea display (#13218)
rc.mergeColor = Color_foreground;
setQPainterPen(computeColor(rc));
- if (dir != Auto) {
+ if (dir != Auto && shape) {
auto ptl = fm.getTextLayout(s, dir == RtL, wordspacing);
QTextLine const & tline = ptl->lineForTextPosition(0);
ptl->draw(this, QPointF(x, y - tline.ascent()));
} else {
+ if (dir == Auto)
+ setLayoutDirection(Qt::LayoutDirectionAuto);
+ else if (dir == RtL)
+ setLayoutDirection(Qt::RightToLeft);
+ else
+ setLayoutDirection(Qt::LeftToRight);
if (font() != ff)
setFont(ff);
drawText(x, y, str);
diff --git a/src/frontends/qt/GuiPainter.h b/src/frontends/qt/GuiPainter.h
index abc4df9065..9b193b3cfd 100644
--- a/src/frontends/qt/GuiPainter.h
+++ b/src/frontends/qt/GuiPainter.h
@@ -202,10 +202,11 @@ private:
Qt::PenJoinStyle js = Qt::BevelJoin);
// Real text() method
+ // shape = false skips Qt's text shaper for raw math glyph draws.
void text(int x, int y, docstring const & s,
FontInfo const & f, Direction const dir,
double const wordspacing, double tw,
- bool const invert = false);
+ bool const invert = false, bool const shape = true);
QColor current_color_;
Painter::line_style current_ls_;
More information about the lyx-cvs
mailing list