r21880 by jghali - moving getScFace() and writingSystemForFont() out of fontFamilyDelegate again: as we ended retrieving qt font database from ScribusQApp, moving them in fontFamilyDelegate was not necessary
scribus-commit
scribus-commit at lists.scribus.net
Tue Apr 11 07:14:06 UTC 2017
Author: jghali
Date: Tue Apr 11 07:14:06 2017
New Revision: 21880
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21880
Log:
moving getScFace() and writingSystemForFont() out of fontFamilyDelegate again: as we ended retrieving qt font database from ScribusQApp, moving them in fontFamilyDelegate was not necessary
Modified:
trunk/Scribus/scribus/ui/fontcombo.cpp
trunk/Scribus/scribus/ui/fontcombo.h
Modified: trunk/Scribus/scribus/ui/fontcombo.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21880&path=/trunk/Scribus/scribus/ui/fontcombo.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/fontcombo.cpp (original)
+++ trunk/Scribus/scribus/ui/fontcombo.cpp Tue Apr 11 07:14:06 2017
@@ -409,14 +409,48 @@
return writingSystemFromScript(script);
}
-fontFamilyDelegate::fontFamilyDelegate(QObject *parent)
- : QAbstractItemDelegate(parent)
- , writingSystem(QFontDatabase::Any)
-{
- pixmapCache.setCacheLimit(64*1024);
-}
-
-const ScFace& fontFamilyDelegate::getScFace(QString classname, QString text) const
+QFontDatabase::WritingSystem writingSystemForFont(const QFont &font, bool *hasLatin)
+{
+ QFontDatabase& fontDb = ScQApp->qtFontDatabase();
+ QList<QFontDatabase::WritingSystem> writingSystems = fontDb.writingSystems(font.family());
+
+ // this just confuses the algorithm below. Vietnamese is Latin with lots of special chars
+ writingSystems.removeOne(QFontDatabase::Vietnamese);
+ *hasLatin = writingSystems.removeOne(QFontDatabase::Latin);
+
+ if (writingSystems.isEmpty())
+ return QFontDatabase::Any;
+
+ QFontDatabase::WritingSystem system = writingSystemFromLocale();
+
+ if (writingSystems.contains(system))
+ return system;
+
+ if (system == QFontDatabase::TraditionalChinese && writingSystems.contains(QFontDatabase::SimplifiedChinese))
+ return QFontDatabase::SimplifiedChinese;
+
+ if (system == QFontDatabase::SimplifiedChinese && writingSystems.contains(QFontDatabase::TraditionalChinese))
+ return QFontDatabase::TraditionalChinese;
+
+ system = writingSystems.last();
+
+ if (!*hasLatin)
+ // we need to show something
+ return system;
+
+ if (writingSystems.count() == 1 && system > QFontDatabase::Cyrillic)
+ return system;
+
+ if (writingSystems.count() <= 2 && system > QFontDatabase::Armenian && system < QFontDatabase::Vietnamese)
+ return system;
+
+ if (writingSystems.count() <= 5 && system >= QFontDatabase::SimplifiedChinese && system <= QFontDatabase::Korean)
+ return system;
+
+ return QFontDatabase::Any;
+}
+
+const ScFace& getScFace(QString classname, QString text)
{
QFontDatabase& fontDb = ScQApp->qtFontDatabase();
PrefsManager* prefsManager = PrefsManager::instance();
@@ -448,6 +482,13 @@
}
}
+fontFamilyDelegate::fontFamilyDelegate(QObject *parent)
+ : QAbstractItemDelegate(parent)
+ , writingSystem(QFontDatabase::Any)
+{
+ pixmapCache.setCacheLimit(64*1024);
+}
+
void fontFamilyDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QString text(index.data(Qt::DisplayRole).toString());
@@ -577,44 +618,4 @@
return QSize(fontMetrics.width(text), fontMetrics.height() + 5);
}
-QFontDatabase::WritingSystem fontFamilyDelegate::writingSystemForFont(const QFont &font, bool *hasLatin) const
-{
- QFontDatabase& fontDb = ScQApp->qtFontDatabase();
- QList<QFontDatabase::WritingSystem> writingSystems = fontDb.writingSystems(font.family());
-
- // this just confuses the algorithm below. Vietnamese is Latin with lots of special chars
- writingSystems.removeOne(QFontDatabase::Vietnamese);
- *hasLatin = writingSystems.removeOne(QFontDatabase::Latin);
-
- if (writingSystems.isEmpty())
- return QFontDatabase::Any;
-
- QFontDatabase::WritingSystem system = writingSystemFromLocale();
-
- if (writingSystems.contains(system))
- return system;
-
- if (system == QFontDatabase::TraditionalChinese && writingSystems.contains(QFontDatabase::SimplifiedChinese))
- return QFontDatabase::SimplifiedChinese;
-
- if (system == QFontDatabase::SimplifiedChinese && writingSystems.contains(QFontDatabase::TraditionalChinese))
- return QFontDatabase::TraditionalChinese;
-
- system = writingSystems.last();
-
- if (!*hasLatin)
- // we need to show something
- return system;
-
- if (writingSystems.count() == 1 && system > QFontDatabase::Cyrillic)
- return system;
-
- if (writingSystems.count() <= 2 && system > QFontDatabase::Armenian && system < QFontDatabase::Vietnamese)
- return system;
-
- if (writingSystems.count() <= 5 && system >= QFontDatabase::SimplifiedChinese && system <= QFontDatabase::Korean)
- return system;
-
- return QFontDatabase::Any;
-}
-
+
Modified: trunk/Scribus/scribus/ui/fontcombo.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21880&path=/trunk/Scribus/scribus/ui/fontcombo.h
==============================================================================
--- trunk/Scribus/scribus/ui/fontcombo.h (original)
+++ trunk/Scribus/scribus/ui/fontcombo.h Tue Apr 11 07:14:06 2017
@@ -119,12 +119,9 @@
const QModelIndex &index) const Q_DECL_OVERRIDE;
QFontDatabase::WritingSystem writingSystem;
+
protected:
- QFont m_font;
-
- static QPixmapCache pixmapCache;
-
- const ScFace& getScFace(QString classname, QString text) const;
- QFontDatabase::WritingSystem writingSystemForFont(const QFont &font, bool *hasLatin) const;
+ QFont m_font;
+ static QPixmapCache pixmapCache;
};
#endif
More information about the scribus-commit
mailing list