1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 or version 3 as published by the Free
20 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22 ** following information to ensure the GNU Lesser General Public License
23 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 **
26 ** As a special exception, The Qt Company gives you certain additional
27 ** rights. These rights are described in The Qt Company LGPL Exception
28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 **
30 ** GNU General Public License Usage
31 ** Alternatively, this file may be used under the terms of the GNU
32 ** General Public License version 3.0 as published by the Free Software
33 ** Foundation and appearing in the file LICENSE.GPL included in the
34 ** packaging of this file.  Please review the following information to
35 ** ensure the GNU General Public License version 3.0 requirements will be
36 ** met: http://www.gnu.org/copyleft/gpl.html.
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QFONTENGINE_S60_P_H
43 #define QFONTENGINE_S60_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 
56 #include "qconfig.h"
57 #include <private/qfontengine_p.h>
58 #include "qsize.h"
59 #include <openfont.h>
60 
61 // The glyph outline code is intentionally disabled. It will be reactivated as
62 // soon as the glyph outline API is backported from Symbian(^4) to Symbian(^3).
63 #if 0
64 #define Q_SYMBIAN_HAS_GLYPHOUTLINE_API
65 #endif
66 
67 class CFont;
68 
69 QT_BEGIN_NAMESPACE
70 
71 // ..gives us access to truetype tables
72 class QSymbianTypeFaceExtras
73 {
74 public:
75     QSymbianTypeFaceExtras(CFont* cFont, COpenFont *openFont = 0);
76     ~QSymbianTypeFaceExtras();
77 
78     QByteArray getSfntTable(uint tag) const;
79     bool getSfntTableData(uint tag, uchar *buffer, uint *length) const;
80     const uchar *cmap() const;
81     CFont *fontOwner() const;
82     bool isSymbolCMap() const;
83     QFixed unitsPerEm() const;
84     static bool symbianFontTableApiAvailable();
85 
86 private:
87     CFont* m_cFont;
88     mutable bool m_symbolCMap;
89     mutable QByteArray m_cmapTable;
90     mutable QFixed m_unitsPerEm;
91 
92     // m_openFont and m_openFont are used if Symbian does not provide
93     // the Font Table API
94     COpenFont *m_openFont;
95     mutable MOpenFontTrueTypeExtension *m_trueTypeExtension;
96     mutable int m_cmapSize;
97 };
98 
99 class QFontEngineS60 : public QFontEngine
100 {
101 public:
102     QFontEngineS60(const QFontDef &fontDef, const QSymbianTypeFaceExtras *extras);
103     ~QFontEngineS60();
104 
105     QFixed emSquareSize() const;
106     bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const;
107     void recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const;
108 
109     void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs,
110                          QPainterPath *path, QTextItem::RenderFlags flags);
111 
112     QImage alphaMapForGlyph(glyph_t glyph);
113 
114     glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);
115     glyph_metrics_t boundingBox_const(glyph_t glyph) const; // Const correctnes quirk.
116     glyph_metrics_t boundingBox(glyph_t glyph);
117 
118     QFixed ascent() const;
119     QFixed descent() const;
120     QFixed leading() const;
121     qreal maxCharWidth() const;
minLeftBearing()122     qreal minLeftBearing() const { return 0; }
minRightBearing()123     qreal minRightBearing() const { return 0; }
124 
125     QByteArray getSfntTable(uint tag) const;
126     bool getSfntTableData(uint tag, uchar *buffer, uint *length) const;
127 
128     static qreal pixelsToPoints(qreal pixels, Qt::Orientation orientation = Qt::Horizontal);
129     static qreal pointsToPixels(qreal points, Qt::Orientation orientation = Qt::Horizontal);
130 
131     const char *name() const;
132 
133     bool canRender(const QChar *string, int len);
134 
135     Type type() const;
136 
137     void getCharacterData(glyph_t glyph, TOpenFontCharMetrics& metrics, const TUint8*& bitmap, TSize& bitmapSize) const;
138     void setFontScale(qreal scale);
139 
140 private:
141     friend class QFontPrivate;
142     friend class QSymbianVGFontGlyphCache;
143 
144     QFixed glyphAdvance(HB_Glyph glyph) const;
145     CFont *fontWithSize(qreal size) const;
146     static void releaseFont(CFont *&font);
147 
148     const QSymbianTypeFaceExtras *m_extras;
149     CFont* m_originalFont;
150     const qreal m_originalFontSizeInPixels;
151     CFont* m_scaledFont;
152     qreal m_scaledFontSizeInPixels;
153     CFont* m_activeFont;
154 };
155 
156 class QFontEngineMultiS60 : public QFontEngineMulti
157 {
158 public:
159     QFontEngineMultiS60(QFontEngine *first, int script, const QStringList &fallbackFamilies);
160     void loadEngine(int at);
161 
162     int m_script;
163     QStringList m_fallbackFamilies;
164 };
165 
166 QT_END_NAMESPACE
167 
168 #endif // QFONTENGINE_S60_P_H
169