Adjust debug output for fonts

This restores the debug output as it was intended before the
introduction of the LYXERR macro that was unconditionally outputing
an end of line. This is how this output was appearing until lyx 1.5:

Looking for font family cmr10 ... got: cmr10
 got it normal!

instead of as it was since lyx 1.6 and until now:

Looking for font family cmr10 ...
got: cmr10
 got it
normal!
This commit is contained in:
Enrico Forestieri 2020-09-01 12:12:55 +02:00
parent 1ba785f2c6
commit 8039b34802
2 changed files with 23 additions and 11 deletions

View File

@ -185,14 +185,14 @@ static bool isChosenFont(QFont & font, QString const & family,
// positions. // positions.
QFontInfo fi(font); QFontInfo fi(font);
LYXERR(Debug::FONT, "got: " << fi.family()); LYXERR_NOPOS(Debug::FONT, "got: " << fi.family());
if (fi.family().contains(family) if (fi.family().contains(family)
#if QT_VERSION >= 0x040800 #if QT_VERSION >= 0x040800
&& (style.isEmpty() || fi.styleName().contains(style)) && (style.isEmpty() || fi.styleName().contains(style))
#endif #endif
) { ) {
LYXERR(Debug::FONT, " got it "); LYXERR_NOENDL(Debug::FONT, " got it ");
return true; return true;
} }
@ -202,7 +202,7 @@ static bool isChosenFont(QFont & font, QString const & family,
QFont symbolFont(QString const & family, bool * ok) QFont symbolFont(QString const & family, bool * ok)
{ {
LYXERR(Debug::FONT, "Looking for font family " << family << " ... "); LYXERR_NOENDL(Debug::FONT, "Looking for font family " << family << " ... ");
QString upper = family; QString upper = family;
upper[0] = family[0].toUpper(); upper[0] = family[0].toUpper();
@ -212,26 +212,26 @@ QFont symbolFont(QString const & family, bool * ok)
font.setStyleName("LyX"); font.setStyleName("LyX");
if (isChosenFont(font, family, "LyX")) { if (isChosenFont(font, family, "LyX")) {
LYXERR(Debug::FONT, "lyx!"); LYXERR_NOPOS(Debug::FONT, "lyx!");
*ok = true; *ok = true;
return font; return font;
} }
LYXERR(Debug::FONT, "Trying normal " << family << " ... "); LYXERR_NOENDL(Debug::FONT, "Trying normal " << family << " ... ");
font.setStyleName(QString()); font.setStyleName(QString());
#endif #endif
if (isChosenFont(font, family, QString())) { if (isChosenFont(font, family, QString())) {
LYXERR(Debug::FONT, "normal!"); LYXERR_NOPOS(Debug::FONT, "normal!");
*ok = true; *ok = true;
return font; return font;
} }
LYXERR(Debug::FONT, "Trying " << upper << " ... "); LYXERR_NOENDL(Debug::FONT, "Trying " << upper << " ... ");
font.setFamily(upper); font.setFamily(upper);
if (isChosenFont(font, upper, QString())) { if (isChosenFont(font, upper, QString())) {
LYXERR(Debug::FONT, "upper!"); LYXERR_NOPOS(Debug::FONT, "upper!");
*ok = true; *ok = true;
return font; return font;
} }
@ -240,17 +240,17 @@ QFont symbolFont(QString const & family, bool * ok)
// A simple setFamily() fails on Qt 2 // A simple setFamily() fails on Qt 2
QString const raw = rawName(family); QString const raw = rawName(family);
LYXERR(Debug::FONT, "Trying " << raw << " ... "); LYXERR_NOENDL(Debug::FONT, "Trying " << raw << " ... ");
font.setRawName(raw); font.setRawName(raw);
if (isChosenFont(font, family, QString())) { if (isChosenFont(font, family, QString())) {
LYXERR(Debug::FONT, "raw version!"); LYXERR_NOPOS(Debug::FONT, "raw version!");
*ok = true; *ok = true;
return font; return font;
} }
#endif #endif
LYXERR(Debug::FONT, " FAILED :-("); LYXERR_NOPOS(Debug::FONT, " FAILED :-(");
*ok = false; *ok = false;
return font; return font;
} }

View File

@ -229,6 +229,18 @@ extern LyXErr lyxerr;
else { lyx::lyxerr << CURRENT_POSITION << msg; lyx::lyxerr.endl(); } \ else { lyx::lyxerr << CURRENT_POSITION << msg; lyx::lyxerr.endl(); } \
} while (0) } while (0)
#define LYXERR_NOENDL(type, msg) \
do { \
if (!lyx::lyxerr.debugging(type)) {} \
else { lyx::lyxerr << CURRENT_POSITION << msg; } \
} while (0)
#define LYXERR_NOPOS(type, msg) \
do { \
if (!lyx::lyxerr.debugging(type)) {} \
else { lyx::lyxerr << msg; lyx::lyxerr.endl(); } \
} while (0)
#define LYXERR0(msg) \ #define LYXERR0(msg) \
do { \ do { \
lyx::lyxerr << CURRENT_POSITION << msg; lyx::lyxerr.endl(); \ lyx::lyxerr << CURRENT_POSITION << msg; lyx::lyxerr.endl(); \