On Tue, Feb 06, 2018 at 12:19:47PM -0500, Scott Kostyshak wrote:
> On Tue, Feb 06, 2018 at 10:01:02AM +0000, Jean-Marc Lasgouttes wrote:
> 
> > Enrico, for reference this is the commit where we use
> > QFontMetrics::width in some cases instead of the QTextLayout thing.
> > 
> > I tried to revert it and did not see much difference.
> 
> I tried a vanilla "git revert" on master and there was a conflict so I
> did not look further. If you have a patch that reverts it, I could test
> that.

Please, try the attached.

-- 
Enrico
diff --git a/lib/symbols b/lib/symbols
index 31ba7f0eb1..82a6d132d5 100644
--- a/lib/symbols
+++ b/lib/symbols
@@ -314,7 +314,7 @@ spadesuit          cmsy        127 170 mathord  ♠
 lyxnot             cmsy         54  47 mathrel  /           hiddensymbol
 iffont cmsy
 # kerning is slightly imperfect so that one can see when \not is selected
-\def\not{\lyxnot}
+\def\not{\lyxnot\mathrel{\kern-11mu}}
 else
 \def\not{\kern4mu\lyxnot\kern-19mu}
 endif
@@ -991,11 +991,11 @@ bignplus           stmry 112   0 mathop     x  stmaryrd # 
caution: named hugenpl
 
 \def\varcopyright{\mathord{c\kern-11mu\varbigcirc}}         stmaryrd
 # kerning is slightly imperfect so that one sees when \[Aa]rrownot is selected
-\def\arrownot{\lyxarrownot}                                 stmaryrd
-\def\Arrownot{\lyxArrownot\mathrel{\kern0.5mu}}             stmaryrd
+\def\arrownot{\lyxarrownot\mathrel{\kern-11mu}}             stmaryrd
+\def\Arrownot{\lyxArrownot\mathrel{\kern-10.5mu}}           stmaryrd
 \def\longarrownot{\mathrel{\kern5.5mu}\arrownot\mathrel{\kern-5.5mu}} stmaryrd
 \def\Longarrownot{\mathrel{\kern5.5mu}\Arrownot\mathrel{\kern-5.5mu}} stmaryrd
-\def\Mapsto{\Mapstochar\mathrel\Rightarrow}              mathrel ⤇ 
stmaryrd
+\def\Mapsto{\Mapstochar\mathrel{\kern-2mu}\Rightarrow}   mathrel ⤇ 
stmaryrd
 \def\mapsfrom{\leftarrow\kern-9mu\mapsfromchar}          mathrel ↤ 
stmaryrd
 \def\Mapsfrom{\Leftarrow\kern-9mu\Mapsfromchar}          mathrel ⤆ 
stmaryrd
 \def\Longmapsto{\Mapstochar\Longrightarrow}              mathrel ⟾ 
stmaryrd
@@ -1174,7 +1174,7 @@ iffont cmsy
 \def\Longleftarrow{\Leftarrow\joinrel\Relbar}                   mathrel 
⟸
 \def\implies{\Longrightarrow}                                   mathrel 
⟹ amsmath
 \def\impliedby{\Longleftarrow}                                  mathrel 
⟸ amsmath
-\def\mapsto{\mapstochar\rightarrow}                             mathrel 
↤
+\def\mapsto{\mapstochar\mathrel{\kern-2mu}\rightarrow}          mathrel 
↤
 \def\longmapsto{\mapstochar\joinrel\relbar\joinrel\rightarrow}  mathrel 
⟻
 \def\models{\mathrel{\vert}\joinrel\Relbar}                     mathrel ⊨
 else
diff --git a/src/frontends/qt4/GuiFontMetrics.cpp 
b/src/frontends/qt4/GuiFontMetrics.cpp
index b9eab8531f..43eb4f20e7 100644
--- a/src/frontends/qt4/GuiFontMetrics.cpp
+++ b/src/frontends/qt4/GuiFontMetrics.cpp
@@ -180,28 +180,16 @@ int GuiFontMetrics::width(docstring const & s) const
        PROFILE_THIS_BLOCK(width);
        if (strwidth_cache_.contains(s))
                return strwidth_cache_[s];
+       // For some reason QMetrics::width returns a wrong value with Qt5
+       // int w = metrics_.width(toqstr(s));
        PROFILE_CACHE_MISS(width);
-       /* For some reason QMetrics::width returns a wrong value with Qt5
-        * with some arabic text. OTOH, QTextLayout is broken for single
-        * characters with null width (like \not in mathed). Also, as a
-        * safety measure, always use QMetrics::width with our math fonts.
-       */
-       int w = 0;
-       if (s.length() == 1
-#if QT_VERSION >= 0x040800
-           || font_.styleName() == "LyX"
-#endif
-           )
-               w = metrics_.width(toqstr(s));
-       else {
-               QTextLayout tl;
-               tl.setText(toqstr(s));
-               tl.setFont(font_);
-               tl.beginLayout();
-               QTextLine line = tl.createLine();
-               tl.endLayout();
-               w = iround(line.horizontalAdvance());
-       }
+       QTextLayout tl;
+       tl.setText(toqstr(s));
+       tl.setFont(font_);
+       tl.beginLayout();
+       QTextLine line = tl.createLine();
+       tl.endLayout();
+       int w = int(line.naturalTextWidth());
        strwidth_cache_.insert(s, w, s.size() * sizeof(char_type));
        return w;
 }

Reply via email to