From d4cd998fecb5f005a5d02fcfe1514bad2a0baa6b Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Wed, 13 Oct 2010 18:43:23 +0200 Subject: Fix fontconfig pattern merging When merging fontconfig patterns, we need to clean up existing object first, otherwise the added object will be appended instead of replacing the existing object. When multiple font engines are using shaping, if fontconfig patterns are not correctly merged, it will result using the old font. For instance, in "Fake Bold Normal", "Normal" text will continue using the font for "Fake Bold" (that only happen with fallback fonts). Task-number: QTBUG-14455 Reviewed-by: Eskil --- src/gui/text/qfontdatabase_x11.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gui/text/qfontdatabase_x11.cpp b/src/gui/text/qfontdatabase_x11.cpp index 2fa16bb..67bcc7a 100644 --- a/src/gui/text/qfontdatabase_x11.cpp +++ b/src/gui/text/qfontdatabase_x11.cpp @@ -1462,6 +1462,7 @@ void qt_addPatternProps(FcPattern *pattern, int screen, int script, const QFontD weight_value = FC_WEIGHT_DEMIBOLD; else if (request.weight < (QFont::Bold + QFont::Black) / 2) weight_value = FC_WEIGHT_BOLD; + FcPatternDel(pattern, FC_WEIGHT); FcPatternAddInteger(pattern, FC_WEIGHT, weight_value); int slant_value = FC_SLANT_ROMAN; @@ -1469,20 +1470,25 @@ void qt_addPatternProps(FcPattern *pattern, int screen, int script, const QFontD slant_value = FC_SLANT_ITALIC; else if (request.style == QFont::StyleOblique) slant_value = FC_SLANT_OBLIQUE; + FcPatternDel(pattern, FC_SLANT); FcPatternAddInteger(pattern, FC_SLANT, slant_value); double size_value = qMax(qreal(1.), request.pixelSize); + FcPatternDel(pattern, FC_PIXEL_SIZE); FcPatternAddDouble(pattern, FC_PIXEL_SIZE, size_value); int stretch = request.stretch; if (!stretch) stretch = 100; + FcPatternDel(pattern, FC_WIDTH); FcPatternAddInteger(pattern, FC_WIDTH, stretch); if (X11->display && QX11Info::appDepth(screen) <= 8) { + FcPatternDel(pattern, FC_ANTIALIAS); // can't do antialiasing on 8bpp FcPatternAddBool(pattern, FC_ANTIALIAS, false); } else if (request.styleStrategy & (QFont::PreferAntialias|QFont::NoAntialias)) { + FcPatternDel(pattern, FC_ANTIALIAS); FcPatternAddBool(pattern, FC_ANTIALIAS, !(request.styleStrategy & QFont::NoAntialias)); } @@ -1491,6 +1497,7 @@ void qt_addPatternProps(FcPattern *pattern, int screen, int script, const QFontD Q_ASSERT(script < QUnicodeTables::ScriptCount); FcLangSet *ls = FcLangSetCreate(); FcLangSetAdd(ls, (const FcChar8*)specialLanguages[script]); + FcPatternDel(pattern, FC_LANG); FcPatternAddLangSet(pattern, FC_LANG, ls); FcLangSetDestroy(ls); } -- cgit v0.12