From 9a54376aef45144213d2958ea643628c1b340e17 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Mon, 20 Feb 2017 15:39:28 +0100 Subject: [PATCH] Better handling for negative position in pos2x This code is already in stable actually. The old one does not work well in RtL text. --- src/frontends/qt4/GuiFontMetrics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 -- 2.39.2