summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-02-08 07:50:58 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-02-08 07:50:58 (GMT)
commit95a0c92a9788af8ad00bd9d52bccc93d2e9c5b83 (patch)
tree6de51927294ac56951e7887fe270150b65c9aeb2
parente5c58224e1ebbfc6cdac3e2f611d71c6654b3642 (diff)
downloadQt-95a0c92a9788af8ad00bd9d52bccc93d2e9c5b83.zip
Qt-95a0c92a9788af8ad00bd9d52bccc93d2e9c5b83.tar.gz
Qt-95a0c92a9788af8ad00bd9d52bccc93d2e9c5b83.tar.bz2
For local fonts, we can just addApplicationFont() rather than loading data.
-rw-r--r--src/declarative/util/qmlfontloader.cpp14
1 files 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
{