From: Jean-Marc Lasgouttes Date: Mon, 20 Feb 2017 14:39:28 +0000 (+0100) Subject: Better handling for negative position in pos2x X-Git-Tag: 2.3.0alpha1~348 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=9a54376aef45144213d2958ea643628c1b340e17;p=features.git Better handling for negative position in pos2x This code is already in stable actually. The old one does not work well in RtL text. --- diff --git a/src/frontends/qt4/GuiFontMetrics.cpp b/src/frontends/qt4/GuiFontMetrics.cpp index 2ab182ec33..512e8771b6 100644 --- a/src/frontends/qt4/GuiFontMetrics.cpp +++ b/src/frontends/qt4/GuiFontMetrics.cpp @@ -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