Qt 4.8
qfontengine_coretext_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
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 Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/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 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QFONTENGINE_CORETEXT_P_H
43 #define QFONTENGINE_CORETEXT_P_H
44 
45 #include <private/qfontengine_p.h>
46 
47 #if defined(Q_OS_IOS)
48 #include <CoreText/CoreText.h>
49 #include <CoreGraphics/CoreGraphics.h>
50 #include <private/qcore_mac_p.h>
51 #endif
52 
53 #if !defined(Q_WS_MAC) || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
54 
56 
58 
59 class QRawFontPrivate;
62 {
63 public:
64  QCoreTextFontEngine(CTFontRef font, const QFontDef &def);
65  QCoreTextFontEngine(CGFontRef font, const QFontDef &def);
67 
68  virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const;
69  virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const;
70 
71  virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);
72  virtual glyph_metrics_t boundingBox(glyph_t glyph);
73 
74  virtual QFixed ascent() const;
75  virtual QFixed descent() const;
76  virtual QFixed leading() const;
77  virtual QFixed xHeight() const;
78  virtual qreal maxCharWidth() const;
79  virtual QFixed averageCharWidth() const;
80 
81  virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int numGlyphs,
82  QPainterPath *path, QTextItem::RenderFlags);
83 
84  virtual const char *name() const { return "QCoreTextFontEngine"; }
85 
86  virtual bool canRender(const QChar *string, int len);
87 
88  virtual int synthesized() const { return synthesisFlags; }
89  virtual bool supportsSubPixelPositions() const { return true; }
90 
91  virtual Type type() const { return QFontEngine::Mac; }
92 
93  void draw(CGContextRef ctx, qreal x, qreal y, const QTextItemInt &ti, int paintDeviceHeight);
94 
95  virtual FaceId faceId() const;
96  virtual bool getSfntTableData(uint /*tag*/, uchar * /*buffer*/, uint * /*length*/) const;
97  virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics);
98  virtual QImage alphaMapForGlyph(glyph_t, QFixed subPixelPosition);
99  virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, int margin, const QTransform &t);
100  virtual qreal minRightBearing() const;
101  virtual qreal minLeftBearing() const;
102  virtual QFixed emSquareSize() const;
103 
104  virtual QFontEngine *cloneWithSize(qreal pixelSize) const;
105 
106 private:
107  friend class QRawFontPrivate;
108 
109  void init();
110  QImage imageForGlyph(glyph_t glyph, QFixed subPixelPosition, int margin, bool colorful);
111  CTFontRef ctfont;
112  CGFontRef cgFont;
114  CGAffineTransform transform;
117 };
118 
120 {
121 public:
123  QCoreTextFontEngineMulti(CTFontRef ctFontRef, const QFontDef &fontDef, bool kerning);
125 
126  virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs,
127  QTextEngine::ShaperFlags flags) const;
128  bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs,
129  QTextEngine::ShaperFlags flags,
130  unsigned short *logClusters, const HB_CharAttributes *charAttributes,
131  QScriptItem *si) const;
132 
133  virtual const char *name() const { return "CoreText"; }
134  inline CTFontRef macFontID() const { return ctfont; }
135 
136 protected:
137  virtual void loadEngine(int at);
138 
139 private:
140  void init(bool kerning);
141  inline const QCoreTextFontEngine *engineAt(int i) const
142  { return static_cast<const QCoreTextFontEngine *>(engines.at(i)); }
143 
144  uint fontIndexForFont(CTFontRef font) const;
145  CTFontRef ctfont;
147  CGAffineTransform transform;
148  friend class QFontDialogPrivate;
150 };
151 
152 CGAffineTransform qt_transform_from_fontdef(const QFontDef &fontDef);
153 
155 
157 
158 #endif// !defined(Q_WS_MAC) || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
159 
160 #endif // QFONTENGINE_CORETEXT_P_H
virtual QFixed ascent() const
virtual qreal minLeftBearing() const
virtual FaceId faceId() const
QImage imageForGlyph(glyph_t glyph, QFixed subPixelPosition, int margin, bool colorful)
double qreal
Definition: qglobal.h:1193
const QCoreTextFontEngine * engineAt(int i) const
virtual QFontEngine * cloneWithSize(qreal pixelSize) const
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
friend class QCoreTextFontEngineMulti
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
virtual bool getSfntTableData(uint, uchar *, uint *) const
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
QCoreTextFontEngine(CTFontRef font, const QFontDef &def)
#define at(className, varName)
virtual qreal minRightBearing() const
virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, int margin, const QTransform &t)
virtual QFixed averageCharWidth() const
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
virtual qreal maxCharWidth() const
unsigned char uchar
Definition: qglobal.h:994
virtual QFixed xHeight() const
QCFType< CFMutableDictionaryRef > attributeDict
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int numGlyphs, QPainterPath *path, QTextItem::RenderFlags)
static float pixelSize(const QFontDef &request, int dpi)
Definition: qfont_win.cpp:80
static QList< QAxEngineDescriptor > engines
Definition: qaxscript.cpp:69
static const QCssKnownValue positions[NumKnownPositionModes - 1]
Definition: qcssparser.cpp:329
virtual bool supportsSubPixelPositions() const
static QFontEngine * loadEngine(int script, const QFontDef &request, QtFontFamily *family, QtFontFoundry *foundry, QtFontStyle *style, QtFontSize *size)
virtual bool canRender(const QChar *string, int len)
virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const
virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics)
Internal QTextItem.
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
unsigned int uint
Definition: qglobal.h:996
virtual const char * name() const
virtual Type type() const
CGAffineTransform transform
virtual QImage alphaMapForGlyph(glyph_t, QFixed subPixelPosition)
virtual QFixed leading() const
#define ctx
Definition: qgl.cpp:6094
void draw(CGContextRef ctx, qreal x, qreal y, const QTextItemInt &ti, int paintDeviceHeight)
virtual QFixed descent() const
CGAffineTransform qt_transform_from_fontdef(const QFontDef &fontDef)
static QFixed kerning(int left, int right, const QFontEngine::KernPair *pairs, int numPairs)
virtual QFixed emSquareSize() const
virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const
struct CGContext * CGContextRef
virtual int synthesized() const
QFontDef fontDef
virtual const char * name() const
#define QT_END_HEADER
Definition: qglobal.h:137
virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs)
unsigned int glyph_t
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65