Le 13/02/2018 à 00:10, Scott Kostyshak a écrit :
Does that seem reasonable to you (for 2.3.0)?Yes, I think so. Also because this regression will put pressure on JMarc for quickly finding a solution ;)Thanks, sounds good.
OK, I know nobody cares, but it seems that the issue is not really my fault :) There are issues with our ttf fonts that are beyond my knowledge.
TL;DR: Qt gets the metrics wrong, and I do not know why.Consider the example file nouveau3.lyx, and instrument LyX with the patch showbearings.diff.
With Qt 4.8.7, I get when loading the file (at zoom level 395%) fantomas: src/lyx ~/nouveau3.lyxfrontends/qt4/GuiFontMetrics.cpp (166): rbearing(1): width=41, Qt lbearing=3, Qt rbearing=-5 => 46 frontends/qt4/GuiFontMetrics.cpp (166): rbearing(102): width=20, Qt lbearing=-4, Qt rbearing=-8 => 28 frontends/qt4/GuiFontMetrics.cpp (166): rbearing(111): width=32, Qt lbearing=2, Qt rbearing=2 => 30
Character 1 is the integral from esint10. Note that the right bearing is negative, as it is for the f (102) but not the "o" (111). This is as expected.
Now, if I compile against Qt 5.5.1, I get: fantomas: src/lyx ~/nouveau3.lyxfrontends/qt4/GuiFontMetrics.cpp (166): rbearing(1): width=41, Qt lbearing=4, Qt rbearing=4 => 37 frontends/qt4/GuiFontMetrics.cpp (166): rbearing(102): width=20, Qt lbearing=-4, Qt rbearing=-8 => 28 frontends/qt4/GuiFontMetrics.cpp (166): rbearing(111): width=32, Qt lbearing=2, Qt rbearing=2 => 30
So the 'f' and the 'o' are the same, but the right bearing of the int is now positive, which is not good. Remember that negative means that the glyph is 'italic' enough to be drawn further than the advance (aka cursor position after glyph).
Let's try another font, that is the plain old cmex10. To this end, apply the patch cmexint.diff and restart LyX (no compilation needed of course).
With Qt4: fantomas: src/lyx ~/nouveau3.lyxfrontends/qt4/GuiFontMetrics.cpp (166): rbearing(82): width=40, Qt lbearing=-1, Qt rbearing=2 => 38 frontends/qt4/GuiFontMetrics.cpp (166): rbearing(102): width=20, Qt lbearing=-4, Qt rbearing=-8 => 28 frontends/qt4/GuiFontMetrics.cpp (166): rbearing(111): width=32, Qt lbearing=2, Qt rbearing=2 => 30
With Qt5: fantomas: src/lyx ~/nouveau3.lyxfrontends/qt4/GuiFontMetrics.cpp (166): rbearing(82): width=40, Qt lbearing=-1, Qt rbearing=2 => 38 frontends/qt4/GuiFontMetrics.cpp (166): rbearing(102): width=20, Qt lbearing=-4, Qt rbearing=-8 => 28 frontends/qt4/GuiFontMetrics.cpp (166): rbearing(111): width=32, Qt lbearing=2, Qt rbearing=2 => 30
So now we have the same result for Qt4 and Qt5 for the \int (now glyph 82 of cmex10) and this result is incorrect. This leads to faulty superscripts for in both cases.
I have tried to run ttfdump on the ttf files, and it shows properly negative right bearings for both fonts. At this point, I give up :)
JMarc
nouveau3.lyx
Description: application/lyx
diff --git a/src/frontends/qt4/GuiFontMetrics.cpp b/src/frontends/qt4/GuiFontMetrics.cpp index b9eab85..2beac64 100644 --- a/src/frontends/qt4/GuiFontMetrics.cpp +++ b/src/frontends/qt4/GuiFontMetrics.cpp @@ -18,6 +18,7 @@ #include "Dimension.h" #include "support/convert.h" +#include "support/debug.h" #include "support/lassert.h" #include "support/lyxlib.h" @@ -162,6 +163,7 @@ int GuiFontMetrics::rbearing(char_type c) const if (is_utf16(c)) { QChar sc = ucs4_to_qchar(c); value = width(c) - metrics_.rightBearing(sc); + LYXERR0("rbearing(" << int(c) << "): width=" << width(c) << ", Qt lbearing=" << metrics_.leftBearing(sc) << ", Qt rbearing=" << metrics_.rightBearing(sc) << " => " << value); } else { // FIXME: QFontMetrics::leftBearing does not support the // full unicode range. Once it does, we could use: @@ -192,7 +194,7 @@ int GuiFontMetrics::width(docstring const & s) const || font_.styleName() == "LyX" #endif ) - w = metrics_.width(toqstr(s)); + w = width(s[0]); else { QTextLayout tl; tl.setText(toqstr(s));
diff --git a/lib/symbols b/lib/symbols index 31ba7f0..7befc58 100644 --- a/lib/symbols +++ b/lib/symbols @@ -1021,33 +1021,33 @@ tbond cmsy 180 186 mathord x # http://www.lyx.org/trac/ticket/1942 for details. # If the wasysym integrals are really wanted then one has to load the package # manually and disable automatic loading of amsmath and esint. -iffont esint -int esint 001 0 mathop ∫ esint|amsmath -intop esint 001 0 mathop ∫ esint -iint esint 003 0 mathop ∬ esint|amsmath -iintop esint 003 0 mathop ∬ esint -iiint esint 005 0 mathop ∭ esint|amsmath +# iffont esint +# int esint 001 0 mathop ∫ esint|amsmath +# intop esint 001 0 mathop ∫ esint +# iint esint 003 0 mathop ∬ esint|amsmath +# iintop esint 003 0 mathop ∬ esint +# iiint esint 005 0 mathop ∭ esint|amsmath -iiintop esint 005 0 mathop ∭ esint -iiiint esint 007 0 mathop ⨌ esint|amsmath +# iiintop esint 005 0 mathop ∭ esint +# iiiint esint 007 0 mathop ⨌ esint|amsmath -iiiintop esint 007 0 mathop ⨌ esint -oint esint 011 0 mathop ∮ esint +# iiiintop esint 007 0 mathop ⨌ esint +# oint esint 011 0 mathop ∮ esint -ointop esint 011 0 mathop ∮ esint -oiint esint 013 0 mathop ∯ esint -oiintop esint 013 0 mathop ∯ esint -sqint esint 015 0 mathop x esint -sqintop esint 015 0 mathop x esint -sqiint esint 017 0 mathop x esint -sqiintop esint 017 0 mathop x esint -dotsint esint 019 0 mathop ∫⋯∫ esint -dotsintop esint 019 0 mathop ∫⋯∫ esint -ointctrclockwise esint 023 0 mathop ∳ esint -ointctrclockwiseop esint 023 0 mathop ∳ esint -ointclockwise esint 025 0 mathop ∲ esint -ointclockwiseop esint 025 0 mathop ∲ esint -else +# ointop esint 011 0 mathop ∮ esint +# oiint esint 013 0 mathop ∯ esint +# oiintop esint 013 0 mathop ∯ esint +# sqint esint 015 0 mathop x esint +# sqintop esint 015 0 mathop x esint +# sqiint esint 017 0 mathop x esint +# sqiintop esint 017 0 mathop x esint +# dotsint esint 019 0 mathop ∫⋯∫ esint +# dotsintop esint 019 0 mathop ∫⋯∫ esint +# ointctrclockwise esint 023 0 mathop ∳ esint +# ointctrclockwiseop esint 023 0 mathop ∳ esint +# ointclockwise esint 025 0 mathop ∲ esint +# ointclockwiseop esint 025 0 mathop ∲ esint +# else int cmex 82 242 mathop ∫ esint|amsmath intop cmex 82 242 mathop ∫ esint iint wasy 115 0 mathop ∬ esint|amsmath @@ -1072,7 +1072,7 @@ oiintop wasy 118 0 mathop ∯ esint \def\ointctrclockwiseop{\circlearrowleft\kern-21mu\int\kern6mu} esint \def\ointclockwise{\circlearrowright\kern-21mu\int\kern6mu} esint \def\ointclockwiseop{\circlearrowright\kern-21mu\int\kern6mu} esint -endif +# endif varointclockwise esint 027 0 mathop ∲ esint varointclockwiseop esint 027 0 mathop ∲ esint