On Mon, Jan 16, 2017 at 03:36:07PM -0500, Richard Heck wrote: > Resending as a new thread so it is more visible.... > > On 01/16/2017 02:04 PM, Scott Kostyshak wrote: > > On Mon, Jan 16, 2017 at 01:13:44PM -0500, Richard Heck wrote: > >> I am seeing display problems in stable with \notin and \noteq. The > >> latter, for example, shows (In LyX) as "/=", rather than as ≠. Similarly > >> for \notin. See the attachments. > > Just a few data points: > > > > I can reproduce the problem on current 2.2.x branch. > > I cannot reproduce on master or on 2.2.1. > > Bisect blames: > > 24648404b3c85015584b1ca127e257cbecf3342d is the first bad commit > commit 24648404b3c85015584b1ca127e257cbecf3342d > Author: Jean-Marc Lasgouttes <lasgout...@lyx.org> > Date: Sun Oct 23 20:52:01 2016 +0200
This seems to be a Qt issue. QTextLine::naturalTextWidth() should report the width of the line occupied by text. If a zero-width character is present, it is correctly accounted for, except when it is the only character in the line. That is to say that "/=" has the same width as "=" if "/" has zero-width, but "/" by alone is reported to have its real width. The metrics in math are computed char by char, so that explains the behavior. The solution is to compute the width by using the old method when when the font is one of ours. See attached patch. > Strange, though, that this does not cause the same problem in master. > Probably > that is due to other changes JMarc has made there. I did not investigate why that is not a problem in master. -- Enrico
diff --git a/src/frontends/qt4/GuiFontMetrics.cpp b/src/frontends/qt4/GuiFontMetrics.cpp index f17ac37..b6761c9 100644 --- a/src/frontends/qt4/GuiFontMetrics.cpp +++ b/src/frontends/qt4/GuiFontMetrics.cpp @@ -181,13 +181,18 @@ int GuiFontMetrics::width(docstring const & s) const // For some reason QMetrics::width returns a wrong value with Qt5 // int w = metrics_.width(toqstr(s)); #endif - QTextLayout tl; - tl.setText(toqstr(s)); - tl.setFont(font_); - tl.beginLayout(); - QTextLine line = tl.createLine(); - tl.endLayout(); - int w = int(line.naturalTextWidth()); + int w; + if (font_.styleName() == "LyX") { + w = metrics_.width(toqstr(s)); + } else { + QTextLayout tl; + tl.setText(toqstr(s)); + tl.setFont(font_); + tl.beginLayout(); + QTextLine line = tl.createLine(); + tl.endLayout(); + w = int(line.naturalTextWidth()); + } #ifdef CACHE_METRICS_WIDTH strwidth_cache_.insert(s, new int(w), s.size() * sizeof(char_type)); #endif