]> git.lyx.org Git - lyx.git/commitdiff
When drawing macro names, enforce LtR direction
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 22 Sep 2023 10:41:44 +0000 (12:41 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 22 Sep 2023 10:41:44 +0000 (12:41 +0200)
Add a Direction parameter to the Painter::text methods that take a
FontInfo parameter.

In drawStrRed and drawStrBlack, force the direction to LtR.

Fixes bug #12905.

src/frontends/NullPainter.h
src/frontends/Painter.h
src/frontends/qt/GuiPainter.cpp
src/frontends/qt/GuiPainter.h
src/mathed/MathSupport.cpp

index 3af85aa6b20b108a95eb2ad255e65308c8e78e97..bec16fa3274c5fe7da7a0b116525c4cba06e36b7 100644 (file)
@@ -65,10 +65,10 @@ public:
        void image(int, int, int, int, graphics::Image const &, bool) override {}
 
        /// draw a string
-       void text(int, int, docstring const &, FontInfo const &) override {}
+       void text(int, int, docstring const &, FontInfo const &, Direction const = Auto) override {}
 
        /// draw a char
-       void text(int, int, char_type, FontInfo const &) override {}
+       void text(int, int, char_type, FontInfo const &, Direction const = Auto) override {}
 
        /// draw a string
        void text(int, int, docstring const &, Font const &, double, double) override {}
index 41427ab3e0381bef664ef8039ee7900189a2a060..60953341aff45af69de064acf75a9f705392cc09 100644 (file)
@@ -134,11 +134,16 @@ public:
        virtual void image(int x, int y, int w, int h,
                graphics::Image const & image, bool const revert_in_darkmode = false) = 0;
 
+       // Direction for painting text
+       enum Direction { LtR, RtL, Auto };
+
        /// draw a string at position x, y (y is the baseline).
-       virtual void text(int x, int y, docstring const & str, FontInfo const & f) = 0;
+       virtual void text(int x, int y, docstring const & str, FontInfo const & f,
+                         Direction const dir = Auto) = 0;
 
        /// draw a char at position x, y (y is the baseline)
-       virtual void text(int x, int y, char_type c, FontInfo const & f) = 0;
+       virtual void text(int x, int y, char_type c, FontInfo const & f,
+                         Direction const dir = Auto) = 0;
 
        /** draw a string at position x, y (y is the baseline). The
         * text direction is enforced by the \c Font.
index 62e48c48b2fc29c86cc330929653248dc843fb24..7110910c3c812f0a0ac6302bb401fd635726f0c1 100644 (file)
@@ -282,15 +282,15 @@ void GuiPainter::image(int x, int y, int w, int h, graphics::Image const & i,
 }
 
 
-void GuiPainter::text(int x, int y, char_type c, FontInfo const & f)
+void GuiPainter::text(int x, int y, char_type c, FontInfo const & f, Direction const dir)
 {
-       text(x, y, docstring(1, c), f);
+       text(x, y, docstring(1, c), f, dir);
 }
 
 
-void GuiPainter::text(int x, int y, docstring const & s, FontInfo const & f)
+void GuiPainter::text(int x, int y, docstring const & s, FontInfo const & f, Direction const dir)
 {
-       text(x, y, s, f, Auto, 0.0, 0.0);
+       text(x, y, s, f, dir, 0.0, 0.0);
 }
 
 
index 522b83c65f51989e253dd3f3f052430b1468f8de..932072e481cba800d01c743995914f5b4f740bc8 100644 (file)
@@ -116,10 +116,12 @@ public:
                lyx::graphics::Image const & image, bool const darkmode = false) override;
 
        /// draw a string at position x, y (y is the baseline).
-       void text(int x, int y, docstring const & str, FontInfo const & f) override;
+       void text(int x, int y, docstring const & str, FontInfo const & f,
+                 Direction const dir = Auto) override;
 
        /// draw a char at position x, y (y is the baseline)
-       void text(int x, int y, char_type c, FontInfo const & f) override;
+       void text(int x, int y, char_type c, FontInfo const & f,
+                 Direction const dir = Auto) override;
 
        /** draw a string at position x, y (y is the baseline). The
         * text direction is enforced by the \c Font.
@@ -188,9 +190,6 @@ private:
                line_style ls = line_solid, int lw = thin_line,
                Qt::PenJoinStyle js = Qt::BevelJoin);
 
-       // Direction for painting text
-       enum Direction { LtR, RtL, Auto };
-
        // Real text() method
        void text(int x, int y, docstring const & s,
               FontInfo const & f, Direction const dir,
index 16019205f1106b4beadf25324f38770e86f13800..b71c46ee8f4b6409173973d48f8ac573778f841c 100644 (file)
@@ -805,7 +805,7 @@ void drawStrRed(PainterInfo & pi, int x, int y, docstring const & str)
        FontInfo f = pi.base.font;
        augmentFont(f, "mathnormal");
        f.setColor(Color_latex);
-       pi.pain.text(x, y, str, f);
+       pi.pain.text(x, y, str, f, Painter::LtR);
 }
 
 
@@ -814,7 +814,7 @@ void drawStrBlack(PainterInfo & pi, int x, int y, docstring const & str)
        FontInfo f = pi.base.font;
        augmentFont(f, "mathnormal");
        f.setColor(Color_foreground);
-       pi.pain.text(x, y, str, f);
+       pi.pain.text(x, y, str, f, Painter::LtR);
 }