commit 08b4a01fd33f964b84f9004df652a5060105e615
Author: Udi Fogiel <[email protected]>
Date:   Sun Aug 2 17:46:23 2026 +0300

    force LTR direction in mathed draw
    
    fixes #12928
---
 src/MetricsInfo.cpp                   | 10 ++++++----
 src/MetricsInfo.h                     |  8 ++++----
 src/mathed/InsetMathBrace.cpp         |  4 ++--
 src/mathed/InsetMathChar.cpp          |  6 +++---
 src/mathed/InsetMathHull.cpp          |  4 ++--
 src/mathed/InsetMathMacro.cpp         | 10 +++++-----
 src/mathed/InsetMathMacroTemplate.cpp |  2 +-
 src/mathed/InsetMathNumber.cpp        |  2 +-
 src/mathed/InsetMathScript.cpp        |  2 +-
 src/mathed/InsetMathSpecialChar.cpp   |  4 ++--
 src/mathed/InsetMathString.cpp        |  2 +-
 src/mathed/MathRow.cpp                |  6 +++---
 src/mathed/MathSupport.cpp            |  4 ++--
 13 files changed, 33 insertions(+), 31 deletions(-)

diff --git a/src/MetricsInfo.cpp b/src/MetricsInfo.cpp
index faca0ea183..484f6be0c6 100644
--- a/src/MetricsInfo.cpp
+++ b/src/MetricsInfo.cpp
@@ -205,15 +205,17 @@ PainterInfo::PainterInfo(BufferView * bv, 
lyx::frontend::Painter & painter)
 {}
 
 
-void PainterInfo::draw(int x, int y, char_type c)
+void PainterInfo::mathDraw(int x, int y, char_type c)
 {
-       pain.text(x, y, c, base.font);
+       // Math content is always LTR.
+       pain.text(x, y, c, base.font, frontend::Painter::LtR);
 }
 
 
-void PainterInfo::draw(int x, int y, docstring const & str)
+void PainterInfo::mathDraw(int x, int y, docstring const & str)
 {
-       pain.text(x, y, str, base.font);
+       // Math content is always LTR.
+       pain.text(x, y, str, base.font, frontend::Painter::LtR);
 }
 
 
diff --git a/src/MetricsInfo.h b/src/MetricsInfo.h
index 1cb4554b69..4c340dbaa7 100644
--- a/src/MetricsInfo.h
+++ b/src/MetricsInfo.h
@@ -122,10 +122,10 @@ class PainterInfo {
 public:
        ///
        PainterInfo(BufferView * bv, frontend::Painter & pain);
-       ///
-       void draw(int x, int y, char_type c);
-       ///
-       void draw(int x, int y, docstring const & str);
+       /// Draw a math character (always LTR, mathed-only)
+       void mathDraw(int x, int y, char_type c);
+       /// Draw a math string (always LTR, mathed-only)
+       void mathDraw(int x, int y, docstring const & str);
        /// Draw preedit char using char_format_index for format
        /// f is used to get the font size in the text mode of mathed
        void draw(int x, int y, char_type c, frontend::InputMethod * im,
diff --git a/src/mathed/InsetMathBrace.cpp b/src/mathed/InsetMathBrace.cpp
index 3a3d4034c3..c4c74ab34b 100644
--- a/src/mathed/InsetMathBrace.cpp
+++ b/src/mathed/InsetMathBrace.cpp
@@ -69,10 +69,10 @@ void InsetMathBrace::draw(PainterInfo & pi, int x, int y) 
const
        font.setShape(UP_SHAPE);
        font.setColor(Color_latex);
        Dimension t = theFontMetrics(font).dimension('{');
-       pi.pain.text(x, y, '{', font);
+       pi.pain.text(x, y, '{', font, frontend::Painter::LtR);
        cell(0).draw(pi, x + t.wid, y);
        Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
-       pi.pain.text(x + t.wid + dim0.width(), y, '}', font);
+       pi.pain.text(x + t.wid + dim0.width(), y, '}', font, 
frontend::Painter::LtR);
 }
 
 
diff --git a/src/mathed/InsetMathChar.cpp b/src/mathed/InsetMathChar.cpp
index 84c0be9a09..bcfc5fd383 100644
--- a/src/mathed/InsetMathChar.cpp
+++ b/src/mathed/InsetMathChar.cpp
@@ -165,7 +165,7 @@ void InsetMathChar::draw(PainterInfo & pi, int x, int y) 
const
                        return;
                } else if (!slanted(char_) && pi.base.fontname == "mathnormal") 
{
                        Changer dummy = pi.base.font.changeShape(UP_SHAPE);
-                       pi.draw(x, y, char_);
+                       pi.mathDraw(x, y, char_);
                        return;
                } else if (!isASCII(char_) && 
Encodings::unicodeCharInfo(char_).isUnicodeSymbol()) {
                        bool special_font = (pi.base.fontname == "mathbb" ||
@@ -179,7 +179,7 @@ void InsetMathChar::draw(PainterInfo & pi, int x, int y) 
const
                        Changer dummy2 = Encodings::isMathAlpha(char_)
                                ? noChange()
                                : pi.base.font.changeShape(UP_SHAPE);
-                       pi.draw(x, y, char_);
+                       pi.mathDraw(x, y, char_);
                        return;
                }
        }
@@ -187,7 +187,7 @@ void InsetMathChar::draw(PainterInfo & pi, int x, int y) 
const
        if (pi.base.fontname == "mathnormal") {
                x += max(-theFontMetrics(pi.base.font).lbearing(char_), 0);
        }
-       pi.draw(x, y, char_);
+       pi.mathDraw(x, y, char_);
 }
 
 
diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index e1638a3493..7b73455987 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -698,7 +698,7 @@ void InsetMathHull::draw(PainterInfo & pi, int x, int y) 
const
                                pi.pain.fillRectangle(pi.leftx, yy - dimnl.asc,
                                        dimnl.width(), dimnl.height(),
                                        pi.selected_left ? Color_selection : 
pi.background_color);
-                               pi.draw(pi.leftx, yy, nl);
+                               pi.mathDraw(pi.leftx, yy, nl);
                        } else {
                                ColorCode const col = pi.selected_right
                                        ? Color_selectiontext
@@ -709,7 +709,7 @@ void InsetMathHull::draw(PainterInfo & pi, int x, int y) 
const
                                pi.pain.fillRectangle(pi.rightx - dimnl.wid, yy 
- dimnl.asc,
                                        dimnl.width(), dimnl.height(),
                                        pi.selected_right ? Color_selection : 
pi.background_color);
-                               pi.draw(pi.rightx - dimnl.wid, yy, nl);
+                               pi.mathDraw(pi.rightx - dimnl.wid, yy, nl);
                        }
                }
        }
diff --git a/src/mathed/InsetMathMacro.cpp b/src/mathed/InsetMathMacro.cpp
index 8495b53b2c..c8b92b984f 100644
--- a/src/mathed/InsetMathMacro.cpp
+++ b/src/mathed/InsetMathMacro.cpp
@@ -755,10 +755,10 @@ void InsetMathMacro::draw(PainterInfo & pi, int x, int y) 
const
 
        if (d->displayMode_ == DISPLAY_INIT || d->displayMode_ == 
DISPLAY_INTERACTIVE_INIT) {
                Changer dummy = pi.base.changeFontSet("lyxtex");
-               pi.pain.text(x, y, from_ascii("\\") + name(), pi.base.font);
+               pi.pain.text(x, y, from_ascii("\\") + name(), pi.base.font, 
frontend::Painter::LtR);
        } else if (d->displayMode_ == DISPLAY_UNFOLDED) {
                Changer dummy = pi.base.changeFontSet("lyxtex");
-               pi.pain.text(x, y, from_ascii("\\"), pi.base.font);
+               pi.pain.text(x, y, from_ascii("\\"), pi.base.font, 
frontend::Painter::LtR);
                x += mathed_string_width(pi.base.font, from_ascii("\\")) + 1;
                cell(0).draw(pi, x, y);
        } else if (lyxrc.macro_edit_style == LyXRC::MACRO_EDIT_LIST
@@ -777,7 +777,7 @@ void InsetMathMacro::draw(PainterInfo & pi, int x, int y) 
const
 
                // draw label
                docstring label = from_ascii("Macro \\") + name() + 
from_ascii(": ");
-               pi.pain.text(x, y, label, labelFont);
+               pi.pain.text(x, y, label, labelFont, frontend::Painter::LtR);
                x += mathed_string_width(labelFont, label);
 
                // draw definition
@@ -798,9 +798,9 @@ void InsetMathMacro::draw(PainterInfo & pi, int x, int y) 
const
 
                        // draw label
                        str[1] = '1' + i;
-                       pi.pain.text(x, y, str, labelFont);
+                       pi.pain.text(x, y, str, labelFont, 
frontend::Painter::LtR);
                        x += strw1;
-                       pi.pain.text(x, y, from_ascii(":"), labelFont);
+                       pi.pain.text(x, y, from_ascii(":"), labelFont, 
frontend::Painter::LtR);
                        x += strw2;
 
                        // draw parameter
diff --git a/src/mathed/InsetMathMacroTemplate.cpp 
b/src/mathed/InsetMathMacroTemplate.cpp
index 1d73fd2cf4..9f8d7c90c7 100644
--- a/src/mathed/InsetMathMacroTemplate.cpp
+++ b/src/mathed/InsetMathMacroTemplate.cpp
@@ -386,7 +386,7 @@ void InsetNameWrapper::draw(PainterInfo & pi, int x, int y) 
const
        Changer dummy2 = pi.base.font.changeColor(color);
 
        // draw backslash
-       pi.pain.text(x, y, from_ascii("\\"), pi.base.font);
+       pi.pain.text(x, y, from_ascii("\\"), pi.base.font, 
frontend::Painter::LtR);
        x += mathed_string_width(pi.base.font, from_ascii("\\"));
 
        // draw name
diff --git a/src/mathed/InsetMathNumber.cpp b/src/mathed/InsetMathNumber.cpp
index 80f13c4c2e..c54a4637d8 100644
--- a/src/mathed/InsetMathNumber.cpp
+++ b/src/mathed/InsetMathNumber.cpp
@@ -40,7 +40,7 @@ void InsetMathNumber::metrics(MetricsInfo & mi, Dimension & 
dim) const
 
 void InsetMathNumber::draw(PainterInfo & pi, int x, int y) const
 {
-       pi.draw(x, y, str_);
+       pi.mathDraw(x, y, str_);
 }
 
 
diff --git a/src/mathed/InsetMathScript.cpp b/src/mathed/InsetMathScript.cpp
index 1ccdf4f3cc..05a74ac377 100644
--- a/src/mathed/InsetMathScript.cpp
+++ b/src/mathed/InsetMathScript.cpp
@@ -353,7 +353,7 @@ void InsetMathScript::draw(PainterInfo & pi, int x, int y) 
const
        else {
                nuc().setXY(bv, x + dxx(bv), y);
                if (editing(&bv))
-                       pi.draw(x + dxx(bv), y, char_type('.'));
+                       pi.mathDraw(x + dxx(bv), y, char_type('.'));
        }
        Changer dummy = pi.base.changeScript();
        if (hasUp())
diff --git a/src/mathed/InsetMathSpecialChar.cpp 
b/src/mathed/InsetMathSpecialChar.cpp
index e416dd6f3e..571503eb05 100644
--- a/src/mathed/InsetMathSpecialChar.cpp
+++ b/src/mathed/InsetMathSpecialChar.cpp
@@ -69,9 +69,9 @@ void InsetMathSpecialChar::draw(PainterInfo & pi, int x, int 
y) const
 {
        if (pi.base.fontname == "mathnormal") {
                Changer dummy = pi.base.font.changeShape(UP_SHAPE);
-               pi.draw(x, y, char_);
+               pi.mathDraw(x, y, char_);
        } else {
-               pi.draw(x, y, char_);
+               pi.mathDraw(x, y, char_);
        }
 }
 
diff --git a/src/mathed/InsetMathString.cpp b/src/mathed/InsetMathString.cpp
index 31dc0cabf5..64f9a7e1de 100644
--- a/src/mathed/InsetMathString.cpp
+++ b/src/mathed/InsetMathString.cpp
@@ -46,7 +46,7 @@ void InsetMathString::metrics(MetricsInfo & mi, Dimension & 
dim) const
 
 void InsetMathString::draw(PainterInfo & pi, int x, int y) const
 {
-       pi.draw(x, y, str_);
+       pi.mathDraw(x, y, str_);
 }
 
 
diff --git a/src/mathed/MathRow.cpp b/src/mathed/MathRow.cpp
index be454a80a3..6ace5403cb 100644
--- a/src/mathed/MathRow.cpp
+++ b/src/mathed/MathRow.cpp
@@ -117,7 +117,7 @@ void drawMarkers(PainterInfo const & pi, MathRow::Element 
const & e,
                mathed_string_dim(font, e.inset->name(), namedim);
                pi.pain.fillRectangle(l, y + dim.des - namedim.height() - 2,
                                      dim.wid, namedim.height() + 2, 
Color_mathmacrobg);
-               pi.pain.text(l, y + dim.des - namedim.des - 1, e.inset->name(), 
font);
+               pi.pain.text(l, y + dim.des - namedim.des - 1, e.inset->name(), 
font, frontend::Painter::LtR);
        }
 
        // Color for corners
@@ -408,12 +408,12 @@ void MathRow::draw(PainterInfo & pi, int x, int const y) 
const
                        f.setColor(Color_inlinecompletion);
                        // offset the text by e.after to make sure that the
                        // spacing is after the completion, not before.
-                       pi.pain.text(x - e.after, y, s1, f);
+                       pi.pain.text(x - e.after, y, s1, f, 
frontend::Painter::LtR);
                        x += mathed_string_width(f, s1);
                }
                if (!s2.empty()) {
                        f.setColor(Color_nonunique_inlinecompletion);
-                       pi.pain.text(x - e.after, y, s2, f);
+                       pi.pain.text(x - e.after, y, s2, f, 
frontend::Painter::LtR);
                        x += mathed_string_width(f, s2);
                }
        }
diff --git a/src/mathed/MathSupport.cpp b/src/mathed/MathSupport.cpp
index 920a15c828..8a0475c56d 100644
--- a/src/mathed/MathSupport.cpp
+++ b/src/mathed/MathSupport.cpp
@@ -814,9 +814,9 @@ void mathedSymbolDraw(PainterInfo & pi, int x, int y, 
latexkeys const * sym)
                                 pi.base.fontname != "mathcal" &&
                                 pi.base.fontname != "mathscr");
        Changer dummy = change_font ? pi.base.changeFontSet(font) : noChange();
-       pi.draw(x, y, mathedSymbol(pi.base, sym));
+       pi.mathDraw(x, y, mathedSymbol(pi.base, sym));
        if (bold_upcase_greek)
-               pi.draw(x + 1, y, mathedSymbol(pi.base, sym));
+               pi.mathDraw(x + 1, y, mathedSymbol(pi.base, sym));
 }
 
 
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to