summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/fontdatabases/mac
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2013-10-28 14:41:43 +0100
committerOswald Buddenhagen <oswald.buddenhagen@digia.com>2013-11-14 14:39:32 +0100
commitf2c5f33b6bda570f64dcfe07241cf20d54f8954b (patch)
tree9b0fd291113e8c1e3bcbdedfebda231c11fb0494 /src/platformsupport/fontdatabases/mac
parenta23ff58d716f62b02ec825a3ea3c6b07616ee3f0 (diff)
Keep web fontdata alive as long as CG uses it
With OS X 10.9 font decoding appears to happen lazily, this means we have to ensure the data we provide CG is kept alive until it dereferences it itself. Task-number: QTBUG-34332 Change-Id: I8fc38fafba746b062c4ad16314b0a410fd0b668d Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com> (cherry picked from qtbase/89ab2671051671ecf440ba480caf0b6b6768b1a9) Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/platformsupport/fontdatabases/mac')
-rw-r--r--src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
index 1e15a9e62c..864cf49aec 100644
--- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
+++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
@@ -296,12 +296,20 @@ QFontEngine *QCoreTextFontDatabase::fontEngine(const QFontDef &f, QChar::Script
return NULL;
}
+static void releaseFontData(void* info, const void* data, size_t size)
+{
+ Q_UNUSED(data);
+ Q_UNUSED(size);
+ delete (QByteArray*)info;
+}
+
QFontEngine *QCoreTextFontDatabase::fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference)
{
Q_UNUSED(hintingPreference);
- QCFType<CGDataProviderRef> dataProvider = CGDataProviderCreateWithData(NULL,
- fontData.constData(), fontData.size(), NULL);
+ QByteArray* fontDataCopy = new QByteArray(fontData);
+ QCFType<CGDataProviderRef> dataProvider = CGDataProviderCreateWithData(fontDataCopy,
+ fontDataCopy->constData(), fontDataCopy->size(), releaseFontData);
CGFontRef cgFont = CGFontCreateWithDataProvider(dataProvider);
@@ -465,8 +473,9 @@ QStringList QCoreTextFontDatabase::addApplicationFont(const QByteArray &fontData
CTFontRef font = NULL;
if (!fontData.isEmpty()) {
- QCFType<CGDataProviderRef> dataProvider = CGDataProviderCreateWithData(NULL,
- fontData.constData(), fontData.size(), NULL);
+ QByteArray* fontDataCopy = new QByteArray(fontData);
+ QCFType<CGDataProviderRef> dataProvider = CGDataProviderCreateWithData(fontDataCopy,
+ fontDataCopy->constData(), fontDataCopy->size(), releaseFontData);
CGFontRef cgFont = CGFontCreateWithDataProvider(dataProvider);
if (cgFont) {
CFErrorRef error;