1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtGui module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #ifndef QWINDOWSFONTENGINE_H
43 #define QWINDOWSFONTENGINE_H
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.
56 #include <QtGui/private/qfontengine_p.h>
58 #include <QtGui/QImage>
59 #include <QtCore/QSharedPointer>
60 #include <QtCore/QMetaType>
62 #include "qtwindows_additional.h"
66 class QWindowsNativeImage;
67 class QWindowsFontEngineData;
69 class QWindowsFontEngine : public QFontEngine
72 Q_PROPERTY(HFONT hFont READ hFont STORED false)
73 Q_PROPERTY(LOGFONT logFont READ logFont STORED false)
74 Q_PROPERTY(bool trueType READ trueType STORED false)
77 QWindowsFontEngine(const QString &name, HFONT, bool, LOGFONT,
78 const QSharedPointer<QWindowsFontEngineData> &fontEngineData);
80 ~QWindowsFontEngine();
81 void initFontInfo(const QFontDef &request,
82 HDC fontHdc, int dpi);
84 virtual QFixed lineThickness() const;
85 virtual Properties properties() const;
86 virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics);
87 virtual FaceId faceId() const;
88 virtual bool getSfntTableData(uint tag, uchar *buffer, uint *length) const;
89 virtual int synthesized() const;
90 virtual QFixed emSquareSize() const;
92 virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const;
93 virtual void recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags) const;
95 virtual void addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path, QTextItem::RenderFlags flags);
96 virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs,
97 QPainterPath *path, QTextItem::RenderFlags flags);
99 HGDIOBJ selectDesignFont() const;
101 virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);
102 virtual glyph_metrics_t boundingBox(glyph_t g) { return boundingBox(g, QTransform()); }
103 virtual glyph_metrics_t boundingBox(glyph_t g, const QTransform &t);
106 virtual QFixed ascent() const;
107 virtual QFixed descent() const;
108 virtual QFixed leading() const;
109 virtual QFixed xHeight() const;
110 virtual QFixed averageCharWidth() const;
111 virtual qreal maxCharWidth() const;
112 virtual qreal minLeftBearing() const;
113 virtual qreal minRightBearing() const;
115 virtual const char *name() const;
117 bool canRender(const QChar *string, int len);
121 virtual QImage alphaMapForGlyph(glyph_t t) { return alphaMapForGlyph(t, QTransform()); }
122 virtual QImage alphaMapForGlyph(glyph_t, const QTransform &xform);
123 virtual QImage alphaRGBMapForGlyph(glyph_t t, QFixed subPixelPosition, const QTransform &xform);
125 virtual QFontEngine *cloneWithSize(qreal pixelSize) const;
128 virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0);
131 int getGlyphIndexes(const QChar *ch, int numChars, QGlyphLayout *glyphs, bool mirrored) const;
134 bool getOutlineMetrics(glyph_t glyph, const QTransform &t, glyph_metrics_t *metrics) const;
136 const QSharedPointer<QWindowsFontEngineData> &fontEngineData() const { return m_fontEngineData; }
138 // Properties accessed by QWin32PrintEngine (QtPrintSupport)
139 LOGFONT logFont() const { return m_logfont; }
140 HFONT hFont() const { return hfont; }
141 bool trueType() const { return ttf; }
143 void setUniqueFamilyName(const QString &newName) { uniqueFamilyName = newName; }
146 QWindowsNativeImage *drawGDIGlyph(HFONT font, glyph_t, int margin, const QTransform &xform,
147 QImage::Format mask_format);
149 const QSharedPointer<QWindowsFontEngineData> m_fontEngineData;
152 QString uniqueFamilyName;
154 const LOGFONT m_logfont;
160 const unsigned char *cmap;
161 QByteArray cmapTable;
162 mutable qreal lbearing;
163 mutable qreal rbearing;
164 QFixed designToDevice;
169 mutable int synthesized_flags;
170 mutable QFixed lineWidth;
171 mutable unsigned char *widthCache;
172 mutable uint widthCacheSize;
173 mutable QFixed *designAdvances;
174 mutable int designAdvancesSize;
177 class QWindowsMultiFontEngine : public QFontEngineMulti
180 QWindowsMultiFontEngine(QFontEngine *first, const QStringList &fallbacks);
181 virtual ~QWindowsMultiFontEngine();
182 void loadEngine(int at);
184 QStringList fallbacks;
189 Q_DECLARE_METATYPE(HFONT)
190 Q_DECLARE_METATYPE(LOGFONT)
192 #endif // QWINDOWSFONTENGINE_H