Add QRawFont from data support to Mac font db

Change-Id: I02f1c4b35b9ed585e72aa4bad9b75d3c098f8e62
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
This commit is contained in:
Jiang Jiang 2011-11-30 16:43:45 +01:00 committed by Qt by Nokia
parent f8725f2c8d
commit c5383f2e49
2 changed files with 24 additions and 0 deletions

View File

@ -282,6 +282,29 @@ QFontEngine *QCoreTextFontDatabase::fontEngine(const QFontDef &f, QUnicodeTables
return NULL;
}
QFontEngine *QCoreTextFontDatabase::fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference)
{
Q_UNUSED(hintingPreference);
QCFType<CGDataProviderRef> dataProvider = CGDataProviderCreateWithData(NULL,
fontData.constData(), fontData.size(), NULL);
CGFontRef cgFont = CGFontCreateWithDataProvider(dataProvider);
QFontEngine *fontEngine = NULL;
if (cgFont == NULL) {
qWarning("QRawFont::platformLoadFromData: CGFontCreateWithDataProvider failed");
} else {
QFontDef def;
def.pixelSize = pixelSize;
def.pointSize = pixelSize * 72.0 / qt_defaultDpi();
fontEngine = new QCoreTextFontEngine(cgFont, def);
CFRelease(cgFont);
}
return fontEngine;
}
QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const
{
Q_UNUSED(family);

View File

@ -51,6 +51,7 @@ public:
~QCoreTextFontDatabase();
void populateFontDatabase();
QFontEngine *fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle);
QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference);
QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const;
QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName);
void releaseHandle(void *handle);