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>
This commit is contained in:
parent
9087d4ed7b
commit
89ab267105
@ -305,12 +305,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);
|
||||
|
||||
@ -474,8 +482,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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user