[556] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
| 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
---|
| 6 | **
|
---|
| 7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
| 10 | ** Commercial Usage
|
---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
| 14 | ** a written agreement between you and Nokia.
|
---|
| 15 | **
|
---|
| 16 | ** GNU Lesser General Public License Usage
|
---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
| 20 | ** packaging of this file. Please review the following information to
|
---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
| 23 | **
|
---|
| 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
| 27 | **
|
---|
| 28 | ** GNU General Public License Usage
|
---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
| 32 | ** packaging of this file. Please review the following information to
|
---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
| 35 | **
|
---|
| 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at [email protected].
|
---|
| 38 | ** $QT_END_LICENSE$
|
---|
| 39 | **
|
---|
| 40 | ****************************************************************************/
|
---|
| 41 |
|
---|
| 42 | #ifndef QABSTRACTFONTENGINE_QWS_H
|
---|
| 43 | #define QABSTRACTFONTENGINE_QWS_H
|
---|
| 44 |
|
---|
| 45 | #include <QtCore/qobject.h>
|
---|
| 46 | #include <QtCore/qhash.h>
|
---|
| 47 | #include <QtCore/qvariant.h>
|
---|
| 48 | #include <QtCore/qfactoryinterface.h>
|
---|
| 49 | #include <QtGui/qpaintengine.h>
|
---|
| 50 | #include <QtGui/qfontdatabase.h>
|
---|
| 51 |
|
---|
| 52 | QT_BEGIN_HEADER
|
---|
| 53 |
|
---|
| 54 | QT_BEGIN_NAMESPACE
|
---|
| 55 |
|
---|
| 56 | QT_MODULE(Gui)
|
---|
| 57 |
|
---|
| 58 | class QFontEngineInfoPrivate;
|
---|
| 59 |
|
---|
| 60 | class Q_GUI_EXPORT QFontEngineInfo
|
---|
| 61 | {
|
---|
| 62 | public:
|
---|
| 63 | QDOC_PROPERTY(QString family READ family WRITE setFamily)
|
---|
| 64 | QDOC_PROPERTY(qreal pixelSize READ pixelSize WRITE setPixelSize)
|
---|
| 65 | QDOC_PROPERTY(int weight READ weight WRITE setWeight)
|
---|
| 66 | QDOC_PROPERTY(QFont::Style style READ style WRITE setStyle)
|
---|
| 67 | QDOC_PROPERTY(QList<QFontDatabase::WritingSystem> writingSystems READ writingSystems WRITE setWritingSystems)
|
---|
| 68 |
|
---|
| 69 | QFontEngineInfo();
|
---|
| 70 | explicit QFontEngineInfo(const QString &family);
|
---|
| 71 | QFontEngineInfo(const QFontEngineInfo &other);
|
---|
| 72 | QFontEngineInfo &operator=(const QFontEngineInfo &other);
|
---|
| 73 | ~QFontEngineInfo();
|
---|
| 74 |
|
---|
| 75 | void setFamily(const QString &name);
|
---|
| 76 | QString family() const;
|
---|
| 77 |
|
---|
| 78 | void setPixelSize(qreal size);
|
---|
| 79 | qreal pixelSize() const;
|
---|
| 80 |
|
---|
| 81 | void setWeight(int weight);
|
---|
| 82 | int weight() const;
|
---|
| 83 |
|
---|
| 84 | void setStyle(QFont::Style style);
|
---|
| 85 | QFont::Style style() const;
|
---|
| 86 |
|
---|
| 87 | QList<QFontDatabase::WritingSystem> writingSystems() const;
|
---|
| 88 | void setWritingSystems(const QList<QFontDatabase::WritingSystem> &writingSystems);
|
---|
| 89 |
|
---|
| 90 | private:
|
---|
| 91 | QFontEngineInfoPrivate *d;
|
---|
| 92 | };
|
---|
| 93 |
|
---|
| 94 | class QAbstractFontEngine;
|
---|
| 95 |
|
---|
| 96 | struct Q_GUI_EXPORT QFontEngineFactoryInterface : public QFactoryInterface
|
---|
| 97 | {
|
---|
| 98 | virtual QAbstractFontEngine *create(const QFontEngineInfo &info) = 0;
|
---|
| 99 | virtual QList<QFontEngineInfo> availableFontEngines() const = 0;
|
---|
| 100 | };
|
---|
| 101 |
|
---|
| 102 | #define QFontEngineFactoryInterface_iid "com.trolltech.Qt.QFontEngineFactoryInterface"
|
---|
| 103 | Q_DECLARE_INTERFACE(QFontEngineFactoryInterface, QFontEngineFactoryInterface_iid)
|
---|
| 104 |
|
---|
| 105 | class QFontEnginePluginPrivate;
|
---|
| 106 |
|
---|
| 107 | class Q_GUI_EXPORT QFontEnginePlugin : public QObject, public QFontEngineFactoryInterface
|
---|
| 108 | {
|
---|
| 109 | Q_OBJECT
|
---|
| 110 | Q_INTERFACES(QFontEngineFactoryInterface:QFactoryInterface)
|
---|
| 111 | public:
|
---|
| 112 | QFontEnginePlugin(const QString &foundry, QObject *parent = 0);
|
---|
| 113 | ~QFontEnginePlugin();
|
---|
| 114 |
|
---|
| 115 | virtual QStringList keys() const;
|
---|
| 116 |
|
---|
| 117 | virtual QAbstractFontEngine *create(const QFontEngineInfo &info) = 0;
|
---|
| 118 | virtual QList<QFontEngineInfo> availableFontEngines() const = 0;
|
---|
| 119 |
|
---|
| 120 | private:
|
---|
| 121 | Q_DECLARE_PRIVATE(QFontEnginePlugin)
|
---|
| 122 | Q_DISABLE_COPY(QFontEnginePlugin)
|
---|
| 123 | };
|
---|
| 124 |
|
---|
| 125 | class QAbstractFontEnginePrivate;
|
---|
| 126 |
|
---|
| 127 | class Q_GUI_EXPORT QAbstractFontEngine : public QObject
|
---|
| 128 | {
|
---|
| 129 | Q_OBJECT
|
---|
| 130 | public:
|
---|
| 131 | enum Capability {
|
---|
| 132 | CanOutlineGlyphs = 1,
|
---|
| 133 | CanRenderGlyphs_Mono = 2,
|
---|
| 134 | CanRenderGlyphs_Gray = 4,
|
---|
| 135 | CanRenderGlyphs = CanRenderGlyphs_Mono | CanRenderGlyphs_Gray
|
---|
| 136 | };
|
---|
| 137 | Q_DECLARE_FLAGS(Capabilities, Capability)
|
---|
| 138 |
|
---|
| 139 | explicit QAbstractFontEngine(QObject *parent = 0);
|
---|
| 140 | ~QAbstractFontEngine();
|
---|
| 141 |
|
---|
| 142 | typedef int Fixed; // 26.6
|
---|
| 143 |
|
---|
| 144 | struct FixedPoint
|
---|
| 145 | {
|
---|
| 146 | Fixed x;
|
---|
| 147 | Fixed y;
|
---|
| 148 | };
|
---|
| 149 |
|
---|
| 150 | struct GlyphMetrics
|
---|
| 151 | {
|
---|
| 152 | inline GlyphMetrics()
|
---|
| 153 | : x(0), y(0), width(0), height(0),
|
---|
| 154 | advance(0) {}
|
---|
| 155 | Fixed x;
|
---|
| 156 | Fixed y;
|
---|
| 157 | Fixed width;
|
---|
| 158 | Fixed height;
|
---|
| 159 | Fixed advance;
|
---|
| 160 | };
|
---|
| 161 |
|
---|
| 162 | enum FontProperty {
|
---|
| 163 | Ascent,
|
---|
| 164 | Descent,
|
---|
| 165 | Leading,
|
---|
| 166 | XHeight,
|
---|
| 167 | AverageCharWidth,
|
---|
| 168 | LineThickness,
|
---|
| 169 | UnderlinePosition,
|
---|
| 170 | MaxCharWidth,
|
---|
| 171 | MinLeftBearing,
|
---|
| 172 | MinRightBearing,
|
---|
| 173 | GlyphCount,
|
---|
| 174 |
|
---|
| 175 | // hints
|
---|
| 176 | CacheGlyphsHint,
|
---|
| 177 | OutlineGlyphsHint
|
---|
| 178 | };
|
---|
| 179 |
|
---|
| 180 | // keep in sync with QTextEngine::ShaperFlag!!
|
---|
| 181 | enum TextShapingFlag {
|
---|
| 182 | RightToLeft = 0x0001,
|
---|
| 183 | ReturnDesignMetrics = 0x0002
|
---|
| 184 | };
|
---|
| 185 | Q_DECLARE_FLAGS(TextShapingFlags, TextShapingFlag)
|
---|
| 186 |
|
---|
| 187 | virtual Capabilities capabilities() const = 0;
|
---|
| 188 | virtual QVariant fontProperty(FontProperty property) const = 0;
|
---|
| 189 |
|
---|
| 190 | virtual bool convertStringToGlyphIndices(const QChar *string, int length, uint *glyphs, int *numGlyphs, TextShapingFlags flags) const = 0;
|
---|
| 191 |
|
---|
| 192 | virtual void getGlyphAdvances(const uint *glyphs, int numGlyphs, Fixed *advances, TextShapingFlags flags) const = 0;
|
---|
| 193 |
|
---|
| 194 | virtual GlyphMetrics glyphMetrics(uint glyph) const = 0;
|
---|
| 195 |
|
---|
| 196 | virtual bool renderGlyph(uint glyph, int depth, int bytesPerLine, int height, uchar *buffer);
|
---|
| 197 |
|
---|
| 198 | virtual void addGlyphOutlinesToPath(uint *glyphs, int numGlyphs, FixedPoint *positions, QPainterPath *path);
|
---|
| 199 |
|
---|
| 200 | /*
|
---|
| 201 | enum Extension {
|
---|
| 202 | GetTrueTypeTable
|
---|
| 203 | };
|
---|
| 204 |
|
---|
| 205 | virtual bool supportsExtension(Extension extension) const;
|
---|
| 206 | virtual QVariant extension(Extension extension, const QVariant &argument = QVariant());
|
---|
| 207 | */
|
---|
| 208 |
|
---|
| 209 | private:
|
---|
| 210 | Q_DECLARE_PRIVATE(QAbstractFontEngine)
|
---|
| 211 | Q_DISABLE_COPY(QAbstractFontEngine)
|
---|
| 212 | };
|
---|
| 213 |
|
---|
| 214 | Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractFontEngine::Capabilities)
|
---|
| 215 | Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractFontEngine::TextShapingFlags)
|
---|
| 216 |
|
---|
| 217 | QT_END_NAMESPACE
|
---|
| 218 |
|
---|
| 219 | QT_END_HEADER
|
---|
| 220 |
|
---|
| 221 | #endif
|
---|