X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt%2FGuiFontLoader.cpp;h=453d1260ea63fe3cfd763e3645586b4e69d4253d;hb=cc257b4927f8833836a6f6caab6f91c5022063db;hp=80d45f6afcc5d0571a613c6540a6beabce676ddc;hpb=10272e474790d25ae9b5f3d272423959422ddfbd;p=lyx.git diff --git a/src/frontends/qt/GuiFontLoader.cpp b/src/frontends/qt/GuiFontLoader.cpp index 80d45f6afc..453d1260ea 100644 --- a/src/frontends/qt/GuiFontLoader.cpp +++ b/src/frontends/qt/GuiFontLoader.cpp @@ -14,7 +14,7 @@ #include "GuiFontLoader.h" #include "FontLoader.h" -#include "FontInfo.h" +#include "Font.h" #include "GuiFontMetrics.h" #include "qt_helpers.h" @@ -29,6 +29,8 @@ #include "support/Package.h" #include "support/os.h" +#include "GuiApplication.h" + #include #include @@ -64,27 +66,9 @@ namespace { struct SymbolFont { FontFamily lyx_family; QString family; -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) - QString xlfd; -#endif }; SymbolFont symbol_fonts[] = { -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) - { SYMBOL_FAMILY,"symbol", "-*-symbol-*-*-*-*-*-*-*-*-*-*-adobe-fontspecific"}, - { CMR_FAMILY, "cmr10", "-*-cmr10-medium-*-*-*-*-*-*-*-*-*-*-*" }, - { CMSY_FAMILY, "cmsy10", "-*-cmsy10-*-*-*-*-*-*-*-*-*-*-*-*" }, - { CMM_FAMILY, "cmmi10", "-*-cmmi10-medium-*-*-*-*-*-*-*-*-*-*-*" }, - { CMEX_FAMILY, "cmex10", "-*-cmex10-*-*-*-*-*-*-*-*-*-*-*-*" }, - { MSA_FAMILY, "msam10", "-*-msam10-*-*-*-*-*-*-*-*-*-*-*-*" }, - { MSB_FAMILY, "msbm10", "-*-msbm10-*-*-*-*-*-*-*-*-*-*-*-*" }, - { DS_FAMILY, "dsrom10", "-*-dsrom10-*-*-*-*-*-*-*-*-*-*-*-*" }, - { EUFRAK_FAMILY,"eufm10", "-*-eufm10-medium-*-*-*-*-*-*-*-*-*-*-*" }, - { RSFS_FAMILY, "rsfs10", "-*-rsfs10-medium-*-*-*-*-*-*-*-*-*-*-*" }, - { STMARY_FAMILY,"stmary10","-*-stmary10-medium-*-*-*-*-*-*-*-*-*-*-*" }, - { WASY_FAMILY, "wasy10", "-*-wasy10-medium-*-*-*-*-*-*-*-*-*-*-*" }, - { ESINT_FAMILY, "esint10","-*-esint10-medium-*-*-*-*-*-*-*-*-*-*-*" } -#else { SYMBOL_FAMILY,"symbol"}, { CMR_FAMILY, "cmr10"}, { CMSY_FAMILY, "cmsy10"}, @@ -98,7 +82,6 @@ SymbolFont symbol_fonts[] = { { STMARY_FAMILY,"stmary10"}, { WASY_FAMILY, "wasy10"}, { ESINT_FAMILY, "esint10"} -#endif }; size_t const nr_symbol_fonts = sizeof(symbol_fonts) / sizeof(symbol_fonts[0]); @@ -129,8 +112,8 @@ GuiFontInfo & fontinfo(FontInfo const & f) (f.size() < NUM_SIZE); if (!fontIsRealized) { // We can reset the font to something sensible in release mode. + LYXERR0("Unrealized font!" << f); LATTEST(false); - LYXERR0("Unrealized font!"); FontInfo f2 = f; f2.realize(sane_font); GuiFontInfo * & fi = fontinfo_ptr(f2); @@ -145,19 +128,6 @@ GuiFontInfo & fontinfo(FontInfo const & f) } -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) -QString rawName(QString const & family) -{ - for (size_t i = 0; i < nr_symbol_fonts; ++i) - if (family == symbol_fonts[i].family) - return symbol_fonts[i].xlfd; - - LYXERR(Debug::FONT, "BUG: family not found !"); - return QString(); -} -#endif - - QString symbolFamily(FontFamily family) { for (size_t i = 0; i < nr_symbol_fonts; ++i) { @@ -188,10 +158,7 @@ static bool isChosenFont(QFont & font, QString const & family, LYXERR_NOPOS(Debug::FONT, "got: " << fi.family()); if (fi.family().contains(family) -#if QT_VERSION >= 0x040800 - && (style.isEmpty() || fi.styleName().contains(style)) -#endif - ) { + && (style.isEmpty() || fi.styleName().contains(style))) { LYXERR_NOENDL(Debug::FONT, " got it "); return true; } @@ -207,16 +174,16 @@ QFont symbolFont(QString const & family, bool * ok) upper[0] = family[0].toUpper(); QFont font; -#if defined Q_WS_X11 || defined(QPA_XCB) - // On *nix we have to also specify the foundry to be able to - // discriminate our fonts when the texlive fonts are managed by - // fontconfig. Unfortunately, doing the same on Windows breaks things. - font.setFamily(family + QLatin1String(" [LyEd]")); -#else - font.setFamily(family); -#endif + if (guiApp->platformName() == "xcb" + || guiApp->platformName().contains("wayland")) { + // On *nix we have to also specify the foundry to be able to + // discriminate our fonts when the texlive fonts are managed by + // fontconfig. Unfortunately, doing the same on Windows breaks things. + font.setFamily(family + QLatin1String(" [LyEd]")); + } else { + font.setFamily(family); + } font.setStyleStrategy(QFont::NoFontMerging); -#if QT_VERSION >= 0x040800 font.setStyleName("LyX"); if (isChosenFont(font, family, "LyX")) { @@ -227,7 +194,6 @@ QFont symbolFont(QString const & family, bool * ok) LYXERR_NOENDL(Debug::FONT, "Trying normal " << family << " ... "); font.setStyleName(QString()); -#endif if (isChosenFont(font, family, QString())) { LYXERR_NOPOS(Debug::FONT, "normal!"); @@ -244,20 +210,6 @@ QFont symbolFont(QString const & family, bool * ok) return font; } -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) - // A simple setFamily() fails on Qt 2 - - QString const raw = rawName(family); - LYXERR_NOENDL(Debug::FONT, "Trying " << raw << " ... "); - font.setRawName(raw); - - if (isChosenFont(font, family, QString())) { - LYXERR_NOPOS(Debug::FONT, "raw version!"); - *ok = true; - return font; - } -#endif - LYXERR_NOPOS(Debug::FONT, " FAILED :-("); *ok = false; return font; @@ -332,15 +284,6 @@ QFont makeQFont(FontInfo const & f) QString family = makeFontName(toqstr(lyxrc.roman_font_name), toqstr(lyxrc.roman_font_foundry)); font.setFamily(family); -#ifdef Q_OS_MAC -#if QT_VERSION >= 0x040300 //&& QT_VERSION < 0x040800 - // Workaround for a Qt bug, see http://www.lyx.org/trac/ticket/3684 - // and http://bugreports.qt.nokia.com/browse/QTBUG-11145. - // FIXME: Check whether this is really fixed in Qt 4.8 - if (family == "Times" && !font.exactMatch()) - font.setFamily("Times New Roman"); -#endif -#endif break; } case SANS_FAMILY: @@ -390,10 +333,6 @@ QFont makeQFont(FontInfo const & f) else LYXERR(Debug::FONT, "This font is NOT an exact match"); -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) - LYXERR(Debug::FONT, "XFLD: " << font.rawName()); -#endif - font.setPointSizeF(f.realSize() * lyxrc.currentZoom / 100.0); LYXERR(Debug::FONT, "The font has size: " << font.pointSizeF()); @@ -447,15 +386,12 @@ bool FontLoader::available(FontInfo const & f) bool FontLoader::canBeDisplayed(char_type c) { - // bug 8493 - if (c == 0x0009) - // FIXME check whether this is still needed for Qt5 - return false; -#if QT_VERSION < 0x050000 && defined(QT_MAC_USE_COCOA) && (QT_MAC_USE_COCOA > 0) - // bug 7954, see also comment in GuiPainter::text() - if (c == 0x00ad) + // bug 8493: with Qt5 and Qt6, characters with codepoints 9, 10, 12 and + // 13 are rendered as spaces. We handle that in our TeX fonts by making + // copies of the glyphs elsewhere, but this may trigger if we are + // unlucky. + if (c == 0x0009 || c == 0x000a || c == 0x000c || c == 0x000d) return false; -#endif return true; }