commit f496ec373bafa15beeb4f1709ec22e179df9f099 Author: Enrico Forestieri <for...@lyx.org> Date: Wed Jan 21 13:57:55 2015 +0100
Solve the "soft-hyphen" (0x00ad) symbol problem. After the str-metrics merge, the kludge for displaying symbols whose code point corresponds to a soft-hyphen was not working anymore. The solution is replicating the offending glyphs with index 0x00ad at a different index. They were replicated at 0x00ac, whose glyph was missing in all affected fonts. However, this would not work by alone because, if a system font with same family name exists, it would be picked up instead of the right one (at least on non-Windows platforms). For this reason, the style of the fonts has been changed from "Regular" to "Lyx", so that we can discriminate the right font. However, this requires using at least Qt 4.8. If an older Qt is used *and* a system font with same family name is already available, the affected glyphs will all turn out on screen as the "logical not" symbol. I have also set the executable flag on the font files, because on Windows they are loaded only in this case. This solves #9229. diff --git a/lib/fonts/cmex10.ttf b/lib/fonts/cmex10.ttf old mode 100644 new mode 100755 index e4b468d..aed7e86 Binary files a/lib/fonts/cmex10.ttf and b/lib/fonts/cmex10.ttf differ diff --git a/lib/fonts/cmmi10.ttf b/lib/fonts/cmmi10.ttf old mode 100644 new mode 100755 index af48386..9b2b430 Binary files a/lib/fonts/cmmi10.ttf and b/lib/fonts/cmmi10.ttf differ diff --git a/lib/fonts/cmr10.ttf b/lib/fonts/cmr10.ttf old mode 100644 new mode 100755 index 8bc4496..e405536 Binary files a/lib/fonts/cmr10.ttf and b/lib/fonts/cmr10.ttf differ diff --git a/lib/fonts/cmsy10.ttf b/lib/fonts/cmsy10.ttf old mode 100644 new mode 100755 index e0f4fa8..40cb3a8 Binary files a/lib/fonts/cmsy10.ttf and b/lib/fonts/cmsy10.ttf differ diff --git a/lib/fonts/esint10.ttf b/lib/fonts/esint10.ttf old mode 100644 new mode 100755 index b803a15..deb6e5f Binary files a/lib/fonts/esint10.ttf and b/lib/fonts/esint10.ttf differ diff --git a/lib/fonts/eufm10.ttf b/lib/fonts/eufm10.ttf old mode 100644 new mode 100755 index eb126a0..0e670d4 Binary files a/lib/fonts/eufm10.ttf and b/lib/fonts/eufm10.ttf differ diff --git a/lib/fonts/msam10.ttf b/lib/fonts/msam10.ttf old mode 100644 new mode 100755 index 8a83d1f..3b0cd89 Binary files a/lib/fonts/msam10.ttf and b/lib/fonts/msam10.ttf differ diff --git a/lib/fonts/msbm10.ttf b/lib/fonts/msbm10.ttf old mode 100644 new mode 100755 index 728d1e8..04a4717 Binary files a/lib/fonts/msbm10.ttf and b/lib/fonts/msbm10.ttf differ diff --git a/lib/fonts/rsfs10.ttf b/lib/fonts/rsfs10.ttf old mode 100644 new mode 100755 index 2fa353e..4160bcf Binary files a/lib/fonts/rsfs10.ttf and b/lib/fonts/rsfs10.ttf differ diff --git a/lib/fonts/stmary10.ttf b/lib/fonts/stmary10.ttf old mode 100644 new mode 100755 index 692a30e..bafedc4 Binary files a/lib/fonts/stmary10.ttf and b/lib/fonts/stmary10.ttf differ diff --git a/lib/fonts/wasy10.ttf b/lib/fonts/wasy10.ttf old mode 100644 new mode 100755 index 673085f..a4e32d2 Binary files a/lib/fonts/wasy10.ttf and b/lib/fonts/wasy10.ttf differ diff --git a/lib/symbols b/lib/symbols index f6d59b8..d4a9f65 100644 --- a/lib/symbols +++ b/lib/symbols @@ -261,7 +261,7 @@ Sigma cmr 167 83 mathalpha Σ Upsilon cmr 168 161 mathalpha ϒ Phi cmr 169 70 mathalpha Φ Psi cmr 170 89 mathalpha Ψ -Omega cmr 173 87 mathalpha Ω +Omega cmr 172 87 mathalpha Ω aleph cmsy 64 192 mathord ℵ imath cmm 123 0 mathord ı jmath cmm 124 0 mathord ȷ @@ -331,7 +331,7 @@ wr cmsy 111 0 mathbin ≀ div cmsy 165 184 mathbin ÷ odot cmsy 175 0 mathbin ⊙ oslash cmsy 174 198 mathbin ø -otimes cmsy 173 196 mathbin ⊗ +otimes cmsy 172 196 mathbin ⊗ ominus cmsy 170 0 mathbin ⊖ oplus cmsy 169 197 mathbin ⊕ mp cmsy 168 0 mathbin ∓ @@ -435,7 +435,7 @@ ulcorner msa 112 0 mathopen ⌜ urcorner msa 113 0 mathclose ⌝ llcorner msa 120 0 mathopen ⌞ lrcorner msa 121 0 mathclose ⌟ -rightleftharpoons msa 173 0 mathrel ⇋ +rightleftharpoons msa 172 0 mathrel ⇋ angle msa 92 208 mathord ∠ sqsubset msa 64 0 mathrel ⊏ sqsupset msa 65 0 mathrel ⊐ @@ -578,7 +578,7 @@ nprec msb 167 0 mathrel ⊀ nsucc msb 168 0 mathrel ⊁ lneqq msb 169 0 mathrel ≨ gneqq msb 170 0 mathrel ≩ -nleqslant msb 173 0 mathrel ⩽̸ +nleqslant msb 172 0 mathrel ⩽̸ ngeqslant msb 174 0 mathrel ⩾̸ lneq msb 175 0 mathrel ≰ gneq msb 176 0 mathrel ⪈ @@ -735,7 +735,7 @@ varSigma cmm 167 0 mathord x amsmath varUpsilon cmm 168 0 mathord x amsmath varPhi cmm 169 0 mathord x amsmath varPsi cmm 170 0 mathord x amsmath -varOmega cmm 173 0 mathord x amsmath +varOmega cmm 172 0 mathord x amsmath # # wasy astronomy diff --git a/src/frontends/qt4/GuiFontLoader.cpp b/src/frontends/qt4/GuiFontLoader.cpp index 8512189..69f1ed2 100644 --- a/src/frontends/qt4/GuiFontLoader.cpp +++ b/src/frontends/qt4/GuiFontLoader.cpp @@ -139,7 +139,8 @@ bool isSymbolFamily(FontFamily family) #endif -static bool isChosenFont(QFont & font, QString const & family) +static bool isChosenFont(QFont & font, QString const & family, + QString const & style) { // QFontInfo won't find a font that has only a few glyphs at unusual // positions, e.g. the original esint10 font. @@ -149,7 +150,11 @@ static bool isChosenFont(QFont & font, QString const & family) LYXERR(Debug::FONT, "got: " << fi.family()); - if (fi.family().contains(family)) { + if (fi.family().contains(family) +#if QT_VERSION >= 0x040800 + && (style.isEmpty() || fi.styleName().contains(style)) +#endif + ) { LYXERR(Debug::FONT, " got it "); return true; } @@ -166,8 +171,20 @@ QFont symbolFont(QString const & family, bool * ok) QFont font; font.setFamily(family); +#if QT_VERSION >= 0x040800 + font.setStyleName("LyX"); + + if (isChosenFont(font, family, "LyX")) { + LYXERR(Debug::FONT, "lyx!"); + *ok = true; + return font; + } + + LYXERR(Debug::FONT, "Trying normal " << family << " ... "); + font.setStyleName(QString()); +#endif - if (isChosenFont(font, family)) { + if (isChosenFont(font, family, QString())) { LYXERR(Debug::FONT, "normal!"); *ok = true; return font; @@ -176,7 +193,7 @@ QFont symbolFont(QString const & family, bool * ok) LYXERR(Debug::FONT, "Trying " << upper << " ... "); font.setFamily(upper); - if (isChosenFont(font, upper)) { + if (isChosenFont(font, upper, QString())) { LYXERR(Debug::FONT, "upper!"); *ok = true; return font; @@ -188,7 +205,7 @@ QFont symbolFont(QString const & family, bool * ok) LYXERR(Debug::FONT, "Trying " << raw << " ... "); font.setRawName(raw); - if (isChosenFont(font, family)) { + if (isChosenFont(font, family, QString())) { LYXERR(Debug::FONT, "raw version!"); *ok = true; return font; diff --git a/src/frontends/qt4/GuiPainter.cpp b/src/frontends/qt4/GuiPainter.cpp index de1ca71..ce0290c 100644 --- a/src/frontends/qt4/GuiPainter.cpp +++ b/src/frontends/qt4/GuiPainter.cpp @@ -333,27 +333,6 @@ int GuiPainter::text(int x, int y, docstring const & s, textDecoration(f, x, y, textwidth); - // Qt4 does not display a glyph whose codepoint is the - // same as that of a soft-hyphen (0x00ad), unless it - // occurs at a line-break. As a kludge, we force Qt to - // render this glyph using a one-column line. - // This is needed for some math glyphs. - // Should the soft hyphen char be displayed at all? - // I don't think so (i.e., Qt is correct as far as - // texted is concerned). /spitz - if (s.size() == 1 && str[0].unicode() == 0x00ad) { - setQPainterPen(computeColor(f.realColor())); - QTextLayout adsymbol(str); - adsymbol.setFont(ff); - adsymbol.beginLayout(); - QTextLine line = adsymbol.createLine(); - line.setNumColumns(1); - line.setPosition(QPointF(0, -line.ascent())); - adsymbol.endLayout(); - line.draw(this, QPointF(x, y)); - return textwidth; - } - if (use_pixmap_cache_) { QPixmap pm; QString key = generateStringSignature(str, f);