diff options
author | Mitch Curtis <mitch.curtis@digia.com> | 2014-03-31 17:45:37 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-31 17:45:37 +0200 |
commit | bd822bedfea5126b12c32523a68c3a1ac7a8931d (patch) | |
tree | 0fafd5ac037e3b62ad45e8808989ec89155618b4 /src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm | |
parent | 84c10500b1730e8d947732728d190fde612fc840 (diff) | |
parent | 3b5c0bc0780f1749fed7c07bd8b691400a0282b7 (diff) |
Merge "Merge remote-tracking branch 'origin/stable' into dev" into refs/staging/dev
Diffstat (limited to 'src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm')
-rw-r--r-- | src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm index 3c30df6efb..0460f11139 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm @@ -50,6 +50,22 @@ QT_BEGIN_NAMESPACE static float SYNTHETIC_ITALIC_SKEW = tanf(14 * acosf(0) / 90); +static bool ct_getSfntTable(void *user_data, uint tag, uchar *buffer, uint *length) +{ + CTFontRef ctfont = *(CTFontRef *)user_data; + + QCFType<CFDataRef> table = CTFontCopyTable(ctfont, tag, 0); + if (!table) + return false; + + CFIndex tableLength = CFDataGetLength(table); + if (buffer && int(*length) >= tableLength) + CFDataGetBytes(table, CFRangeMake(0, tableLength), buffer); + *length = tableLength; + Q_ASSERT(int(*length) > 0); + return true; +} + static void loadAdvancesForGlyphs(CTFontRef ctfont, QVarLengthArray<CGGlyph> &cgGlyphs, QGlyphLayout *glyphs, int len, @@ -191,7 +207,10 @@ void QCoreTextFontEngine::init() cache_cost = (CTFontGetAscent(ctfont) + CTFontGetDescent(ctfont)) * avgCharWidth.toInt() * 2000; - setUserData(QVariant::fromValue((void *)cgFont)); + // HACK hb_coretext requires both CTFont and CGFont but user_data is only void* + Q_ASSERT((void *)(&ctfont + 1) == (void *)&cgFont); + faceData.user_data = &ctfont; + faceData.get_font_table = ct_getSfntTable; } glyph_t QCoreTextFontEngine::glyphIndex(uint ucs4) const @@ -683,15 +702,7 @@ bool QCoreTextFontEngine::canRender(const QChar *string, int len) const bool QCoreTextFontEngine::getSfntTableData(uint tag, uchar *buffer, uint *length) const { - QCFType<CFDataRef> table = CTFontCopyTable(ctfont, tag, 0); - if (!table) - return false; - CFIndex tableLength = CFDataGetLength(table); - if (buffer && int(*length) >= tableLength) - CFDataGetBytes(table, CFRangeMake(0, tableLength), buffer); - *length = tableLength; - Q_ASSERT(int(*length) > 0); - return true; + return ct_getSfntTable((void *)&ctfont, tag, buffer, length); } void QCoreTextFontEngine::getUnscaledGlyph(glyph_t, QPainterPath *, glyph_metrics_t *) |