From 95a0c92a9788af8ad00bd9d52bccc93d2e9c5b83 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Mon, 8 Feb 2010 17:50:58 +1000 Subject: For local fonts, we can just addApplicationFont() rather than loading data. --- src/declarative/util/qmlfontloader.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/declarative/util/qmlfontloader.cpp b/src/declarative/util/qmlfontloader.cpp index 42b34b5..b56043b 100644 --- a/src/declarative/util/qmlfontloader.cpp +++ b/src/declarative/util/qmlfontloader.cpp @@ -126,10 +126,16 @@ void QmlFontLoader::setSource(const QUrl &url) #ifndef QT_NO_LOCALFILE_OPTIMIZED_QML QString lf = toLocalFileOrQrc(d->url); if (!lf.isEmpty()) { - QFile file(lf); - file.open(QIODevice::ReadOnly); - QByteArray ba = file.readAll(); - d->addFontToDatabase(ba); + int id = QFontDatabase::addApplicationFont(lf); + if (id != -1) { + d->name = QFontDatabase::applicationFontFamilies(id).at(0); + emit nameChanged(); + d->status = QmlFontLoader::Ready; + } else { + d->status = QmlFontLoader::Error; + qWarning() << "Cannot load font:" << url; + } + emit statusChanged(); } else #endif { -- cgit v0.12