Qt 4.8
qfontengine_mac_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_MAC_P_H
43 #define QFONTENGINE_MAC_P_H
44 
45 #include <private/qfontengine_p.h>
46 
47 #ifndef QT_MAC_USE_COCOA
48 
50 
53 {
54  friend class QFontEngineMacMulti;
55 public:
56  QFontEngineMac(ATSUStyle baseStyle, ATSUFontID fontID, const QFontDef &def, QFontEngineMacMulti *multiEngine = 0);
57  virtual ~QFontEngineMac();
58 
59  virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *numGlyphs, QTextEngine::ShaperFlags flags) const;
60  virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const;
61 
62  virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);
63  virtual glyph_metrics_t boundingBox(glyph_t glyph);
64 
65  virtual QFixed ascent() const;
66  virtual QFixed descent() const;
67  virtual QFixed leading() const;
68  virtual QFixed xHeight() const;
69  virtual qreal maxCharWidth() const;
70  virtual QFixed averageCharWidth() const;
71 
72  virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int numGlyphs,
73  QPainterPath *path, QTextItem::RenderFlags);
74 
75  virtual const char *name() const { return "QFontEngineMac"; }
76 
77  virtual bool canRender(const QChar *string, int len);
78 
79  virtual int synthesized() const { return synthesisFlags; }
80 
81  virtual Type type() const { return QFontEngine::Mac; }
82 
83  void draw(CGContextRef ctx, qreal x, qreal y, const QTextItemInt &ti, int paintDeviceHeight);
84 
85  virtual FaceId faceId() const;
86  virtual QByteArray getSfntTable(uint tag) const;
87  virtual Properties properties() const;
88  virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics);
90  virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, int margin, const QTransform &t);
91 
92 private:
93  QImage imageForGlyph(glyph_t glyph, int margin, bool colorful);
94 
95  ATSUFontID fontID;
97  ATSUStyle style;
101  mutable const unsigned char *cmap;
102  mutable bool symbolCMap;
104  CGAffineTransform transform;
111 };
112 
114 {
115  friend class QFontEngineMac;
116 public:
117  // internal
118  struct ShaperItem
119  {
120  inline ShaperItem() : string(0), from(0), length(0),
121  log_clusters(0), charAttributes(0) {}
122 
123  const QChar *string;
124  int from;
125  int length;
127  unsigned short *log_clusters;
128  const HB_CharAttributes *charAttributes;
129  QTextEngine::ShaperFlags flags;
130  };
131 
132  QFontEngineMacMulti(const ATSFontFamilyRef &atsFamily, const ATSFontRef &atsFontRef, const QFontDef &fontDef, bool kerning);
133  virtual ~QFontEngineMacMulti();
134 
135  virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const;
136  bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags,
137  unsigned short *logClusters, const HB_CharAttributes *charAttributes, QScriptItem *) const;
138 
139  virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const;
140  virtual void doKerning(QGlyphLayout *, QTextEngine::ShaperFlags) const;
141 
142  virtual const char *name() const { return "ATSUI"; }
143 
144  virtual bool canRender(const QChar *string, int len);
145 
146  inline ATSUFontID macFontID() const { return fontID; }
147 
148 protected:
149  virtual void loadEngine(int at);
150 
151 private:
152  inline const QFontEngineMac *engineAt(int i) const
153  { return static_cast<const QFontEngineMac *>(engines.at(i)); }
154 
155  bool stringToCMapInternal(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags, ShaperItem *item) const;
156 
157  int fontIndexForFontID(ATSUFontID id) const;
158 
159  ATSUFontID fontID;
161 
162  mutable ATSUTextLayout textLayout;
163  mutable ATSUStyle style;
164  CGAffineTransform transform;
165 };
166 
168 
169 #endif
170 
171 #endif // QFONTENGINE_MAC_P_H
virtual FaceId faceId() const
virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int numGlyphs, QPainterPath *path, QTextItem::RenderFlags)
QCFType< CGFontRef > cgFont
double qreal
Definition: qglobal.h:1193
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
virtual QFixed ascent() const
virtual Type type() const
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
virtual void doKerning(QGlyphLayout *, QTextEngine::ShaperFlags) const
#define at(className, varName)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
ATSUTextLayout textLayout
QGlyphLayout kashidaGlyph
ATSUFontID macFontID() const
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
void draw(CGContextRef ctx, qreal x, qreal y, const QTextItemInt &ti, int paintDeviceHeight)
virtual ~QFontEngineMac()
virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QImage imageForGlyph(glyph_t glyph, int margin, bool colorful)
Helper function for alphaMapForGlyph and alphaRGBMapForGlyph.
static QList< QAxEngineDescriptor > engines
Definition: qaxscript.cpp:69
static const QCssKnownValue positions[NumKnownPositionModes - 1]
Definition: qcssparser.cpp:329
virtual int synthesized() const
QFontEngineMacMulti * multiEngine
static QFontEngine * loadEngine(int script, const QFontDef &request, QtFontFamily *family, QtFontFoundry *foundry, QtFontStyle *style, QtFontSize *size)
virtual QFixed descent() const
Internal QTextItem.
virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *numGlyphs, QTextEngine::ShaperFlags flags) const
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 void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics)
virtual bool canRender(const QChar *string, int len)
const HB_CharAttributes * charAttributes
virtual const char * name() const
QByteArray cmapTable
#define ctx
Definition: qgl.cpp:6094
friend class QFontEngineMacMulti
virtual QImage alphaMapForGlyph(glyph_t)
const unsigned char * cmap
const QFontEngineMac * engineAt(int i) const
virtual Properties properties() const
CGAffineTransform transform
virtual QFixed leading() const
QFontEngineMac(ATSUStyle baseStyle, ATSUFontID fontID, const QFontDef &def, QFontEngineMacMulti *multiEngine=0)
static QFixed kerning(int left, int right, const QFontEngine::KernPair *pairs, int numPairs)
virtual QFixed averageCharWidth() const
virtual QFixed xHeight() const
QTextEngine::ShaperFlags flags
struct CGContext * CGContextRef
virtual const char * name() const
QFontDef fontDef
virtual QByteArray getSfntTable(uint tag) const
virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const
unsigned int glyph_t
virtual qreal maxCharWidth() const
virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, int margin, const QTransform &t)
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
CGAffineTransform transform