]> git.lyx.org Git - features.git/commitdiff
Better handling for negative position in pos2x
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 20 Feb 2017 14:39:28 +0000 (15:39 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 20 Feb 2017 14:39:28 +0000 (15:39 +0100)
This code is already in stable actually. The old one does not work
well in RtL text.

src/frontends/qt4/GuiFontMetrics.cpp

index 2ab182ec33aef23aaae29fb47facd24b0d527181..512e8771b69f68214cca5759ff355de219a41ade 100644 (file)
@@ -261,11 +261,11 @@ GuiFontMetrics::getTextLayout(docstring const & s, bool const rtl,
 }
 
 
-int GuiFontMetrics::pos2x(docstring const & s, int const pos, bool const rtl,
+int GuiFontMetrics::pos2x(docstring const & s, int pos, bool const rtl,
                           double const wordspacing) const
 {
        if (pos <= 0)
-               return rtl ? width(s) : 0;
+               pos = 0;
        QTextLayout const * tl = getTextLayout(s, rtl, wordspacing);
        /* Since QString is UTF-16 and docstring is UCS-4, the offsets may
         * not be the same when there are high-plan unicode characters