From 64ea86124784a6df68c6486f416f6e442dd3d629 Mon Sep 17 00:00:00 2001 From: Scott Kostyshak Date: Fri, 20 Mar 2020 20:36:35 -0400 Subject: [PATCH] Restore XLFD code for Qt 4 There is a chance that this code is still useful for Qt 4. We keep it around just in case. For the case of Qt 4, this commit restores the code changed in f8e40f8a, d255339a, and d4ff3a29. --- src/frontends/qt/GuiFontLoader.cpp | 49 ++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/frontends/qt/GuiFontLoader.cpp b/src/frontends/qt/GuiFontLoader.cpp index cf73292f2a..01e7a66289 100644 --- a/src/frontends/qt/GuiFontLoader.cpp +++ b/src/frontends/qt/GuiFontLoader.cpp @@ -64,9 +64,26 @@ 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-*-*-*-*-*-*-*-*-*-*-*-*" }, + { 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"}, @@ -79,6 +96,7 @@ 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]); @@ -125,6 +143,19 @@ 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) { @@ -203,6 +234,20 @@ 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(Debug::FONT, "Trying " << raw << " ... "); + font.setRawName(raw); + + if (isChosenFont(font, family, QString())) { + LYXERR(Debug::FONT, "raw version!"); + *ok = true; + return font; + } +#endif + LYXERR(Debug::FONT, " FAILED :-("); *ok = false; return font; @@ -335,6 +380,10 @@ 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()); -- 2.39.5