1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtGui module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #ifndef QFONTENGINE_CORETEXT_P_H
43 #define QFONTENGINE_CORETEXT_P_H
45 #include <private/qfontengine_p.h>
47 #if !defined(Q_WS_MAC) || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
53 class QRawFontPrivate;
54 class QCoreTextFontEngineMulti;
55 class QCoreTextFontEngine : public QFontEngine
58 QCoreTextFontEngine(CTFontRef font, const QFontDef &def);
59 QCoreTextFontEngine(CGFontRef font, const QFontDef &def);
60 ~QCoreTextFontEngine();
62 virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const;
63 virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const;
65 virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);
66 virtual glyph_metrics_t boundingBox(glyph_t glyph);
68 virtual QFixed ascent() const;
69 virtual QFixed descent() const;
70 virtual QFixed leading() const;
71 virtual QFixed xHeight() const;
72 virtual qreal maxCharWidth() const;
73 virtual QFixed averageCharWidth() const;
75 virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int numGlyphs,
76 QPainterPath *path, QTextItem::RenderFlags);
78 virtual const char *name() const { return "QCoreTextFontEngine"; }
80 virtual bool canRender(const QChar *string, int len);
82 virtual int synthesized() const { return synthesisFlags; }
83 virtual bool supportsSubPixelPositions() const { return true; }
85 virtual Type type() const { return QFontEngine::Mac; }
87 void draw(CGContextRef ctx, qreal x, qreal y, const QTextItemInt &ti, int paintDeviceHeight);
89 virtual FaceId faceId() const;
90 virtual bool getSfntTableData(uint /*tag*/, uchar * /*buffer*/, uint * /*length*/) const;
91 virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics);
92 virtual QImage alphaMapForGlyph(glyph_t, QFixed subPixelPosition);
93 virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, int margin, const QTransform &t);
94 virtual qreal minRightBearing() const;
95 virtual qreal minLeftBearing() const;
96 virtual QFixed emSquareSize() const;
98 virtual QFontEngine *cloneWithSize(qreal pixelSize) const;
101 friend class QRawFontPrivate;
104 QImage imageForGlyph(glyph_t glyph, QFixed subPixelPosition, int margin, bool colorful);
108 CGAffineTransform transform;
110 friend class QCoreTextFontEngineMulti;
113 class QCoreTextFontEngineMulti : public QFontEngineMulti
116 QCoreTextFontEngineMulti(const QCFString &name, const QFontDef &fontDef, bool kerning);
117 QCoreTextFontEngineMulti(CTFontRef ctFontRef, const QFontDef &fontDef, bool kerning);
118 ~QCoreTextFontEngineMulti();
120 virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs,
121 QTextEngine::ShaperFlags flags) const;
122 bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs,
123 QTextEngine::ShaperFlags flags,
124 unsigned short *logClusters, const HB_CharAttributes *charAttributes,
125 QScriptItem *si) const;
127 virtual const char *name() const { return "CoreText"; }
128 inline CTFontRef macFontID() const { return ctfont; }
131 virtual void loadEngine(int at);
134 void init(bool kerning);
135 inline const QCoreTextFontEngine *engineAt(int i) const
136 { return static_cast<const QCoreTextFontEngine *>(engines.at(i)); }
138 uint fontIndexForFont(CTFontRef font) const;
140 mutable QCFType<CFMutableDictionaryRef> attributeDict;
141 CGAffineTransform transform;
142 friend class QFontDialogPrivate;
145 CGAffineTransform qt_transform_from_fontdef(const QFontDef &fontDef);
151 #endif// !defined(Q_WS_MAC) || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
153 #endif // QFONTENGINE_CORETEXT_P_H