diff options
author | Alessandro Portale <aportale@trolltech.com> | 2009-06-04 21:26:40 (GMT) |
---|---|---|
committer | Alessandro Portale <aportale@trolltech.com> | 2009-06-04 21:26:40 (GMT) |
commit | 9196781f93fd60e869fededc83e32168868632cb (patch) | |
tree | 0287d8ad6232fcf3f0eb293fbd244d2316fdca49 /src/gui/text | |
parent | aa081e40af9f3dd7b7e9a47e062f7784e0dbb515 (diff) | |
download | Qt-9196781f93fd60e869fededc83e32168868632cb.zip Qt-9196781f93fd60e869fededc83e32168868632cb.tar.gz Qt-9196781f93fd60e869fededc83e32168868632cb.tar.bz2 |
Loading fonts from other /resource/fonts folders than the one on Z:
Order is 'soft to hard' W:, X: ... A:, Z: Duplicated font file
names are ignored. That should imitate the font loading behaviour
in the fbSrv.
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qfontdatabase_s60.cpp | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp index ab9291f..416c3d1 100644 --- a/src/gui/text/qfontdatabase_s60.cpp +++ b/src/gui/text/qfontdatabase_s60.cpp @@ -55,6 +55,39 @@ QT_BEGIN_NAMESPACE +QFileInfoList alternativeFilePaths(const QString &path, const QStringList &nameFilters, + QDir::Filters filters = QDir::NoFilter, QDir::SortFlags sort = QDir::NoSort, + bool uniqueFileNames = true) +{ + QFileInfoList result; + + // Prepare a 'soft to hard' drive list: W:, X: ... A:, Z: + QStringList driveStrings; + foreach (const QFileInfo &drive, QDir::drives()) + driveStrings.append(drive.absolutePath()); + driveStrings.sort(); + const QString zDriveString("Z:/"); + driveStrings.removeAll(zDriveString); + driveStrings.prepend(zDriveString); + + QStringList uniqueFileNameList; + for (int i = driveStrings.count() - 1; i >= 0; --i) { + const QDir dirOnDrive(driveStrings.at(i) + path); + const QFileInfoList entriesOnDrive = dirOnDrive.entryInfoList(nameFilters, filters, sort); + if (uniqueFileNames) { + foreach(const QFileInfo &entry, entriesOnDrive) { + if (!uniqueFileNameList.contains(entry.fileName())) { + uniqueFileNameList.append(entry.fileName()); + result.append(entry); + } + } + } else { + result.append(entriesOnDrive); + } + } + return result; +} + #if defined(QT_NO_FREETYPE) class QFontDatabaseS60StoreImplementation : public QFontDatabaseS60Store { @@ -77,10 +110,13 @@ QFontDatabaseS60StoreImplementation::QFontDatabaseS60StoreImplementation() m_store = CFontStore::NewL(m_heap); m_rasterizer = COpenFontRasterizer::NewL(TUid::Uid(0x101F7F5E)); m_store->InstallRasterizerL(m_rasterizer); - QDir dir(QDesktopServices::storageLocation(QDesktopServices::FontsLocation)); - dir.setNameFilters(QStringList() << QLatin1String("*.ttf") << QLatin1String("*.ccc")); - for (int i = 0; i < int(dir.count()); ++i) { - const QString fontFile = QDir::toNativeSeparators(dir.absoluteFilePath(dir[i])); + + QStringList filters; + filters.append(QString::fromLatin1("*.ttf")); + filters.append(QString::fromLatin1("*.ccc")); + const QFileInfoList fontFiles = alternativeFilePaths(QString::fromLatin1("resource\\Fonts"), filters); + foreach (const QFileInfo &fontFileInfo, fontFiles) { + const QString fontFile = QDir::toNativeSeparators(fontFileInfo.absoluteFilePath()); m_store->AddFileL(qt_QString2TPtrC(fontFile)); } } |