Fix uses of qRound on non-floating-point types.
[profile/ivi/qtbase.git] / src / gui / text / qfontengine_x11.cpp
index 4260b85..490866c 100644 (file)
@@ -7,29 +7,29 @@
 ** This file is part of the QtGui module of the Qt Toolkit.
 **
 ** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
 ** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file.  Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 **
 ** In addition, as a special exception, Nokia gives you certain additional
-** rights.  These rights are described in the Nokia Qt LGPL Exception
+** rights. These rights are described in the Nokia Qt LGPL Exception
 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
 **
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
 **
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
 **
 **
 **
@@ -863,11 +863,8 @@ glyph_t QFontEngineXLFD::glyphIndexToFreetypeGlyphIndex(glyph_t g) const
 // Multi FT engine
 // ------------------------------------------------------------------
 
-static QFontEngine *engineForPattern(FcPattern *pattern, const QFontDef &request,
-                                     int screen)
+static QFontEngine *engineForPattern(FcPattern *match, const QFontDef &request, int screen)
 {
-    FcResult res;
-    FcPattern *match = FcFontMatch(0, pattern, &res);
     QFontEngineX11FT *engine = new QFontEngineX11FT(match, request, screen);
     if (!engine->invalid())
         return engine;
@@ -879,9 +876,9 @@ static QFontEngine *engineForPattern(FcPattern *pattern, const QFontDef &request
 }
 
 QFontEngineMultiFT::QFontEngineMultiFT(QFontEngine *fe, FcPattern *matchedPattern, FcPattern *p, int s, const QFontDef &req)
-    : QFontEngineMulti(2), request(req), pattern(p), firstEnginePattern(matchedPattern), fontSet(0), screen(s)
+    : QFontEngineMulti(2), request(req), pattern(p), fontSet(0), screen(s)
 {
-
+    firstEnginePattern = FcPatternDuplicate(matchedPattern);
     engines[0] = fe;
     engines.at(0)->ref.ref();
     fontDef = engines[0]->fontDef;
@@ -907,8 +904,6 @@ void QFontEngineMultiFT::loadEngine(int at)
     extern QMutex *qt_fontdatabase_mutex();
     QMutexLocker locker(qt_fontdatabase_mutex());
 
-    extern void qt_addPatternProps(FcPattern *pattern, int screen, int script,
-                                   const QFontDef &request);
     extern QFontDef qt_FcPatternToQFontDef(FcPattern *pattern, const QFontDef &);
     extern FcFontSet *qt_fontSetForPattern(FcPattern *pattern, const QFontDef &request);
 
@@ -940,22 +935,18 @@ void QFontEngineMultiFT::loadEngine(int at)
     Q_ASSERT(at < engines.size());
     Q_ASSERT(engines.at(at) == 0);
 
-    FcPattern *pattern = FcPatternDuplicate(fontSet->fonts[at + firstFontIndex - 1]);
-    qt_addPatternProps(pattern, screen, QUnicodeTables::Common, request);
-
-    QFontDef fontDef = qt_FcPatternToQFontDef(pattern, this->request);
+    FcPattern *match = FcFontRenderPrepare(NULL, pattern, fontSet->fonts[at + firstFontIndex - 1]);
+    QFontDef fontDef = qt_FcPatternToQFontDef(match, this->request);
 
     // note: we use -1 for the script to make sure that we keep real
     // FT engines separate from Multi engines in the font cache
     QFontCache::Key key(fontDef, -1, screen);
     QFontEngine *fontEngine = QFontCache::instance()->findEngine(key);
     if (!fontEngine) {
-        FcConfigSubstitute(0, pattern, FcMatchPattern);
-        FcDefaultSubstitute(pattern);
-        fontEngine = engineForPattern(pattern, request, screen);
+        fontEngine = engineForPattern(match, request, screen);
         QFontCache::instance()->insertEngine(key, fontEngine);
     }
-    FcPatternDestroy(pattern);
+    FcPatternDestroy(match);
     fontEngine->ref.ref();
     engines[at] = fontEngine;
 }
@@ -1123,17 +1114,14 @@ QFontEngineX11FT::QFontEngineX11FT(FcPattern *pattern, const QFontDef &fd, int s
     }
 #endif
 
-    if (!init(face_id, antialias, defaultFormat)) {
-        FcPatternDestroy(pattern);
+    if (!init(face_id, antialias, defaultFormat))
         return;
-    }
 
     if (!freetype->charset) {
         FcCharSet *cs;
         FcPatternGetCharSet (pattern, FC_CHARSET, 0, &cs);
         freetype->charset = FcCharSetCopy(cs);
     }
-    FcPatternDestroy(pattern);
 }
 
 QFontEngineX11FT::~QFontEngineX11FT()
@@ -1205,7 +1193,9 @@ QFontEngine *QFontEngineX11FT::cloneWithSize(qreal pixelSize) const
         delete fe;
         return 0;
     } else {
+#ifndef QT_NO_XRENDER
         fe->xglyph_format = xglyph_format;
+#endif
         return fe;
     }
 }