mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-24 10:40:48 +00:00
Fix metrics of math characters with 0 width
It seems that QTextLayout does not handle properly a single character with 0 width. This breaks drawing of things like \not. Actually the problem had been worked around already in lib/symbol. The work around can therefore by removed now. [additionally, remove extra spacing from \mapsto, \Mapsto]
This commit is contained in:
parent
c9c2179c1f
commit
4a935ed768
10
lib/symbols
10
lib/symbols
@ -314,7 +314,7 @@ spadesuit cmsy 127 170 mathord ♠
|
|||||||
lyxnot cmsy 54 47 mathrel / hiddensymbol
|
lyxnot cmsy 54 47 mathrel / hiddensymbol
|
||||||
iffont cmsy
|
iffont cmsy
|
||||||
# kerning is slightly imperfect so that one can see when \not is selected
|
# kerning is slightly imperfect so that one can see when \not is selected
|
||||||
\def\not{\lyxnot\mathrel{\kern-11mu}}
|
\def\not{\lyxnot}
|
||||||
else
|
else
|
||||||
\def\not{\kern4mu\lyxnot\kern-19mu}
|
\def\not{\kern4mu\lyxnot\kern-19mu}
|
||||||
endif
|
endif
|
||||||
@ -991,11 +991,11 @@ bignplus stmry 112 0 mathop x stmaryrd # caution: named hugenpl
|
|||||||
|
|
||||||
\def\varcopyright{\mathord{c\kern-11mu\varbigcirc}} stmaryrd
|
\def\varcopyright{\mathord{c\kern-11mu\varbigcirc}} stmaryrd
|
||||||
# kerning is slightly imperfect so that one sees when \[Aa]rrownot is selected
|
# kerning is slightly imperfect so that one sees when \[Aa]rrownot is selected
|
||||||
\def\arrownot{\lyxarrownot\mathrel{\kern-11mu}} stmaryrd
|
\def\arrownot{\lyxarrownot} stmaryrd
|
||||||
\def\Arrownot{\lyxArrownot\mathrel{\kern-10.5mu}} stmaryrd
|
\def\Arrownot{\lyxArrownot\mathrel{\kern0.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\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{\kern-2mu}\Rightarrow} mathrel ⤇ stmaryrd
|
\def\Mapsto{\Mapstochar\mathrel\Rightarrow} mathrel ⤇ stmaryrd
|
||||||
\def\mapsfrom{\leftarrow\kern-9mu\mapsfromchar} mathrel ↤ stmaryrd
|
\def\mapsfrom{\leftarrow\kern-9mu\mapsfromchar} mathrel ↤ stmaryrd
|
||||||
\def\Mapsfrom{\Leftarrow\kern-9mu\Mapsfromchar} mathrel ⤆ stmaryrd
|
\def\Mapsfrom{\Leftarrow\kern-9mu\Mapsfromchar} mathrel ⤆ stmaryrd
|
||||||
\def\Longmapsto{\Mapstochar\Longrightarrow} mathrel ⟾ stmaryrd
|
\def\Longmapsto{\Mapstochar\Longrightarrow} mathrel ⟾ stmaryrd
|
||||||
@ -1174,7 +1174,7 @@ iffont cmsy
|
|||||||
\def\Longleftarrow{\Leftarrow\joinrel\Relbar} mathrel ⟸
|
\def\Longleftarrow{\Leftarrow\joinrel\Relbar} mathrel ⟸
|
||||||
\def\implies{\Longrightarrow} mathrel ⟹ amsmath
|
\def\implies{\Longrightarrow} mathrel ⟹ amsmath
|
||||||
\def\impliedby{\Longleftarrow} mathrel ⟸ amsmath
|
\def\impliedby{\Longleftarrow} mathrel ⟸ amsmath
|
||||||
\def\mapsto{\mapstochar\mathrel{\kern-2mu}\rightarrow} mathrel ↤
|
\def\mapsto{\mapstochar\rightarrow} mathrel ↤
|
||||||
\def\longmapsto{\mapstochar\joinrel\relbar\joinrel\rightarrow} mathrel ⟻
|
\def\longmapsto{\mapstochar\joinrel\relbar\joinrel\rightarrow} mathrel ⟻
|
||||||
\def\models{\mathrel{\vert}\joinrel\Relbar} mathrel ⊨
|
\def\models{\mathrel{\vert}\joinrel\Relbar} mathrel ⊨
|
||||||
else
|
else
|
||||||
|
@ -182,17 +182,28 @@ int GuiFontMetrics::width(docstring const & s) const
|
|||||||
int * pw = strwidth_cache_[s];
|
int * pw = strwidth_cache_[s];
|
||||||
if (pw)
|
if (pw)
|
||||||
return *pw;
|
return *pw;
|
||||||
// For some reason QMetrics::width returns a wrong value with Qt5
|
|
||||||
// int w = metrics_.width(toqstr(s));
|
|
||||||
PROFILE_CACHE_MISS(width)
|
PROFILE_CACHE_MISS(width)
|
||||||
#endif
|
#endif
|
||||||
QTextLayout tl;
|
/* For some reason QMetrics::width returns a wrong value with Qt5
|
||||||
tl.setText(toqstr(s));
|
* with some arabic text. OTOH, QTextLayout is broken for single
|
||||||
tl.setFont(font_);
|
* characters with null width (like \not in mathed).
|
||||||
tl.beginLayout();
|
*/
|
||||||
QTextLine line = tl.createLine();
|
int w = 0;
|
||||||
tl.endLayout();
|
if (s.length() == 1
|
||||||
int w = int(line.naturalTextWidth());
|
#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 = int(line.naturalTextWidth());
|
||||||
|
}
|
||||||
#ifdef CACHE_METRICS_WIDTH
|
#ifdef CACHE_METRICS_WIDTH
|
||||||
strwidth_cache_.insert(s, new int(w), s.size() * sizeof(char_type));
|
strwidth_cache_.insert(s, new int(w), s.size() * sizeof(char_type));
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user