On Mon, Aug 31, 2020 at 10:11:56PM +0200, Enrico Forestieri wrote:
> On Mon, Aug 31, 2020 at 07:08:31PM +0200, Pavel Sanda wrote:
> > 
> > At this moment I would like to ask other people on this list, whether
> > they can sucesfully load fonts/test/check_glyphs.lyx and display
> > esint glyphs (in particular oiint and alignment of limits around \int)
> > in any Qt >= 5.12.7 to check whether this is systemic problem or
> > something related to openSuse packaging.
> 
> I have no issues with Qt 5.15.0. From the screenshots, it seems that
> a wrong font is loaded. I suggest running "lyx -dbg font", load a
> document with an integral sign and watch for the loading of esint10.
> If one gets
> ...
> frontends/qt/GuiFontLoader.cpp (205): Looking for font family esint10 ...
> frontends/qt/GuiFontLoader.cpp (188): got: esint10
> frontends/qt/GuiFontLoader.cpp (195):  got it
> frontends/qt/GuiFontLoader.cpp (215): lyx!
> ...
> 
> then it's the correct font. But if it does not say "lyx!", another
> font (not the one distributed with lyx) is being loaded.
> 
> The following command might shed some light on which font file is used:
> fc-match -v esint10 | grep file:

The attached patch should show which font file lyx uses for math fonts.
This is only for linux. You have to configure lyx using LIBS=-lfontconfig,
i.e., "configure [your usual options here] LIBS=-lfontconfig".

After building lyx, create a new document and then a math inset.
You should then see all used font files printed in the terminal.

-- 
Enrico
diff --git a/src/frontends/qt/GuiFontLoader.cpp b/src/frontends/qt/GuiFontLoader.cpp
index 82dafbffd7..366f015faf 100644
--- a/src/frontends/qt/GuiFontLoader.cpp
+++ b/src/frontends/qt/GuiFontLoader.cpp
@@ -200,6 +200,37 @@ static bool isChosenFont(QFont & font, QString const & family,
 }
 
 
+#if defined Q_WS_X11 || defined(QPA_XCB)
+#include <fontconfig/fontconfig.h>
+static void print_font_file(QString const & fam_name, QString const & sty_name)
+{
+	FcConfig * config = FcInitLoadConfigAndFonts();
+	QString const family_and_style = sty_name.isEmpty() ? fam_name
+		: fam_name + QLatin1String(": style=") + sty_name;
+	FcPattern * pat = FcNameParse(reinterpret_cast<FcChar8 const *>(family_and_style.toLocal8Bit().data()));
+	FcConfigSubstitute(config, pat, FcMatchPattern);
+	FcDefaultSubstitute(pat);
+	FcResult res;
+	FcPattern * font = FcFontMatch(config, pat, &res);
+	if (font) {
+		FcChar8 * file = NULL;
+		FcChar8 * family = NULL;
+		FcChar8 * style = NULL;
+		if (FcPatternGetString(font, FC_FILE, 0, &file) == FcResultMatch &&
+		    FcPatternGetString(font, FC_FAMILY, 0, &family) == FcResultMatch &&
+		    FcPatternGetString(font, FC_STYLE, 0, &style) == FcResultMatch) {
+			lyxerr << "Filename: " << reinterpret_cast<char *>(file)
+			       << " (family " << reinterpret_cast<char *>(family)
+			       << ", style " << reinterpret_cast<char *>(style)
+			       << ")" << endl;
+		}
+		FcPatternDestroy(font);
+	}
+	FcPatternDestroy(pat);
+}
+#endif
+
+
 QFont symbolFont(QString const & family, bool * ok)
 {
 	LYXERR_NOENDL(Debug::FONT, "Looking for font family " << family << " ... ");
@@ -214,6 +245,9 @@ QFont symbolFont(QString const & family, bool * ok)
 	if (isChosenFont(font, family, "LyX")) {
 		LYXERR_NOPOS(Debug::FONT, "lyx!");
 		*ok = true;
+#if defined Q_WS_X11 || defined(QPA_XCB)
+		print_font_file(family, "LyX");
+#endif
 		return font;
 	}
 
@@ -224,6 +258,9 @@ QFont symbolFont(QString const & family, bool * ok)
 	if (isChosenFont(font, family, QString())) {
 		LYXERR_NOPOS(Debug::FONT, "normal!");
 		*ok = true;
+#if defined Q_WS_X11 || defined(QPA_XCB)
+		print_font_file(family, QString());
+#endif
 		return font;
 	}
 
@@ -233,6 +270,9 @@ QFont symbolFont(QString const & family, bool * ok)
 	if (isChosenFont(font, upper, QString())) {
 		LYXERR_NOPOS(Debug::FONT, "upper!");
 		*ok = true;
+#if defined Q_WS_X11 || defined(QPA_XCB)
+		print_font_file(upper, QString());
+#endif
 		return font;
 	}
 
@@ -246,6 +286,9 @@ QFont symbolFont(QString const & family, bool * ok)
 	if (isChosenFont(font, family, QString())) {
 		LYXERR_NOPOS(Debug::FONT, "raw version!");
 		*ok = true;
+#if defined Q_WS_X11 || defined(QPA_XCB)
+		print_font_file(family, QString());
+#endif
 		return font;
 	}
 #endif
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to