Fix uses of qRound on non-floating-point types.
[profile/ivi/qtbase.git] / src / gui / text / qfontengine_x11_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of the QtGui module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 **
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 **
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
29 **
30 ** Other Usage
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QFONTENGINE_X11_P_H
43 #define QFONTENGINE_X11_P_H
44
45 //
46 //  W A R N I N G
47 //  -------------
48 //
49 // This file is not part of the Qt API.  It exists purely as an
50 // implementation detail.  This header file may change from version to
51 // version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55 #include <private/qt_x11_p.h>
56
57 #include <private/qfontengine_ft_p.h>
58
59 QT_BEGIN_NAMESPACE
60
61 class QFreetypeFace;
62
63 // --------------------------------------------------------------------------
64
65 class QFontEngineMultiXLFD : public QFontEngineMulti
66 {
67 public:
68     QFontEngineMultiXLFD(const QFontDef &r, const QList<int> &l, int s);
69     ~QFontEngineMultiXLFD();
70
71     void loadEngine(int at);
72
73 private:
74     QList<int> encodings;
75     int screen;
76     QFontDef request;
77 };
78
79 /**
80  * \internal The font engine for X Logical Font Description (XLFD) fonts, which is for X11 systems without freetype.
81  */
82 class QFontEngineXLFD : public QFontEngine
83 {
84 public:
85     QFontEngineXLFD(XFontStruct *f, const QByteArray &name, int mib);
86     ~QFontEngineXLFD();
87
88     virtual QFontEngine::FaceId faceId() const;
89     QFontEngine::Properties properties() const;
90     virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics);
91     virtual bool getSfntTableData(uint tag, uchar *buffer, uint *length) const;
92     virtual int synthesized() const;
93
94     virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs,
95                       QTextEngine::ShaperFlags flags) const;
96     virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const;
97
98     virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);
99     virtual glyph_metrics_t boundingBox(glyph_t glyph);
100
101     virtual void addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path, QTextItem::RenderFlags);
102     virtual QFixed ascent() const;
103     virtual QFixed descent() const;
104     virtual QFixed leading() const;
105     virtual qreal maxCharWidth() const;
106     virtual qreal minLeftBearing() const;
107     virtual qreal minRightBearing() const;
108     virtual QImage alphaMapForGlyph(glyph_t);
109
110     virtual inline Type type() const
111     { return QFontEngine::XLFD; }
112
113     virtual bool canRender(const QChar *string, int len);
114     virtual const char *name() const;
115
116     inline XFontStruct *fontStruct() const
117     { return _fs; }
118
119 #ifndef QT_NO_FREETYPE
120     FT_Face non_locked_face() const;
121     glyph_t glyphIndexToFreetypeGlyphIndex(glyph_t g) const;
122 #endif
123     uint toUnicode(glyph_t g) const;
124
125 private:
126     QBitmap bitmapForGlyphs(const QGlyphLayout &glyphs, const glyph_metrics_t &metrics, QTextItem::RenderFlags flags = 0);
127
128     XFontStruct *_fs;
129     QByteArray _name;
130     QTextCodec *_codec;
131     int _cmap;
132     int lbearing, rbearing;
133     mutable QFontEngine::FaceId face_id;
134     mutable QFreetypeFace *freetype;
135     mutable int synth;
136 };
137
138 #ifndef QT_NO_FONTCONFIG
139
140 class Q_GUI_EXPORT QFontEngineMultiFT : public QFontEngineMulti
141 {
142 public:
143     QFontEngineMultiFT(QFontEngine *fe, FcPattern *firstEnginePattern, FcPattern *p, int s, const QFontDef &request);
144     ~QFontEngineMultiFT();
145
146     void loadEngine(int at);
147
148 private:
149     QFontDef request;
150     FcPattern *pattern;
151     FcPattern *firstEnginePattern;
152     FcFontSet *fontSet;
153     int screen;
154     int firstFontIndex; // first font in fontset
155 };
156
157 class Q_GUI_EXPORT QFontEngineX11FT : public QFontEngineFT
158 {
159 public:
160     explicit QFontEngineX11FT(const QFontDef &fontDef) : QFontEngineFT(fontDef) {}
161     explicit QFontEngineX11FT(FcPattern *pattern, const QFontDef &fd, int screen);
162     ~QFontEngineX11FT();
163
164     QFontEngine *cloneWithSize(qreal pixelSize) const;
165
166 #ifndef QT_NO_XRENDER
167     int xglyph_format;
168 #endif
169
170 protected:
171     virtual bool uploadGlyphToServer(QGlyphSet *set, uint glyphid, Glyph *g, GlyphInfo *info, int glyphDataSize) const;
172     virtual unsigned long allocateServerGlyphSet();
173     virtual void freeServerGlyphSet(unsigned long id);
174 };
175
176 #endif // QT_NO_FONTCONFIG
177
178 QT_END_NAMESPACE
179
180 #endif // QFONTENGINE_X11_P_H