[LyX/master] Adjust debug output for fonts
Enrico Forestieri
forenr at lyx.org
Thu Sep 3 08:55:14 UTC 2020
On Tue, Sep 01, 2020 at 11:54:46AM +0200, Enrico Forestieri wrote:
> commit 8039b34802c9e08809c02bb3682ac50439d97951
> Author: Enrico Forestieri <forenr at lyx.org>
> Date: Tue Sep 1 12:12:55 2020 +0200
>
> 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!
> ---
> src/frontends/qt/GuiFontLoader.cpp | 22 +++++++++++-----------
> src/support/debug.h | 12 ++++++++++++
> 2 files changed, 23 insertions(+), 11 deletions(-)
Riki, what about backporting this? It's risk free.
> diff --git a/src/frontends/qt/GuiFontLoader.cpp b/src/frontends/qt/GuiFontLoader.cpp
> index 6f1de04..82dafbf 100644
> --- a/src/frontends/qt/GuiFontLoader.cpp
> +++ b/src/frontends/qt/GuiFontLoader.cpp
> @@ -185,14 +185,14 @@ static bool isChosenFont(QFont & font, QString const & family,
> // positions.
> QFontInfo fi(font);
>
> - LYXERR(Debug::FONT, "got: " << fi.family());
> + LYXERR_NOPOS(Debug::FONT, "got: " << fi.family());
>
> if (fi.family().contains(family)
> #if QT_VERSION >= 0x040800
> && (style.isEmpty() || fi.styleName().contains(style))
> #endif
> ) {
> - LYXERR(Debug::FONT, " got it ");
> + LYXERR_NOENDL(Debug::FONT, " got it ");
> return true;
> }
>
> @@ -202,7 +202,7 @@ static bool isChosenFont(QFont & font, QString const & family,
>
> 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;
> upper[0] = family[0].toUpper();
>
> @@ -212,26 +212,26 @@ QFont symbolFont(QString const & family, bool * ok)
> font.setStyleName("LyX");
>
> if (isChosenFont(font, family, "LyX")) {
> - LYXERR(Debug::FONT, "lyx!");
> + LYXERR_NOPOS(Debug::FONT, "lyx!");
> *ok = true;
> return font;
> }
>
> - LYXERR(Debug::FONT, "Trying normal " << family << " ... ");
> + LYXERR_NOENDL(Debug::FONT, "Trying normal " << family << " ... ");
> font.setStyleName(QString());
> #endif
>
> if (isChosenFont(font, family, QString())) {
> - LYXERR(Debug::FONT, "normal!");
> + LYXERR_NOPOS(Debug::FONT, "normal!");
> *ok = true;
> return font;
> }
>
> - LYXERR(Debug::FONT, "Trying " << upper << " ... ");
> + LYXERR_NOENDL(Debug::FONT, "Trying " << upper << " ... ");
> font.setFamily(upper);
>
> if (isChosenFont(font, upper, QString())) {
> - LYXERR(Debug::FONT, "upper!");
> + LYXERR_NOPOS(Debug::FONT, "upper!");
> *ok = true;
> return font;
> }
> @@ -240,17 +240,17 @@ QFont symbolFont(QString const & family, bool * ok)
> // A simple setFamily() fails on Qt 2
>
> QString const raw = rawName(family);
> - LYXERR(Debug::FONT, "Trying " << raw << " ... ");
> + LYXERR_NOENDL(Debug::FONT, "Trying " << raw << " ... ");
> font.setRawName(raw);
>
> if (isChosenFont(font, family, QString())) {
> - LYXERR(Debug::FONT, "raw version!");
> + LYXERR_NOPOS(Debug::FONT, "raw version!");
> *ok = true;
> return font;
> }
> #endif
>
> - LYXERR(Debug::FONT, " FAILED :-(");
> + LYXERR_NOPOS(Debug::FONT, " FAILED :-(");
> *ok = false;
> return font;
> }
> diff --git a/src/support/debug.h b/src/support/debug.h
> index 10bb5a7..112b66a 100644
> --- a/src/support/debug.h
> +++ b/src/support/debug.h
> @@ -229,6 +229,18 @@ extern LyXErr lyxerr;
> else { lyx::lyxerr << CURRENT_POSITION << msg; lyx::lyxerr.endl(); } \
> } 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) \
> do { \
> lyx::lyxerr << CURRENT_POSITION << msg; lyx::lyxerr.endl(); \
> --
> lyx-cvs mailing list
> lyx-cvs at lists.lyx.org
> http://lists.lyx.org/mailman/listinfo/lyx-cvs
--
Enrico
More information about the lyx-devel
mailing list