Go
to the documentation of this file.
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef QABSTRACTFONTENGINE_QWS_H
00043 #define QABSTRACTFONTENGINE_QWS_H
00044
00045 #include <QtCore/qobject.h>
00046 #include <QtCore/qhash.h>
00047 #include <QtCore/qvariant.h>
00048 #include <QtCore/qfactoryinterface.h>
00049 #include <QtGui/qpaintengine.h>
00050 #include <QtGui/qfontdatabase.h>
00051
00052 QT_BEGIN_HEADER
00053
00054 QT_BEGIN_NAMESPACE
00055
00056 QT_MODULE(Gui)
00057
00058 class QFontEngineInfoPrivate;
00059
00060 class Q_GUI_EXPORT QFontEngineInfo
00061 {
00062 public:
00063 QDOC_PROPERTY(QString family READ family WRITE setFamily)
00064 QDOC_PROPERTY(qreal pixelSize READ pixelSize WRITE setPixelSize)
00065 QDOC_PROPERTY(int weight READ weight WRITE setWeight)
00066 QDOC_PROPERTY(QFont::Style style READ style WRITE setStyle)
00067 QDOC_PROPERTY(QList<QFontDatabase::WritingSystem> writingSystems READ writingSystems WRITE setWritingSystems)
00068
00069 QFontEngineInfo();
00070 explicit QFontEngineInfo(const QString &family);
00071 QFontEngineInfo(const QFontEngineInfo &other);
00072 QFontEngineInfo &operator=(const QFontEngineInfo &other);
00073 ~QFontEngineInfo();
00074
00075 void setFamily(const QString &name);
00076 QString family() const;
00077
00078 void setPixelSize(qreal size);
00079 qreal pixelSize() const;
00080
00081 void setWeight(int weight);
00082 int weight() const;
00083
00084 void setStyle(QFont::Style style);
00085 QFont::Style style() const;
00086
00087 QList<QFontDatabase::WritingSystem> writingSystems() const;
00088 void setWritingSystems(const QList<QFontDatabase::WritingSystem> &writingSystems);
00089
00090 private:
00091 QFontEngineInfoPrivate *d;
00092 };
00093
00094 class QAbstractFontEngine;
00095
00096 struct Q_GUI_EXPORT QFontEngineFactoryInterface : public QFactoryInterface
00097 {
00098 virtual QAbstractFontEngine *create(const QFontEngineInfo &info) = 0;
00099 virtual QList<QFontEngineInfo> availableFontEngines() const = 0;
00100 };
00101
00102 #define QFontEngineFactoryInterface_iid "com.trolltech.Qt.QFontEngineFactoryInterface"
00103 Q_DECLARE_INTERFACE(QFontEngineFactoryInterface, QFontEngineFactoryInterface_iid)
00104
00105 class QFontEnginePluginPrivate;
00106
00107 class Q_GUI_EXPORT QFontEnginePlugin : public QObject, public QFontEngineFactoryInterface
00108 {
00109 Q_OBJECT
00110 Q_INTERFACES(QFontEngineFactoryInterface:QFactoryInterface)
00111 public:
00112 QFontEnginePlugin(const QString &foundry, QObject *parent = 0);
00113 ~QFontEnginePlugin();
00114
00115 virtual QStringList keys() const;
00116
00117 virtual QAbstractFontEngine *create(const QFontEngineInfo &info) = 0;
00118 virtual QList<QFontEngineInfo> availableFontEngines() const = 0;
00119
00120 private:
00121 Q_DECLARE_PRIVATE(QFontEnginePlugin)
00122 Q_DISABLE_COPY(QFontEnginePlugin)
00123 };
00124
00125 class QAbstractFontEnginePrivate;
00126
00127 class Q_GUI_EXPORT QAbstractFontEngine : public QObject
00128 {
00129 Q_OBJECT
00130 public:
00131 enum Capability {
00132 CanOutlineGlyphs = 1,
00133 CanRenderGlyphs_Mono = 2,
00134 CanRenderGlyphs_Gray = 4,
00135 CanRenderGlyphs = CanRenderGlyphs_Mono | CanRenderGlyphs_Gray
00136 };
00137 Q_DECLARE_FLAGS(Capabilities, Capability)
00138
00139 explicit QAbstractFontEngine(QObject *parent = 0);
00140 ~QAbstractFontEngine();
00141
00142 typedef int Fixed;
00143
00144 struct FixedPoint
00145 {
00146 Fixed x;
00147 Fixed y;
00148 };
00149
00150 struct GlyphMetrics
00151 {
00152 inline GlyphMetrics()
00153 : x(0), y(0), width(0), height(0),
00154 advance(0) {}
00155 Fixed x;
00156 Fixed y;
00157 Fixed width;
00158 Fixed height;
00159 Fixed advance;
00160 };
00161
00162 enum FontProperty {
00163 Ascent,
00164 Descent,
00165 Leading,
00166 XHeight,
00167 AverageCharWidth,
00168 LineThickness,
00169 UnderlinePosition,
00170 MaxCharWidth,
00171 MinLeftBearing,
00172 MinRightBearing,
00173 GlyphCount,
00174
00175
00176 CacheGlyphsHint,
00177 OutlineGlyphsHint
00178 };
00179
00180
00181 enum TextShapingFlag {
00182 RightToLeft = 0x0001,
00183 ReturnDesignMetrics = 0x0002
00184 };
00185 Q_DECLARE_FLAGS(TextShapingFlags, TextShapingFlag)
00186
00187 virtual Capabilities capabilities() const = 0;
00188 virtual QVariant fontProperty(FontProperty property) const = 0;
00189
00190 virtual bool convertStringToGlyphIndices(const QChar *string, int length, uint *glyphs, int *numGlyphs, TextShapingFlags flags) const = 0;
00191
00192 virtual void getGlyphAdvances(const uint *glyphs, int numGlyphs, Fixed *advances, TextShapingFlags flags) const = 0;
00193
00194 virtual GlyphMetrics glyphMetrics(uint glyph) const = 0;
00195
00196 virtual bool renderGlyph(uint glyph, int depth, int bytesPerLine, int height, uchar *buffer);
00197
00198 virtual void addGlyphOutlinesToPath(uint *glyphs, int numGlyphs, FixedPoint *positions, QPainterPath *path);
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209 private:
00210 Q_DECLARE_PRIVATE(QAbstractFontEngine)
00211 Q_DISABLE_COPY(QAbstractFontEngine)
00212 };
00213
00214 Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractFontEngine::Capabilities)
00215 Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractFontEngine::TextShapingFlags)
00216
00217 QT_END_NAMESPACE
00218
00219 QT_END_HEADER
00220
00221 #endif