| 1 |
/**************************************************************************** |
| 2 |
** |
| 3 |
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). |
| 4 |
** All rights reserved. |
| 5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
| 6 |
** |
| 7 |
** This file is part of the QtGui module of the Qt Toolkit. |
| 8 |
** |
| 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. |
| 17 |
** |
| 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. |
| 21 |
** |
| 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. |
| 29 |
** |
| 30 |
** Other Usage |
| 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. |
| 33 |
** |
| 34 |
** |
| 35 |
** |
| 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 |
#ifdef QT_NO_CORESERVICES |
| 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 |
|
| 55 |
QT_BEGIN_HEADER |
| 56 |
|
| 57 |
QT_BEGIN_NAMESPACE |
| 58 |
|
| 59 |
class QRawFontPrivate; |
| 60 |
class QCoreTextFontEngineMulti; |
| 61 |
class QCoreTextFontEngine : public QFontEngine |
| 62 |
{ |
| 63 |
public: |
| 64 |
QCoreTextFontEngine(CTFontRef font, const QFontDef &def); |
| 65 |
QCoreTextFontEngine(CGFontRef font, const QFontDef &def); |
| 66 |
~QCoreTextFontEngine(); |
| 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; |
| 113 |
int synthesisFlags; |
| 114 |
CGAffineTransform transform; |
| 115 |
QFixed avgCharWidth; |
| 116 |
friend class QCoreTextFontEngineMulti; |
| 117 |
}; |
| 118 |
|
| 119 |
class QCoreTextFontEngineMulti : public QFontEngineMulti |
| 120 |
{ |
| 121 |
public: |
| 122 |
QCoreTextFontEngineMulti(const QCFString &name, const QFontDef &fontDef, bool kerning); |
| 123 |
QCoreTextFontEngineMulti(CTFontRef ctFontRef, const QFontDef &fontDef, bool kerning); |
| 124 |
~QCoreTextFontEngineMulti(); |
| 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; |
| 146 |
mutable QCFType<CFMutableDictionaryRef> attributeDict; |
| 147 |
CGAffineTransform transform; |
| 148 |
friend class QFontDialogPrivate; |
| 149 |
bool transformAdvances; |
| 150 |
}; |
| 151 |
|
| 152 |
CGAffineTransform qt_transform_from_fontdef(const QFontDef &fontDef); |
| 153 |
|
| 154 |
QT_END_NAMESPACE |
| 155 |
|
| 156 |
QT_END_HEADER |
| 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 |