Fix symbol fonts support with FT engine
authorJiang Jiang <jiang.jiang@nokia.com>
Thu, 10 Nov 2011 18:04:14 +0000 (19:04 +0100)
committerQt by Nokia <qt-info@nokia.com>
Fri, 11 Nov 2011 15:47:23 +0000 (16:47 +0100)
It appears that the symbol_map we obtained with FreeType doesn't
work for common symbol fonts like Wingdings, in previous X11 code
we use the code path with normal charmap, to enable it we need to
make sure QT_NO_FONTCONFIG is not defined. And since the FcCharset
functions doesn't really operates on the font database, we can
safely skip the mutex calls.

Change-Id: I8c484de200be1d47c053b10be2c51d2273dcd359
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
src/gui/text/qfontengine_ft.cpp
src/platformsupport/fontdatabases/fontconfig/fontconfig.pri
src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp

index 6845c67..0747249 100644 (file)
@@ -1485,11 +1485,6 @@ bool QFontEngineFT::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs
         return false;
     }
 
-#if !defined(QT_NO_FONTCONFIG)
-    extern QMutex *qt_fontdatabase_mutex();
-    QMutex *mtx = 0;
-#endif
-
     bool mirrored = flags & QTextEngine::RightToLeft;
     int glyph_pos = 0;
     if (freetype->symbol_map) {
@@ -1500,11 +1495,6 @@ bool QFontEngineFT::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs
             if ( !glyphs->glyphs[glyph_pos] ) {
                 glyph_t glyph;
 #if !defined(QT_NO_FONTCONFIG)
-                if (!mtx) {
-                    mtx = qt_fontdatabase_mutex();
-                    mtx->lock();
-                }
-
                 if (freetype->charset != 0 && FcCharSetHasChar(freetype->charset, uc)) {
 #else
                 if (false) {
@@ -1535,11 +1525,6 @@ bool QFontEngineFT::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs
             glyphs->glyphs[glyph_pos] = uc < QFreetypeFace::cmapCacheSize ? freetype->cmapCache[uc] : 0;
             if (!glyphs->glyphs[glyph_pos]) {
 #if !defined(QT_NO_FONTCONFIG)
-                if (!mtx) {
-                    mtx = qt_fontdatabase_mutex();
-                    mtx->lock();
-                }
-
                 if (freetype->charset == 0 || FcCharSetHasChar(freetype->charset, uc))
 #endif
                 {
@@ -1561,11 +1546,6 @@ bool QFontEngineFT::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs
     *nglyphs = glyph_pos;
     glyphs->numGlyphs = glyph_pos;
 
-#if !defined(QT_NO_FONTCONFIG)
-    if (mtx)
-        mtx->unlock();
-#endif
-
     if (flags & QTextEngine::GlyphIndicesOnly)
         return true;
 
index 2efcb4d..7ea1c64 100644 (file)
@@ -1,2 +1,3 @@
 HEADERS += $$PWD/qfontconfigdatabase_p.h
 SOURCES += $$PWD/qfontconfigdatabase.cpp
+DEFINES -= QT_NO_FONTCONFIG
index 3c37be2..575fbb9 100644 (file)
@@ -503,6 +503,7 @@ QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, QUnicodeTables::
 
     FcResult result;
     FcPattern *match = FcFontMatch(0, pattern, &result);
+    FcCharSet *charset;
     if (match) {
         QFontEngineFT::HintStyle default_hint_style;
 
@@ -549,6 +550,7 @@ QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, QUnicodeTables::
         } else
             format = QFontEngineFT::Format_Mono;
 
+        FcPatternGetCharSet(match, FC_CHARSET, 0, &charset);
         FcPatternDestroy(match);
     } else
         format = antialias ? QFontEngineFT::Format_A8 : QFontEngineFT::Format_Mono;
@@ -571,6 +573,9 @@ QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, QUnicodeTables::
         }
     }
 
+    if (engine && engine->freetype && !engine->freetype->charset)
+        engine->freetype->charset = FcCharSetCopy(charset);
+
     return engine;
 }