Get started with patching up the Qt GUI docs
[profile/ivi/qtbase.git] / src / gui / text / qrawfont.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
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.
16 **
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.
20 **
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.
28 **
29 ** Other Usage
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.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QRAWFONT_H
43 #define QRAWFONT_H
44
45 #include <QtCore/qstring.h>
46 #include <QtCore/qiodevice.h>
47 #include <QtCore/qglobal.h>
48 #include <QtCore/qobject.h>
49 #include <QtCore/qpoint.h>
50 #include <QtGui/qfont.h>
51 #include <QtGui/qtransform.h>
52 #include <QtGui/qfontdatabase.h>
53
54 #if !defined(QT_NO_RAWFONT)
55
56 QT_BEGIN_HEADER
57
58 QT_BEGIN_NAMESPACE
59
60
61 class QRawFontPrivate;
62 class Q_GUI_EXPORT QRawFont
63 {
64 public:
65     enum AntialiasingType {
66         PixelAntialiasing,
67         SubPixelAntialiasing
68     };
69
70     QRawFont();
71     QRawFont(const QString &fileName,
72              qreal pixelSize,
73              QFont::HintingPreference hintingPreference = QFont::PreferDefaultHinting);
74     QRawFont(const QByteArray &fontData,
75              qreal pixelSize,
76              QFont::HintingPreference hintingPreference = QFont::PreferDefaultHinting);
77     QRawFont(const QRawFont &other);
78     ~QRawFont();
79
80     bool isValid() const;
81
82     QRawFont &operator=(const QRawFont &other);
83
84     bool operator==(const QRawFont &other) const;
85     inline bool operator!=(const QRawFont &other) const
86     { return !operator==(other); }
87
88     QString familyName() const;
89     QString styleName() const;
90
91     QFont::Style style() const;
92     int weight() const;
93
94     QVector<quint32> glyphIndexesForString(const QString &text) const;
95     QVector<QPointF> advancesForGlyphIndexes(const QVector<quint32> &glyphIndexes) const;
96     bool glyphIndexesForChars(const QChar *chars, int numChars, quint32 *glyphIndexes, int *numGlyphs) const;
97     bool advancesForGlyphIndexes(const quint32 *glyphIndexes, QPointF *advances, int numGlyphs) const;
98
99     QImage alphaMapForGlyph(quint32 glyphIndex,
100                             AntialiasingType antialiasingType = SubPixelAntialiasing,
101                             const QTransform &transform = QTransform()) const;
102     QPainterPath pathForGlyph(quint32 glyphIndex) const;
103     QRectF boundingRect(quint32 glyphIndex) const;
104
105     void setPixelSize(qreal pixelSize);
106     qreal pixelSize() const;
107
108     QFont::HintingPreference hintingPreference() const;
109
110     qreal ascent() const;
111     qreal descent() const;
112     qreal leading() const;
113     qreal xHeight() const;
114     qreal averageCharWidth() const;
115     qreal maxCharWidth() const;
116     qreal lineThickness() const;
117     qreal underlinePosition() const;
118
119     qreal unitsPerEm() const;
120
121     void loadFromFile(const QString &fileName,
122                       qreal pixelSize,
123                       QFont::HintingPreference hintingPreference);
124
125     void loadFromData(const QByteArray &fontData,
126                       qreal pixelSize,
127                       QFont::HintingPreference hintingPreference);
128
129     bool supportsCharacter(uint ucs4) const;
130     bool supportsCharacter(QChar character) const;
131     QList<QFontDatabase::WritingSystem> supportedWritingSystems() const;
132
133     QByteArray fontTable(const char *tagName) const;
134
135     static QRawFont fromFont(const QFont &font,
136                              QFontDatabase::WritingSystem writingSystem = QFontDatabase::Any);
137
138 private:
139     friend class QRawFontPrivate;
140     friend class QTextLayout;
141     friend class QTextEngine;
142
143     QExplicitlySharedDataPointer<QRawFontPrivate> d;
144 };
145
146 QT_END_NAMESPACE
147
148 QT_END_HEADER
149
150 #endif // QT_NO_RAWFONT
151
152 #endif // QRAWFONT_H