summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qfontdatabase.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2011-03-22 09:57:59 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2011-04-15 10:56:26 (GMT)
commit1348f4f0853155182d2ea5836902794d1e43980c (patch)
treef51a9882326ff3d89876902a65af0493436d3146 /src/gui/text/qfontdatabase.cpp
parent3bff1637cd49617d334c1be63c20e008fac93be1 (diff)
downloadQt-1348f4f0853155182d2ea5836902794d1e43980c.zip
Qt-1348f4f0853155182d2ea5836902794d1e43980c.tar.gz
Qt-1348f4f0853155182d2ea5836902794d1e43980c.tar.bz2
Long live QRawFont!
The QGlyphs API was initially attempted with a bastardization of QFont which was meant to encapsulate a single, physical font instance (a QFontEngine) where a set of glyph indexes would make sense. This is not how QFont was intended to be used, and it caused several issues. At the same time, the requirement for loading a font from ttf/otf data and be able to access it and use it without polluting the rest of the process with the font arose. To support these two APIs we introduce QRawFont, which is an abstraction on top of a single physical font. Done-with: Jiang Jiang
Diffstat (limited to 'src/gui/text/qfontdatabase.cpp')
-rw-r--r--src/gui/text/qfontdatabase.cpp27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 94f21b8..36b0ea9 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -136,6 +136,21 @@ static int getFontWeight(const QString &weightString)
return (int) QFont::Normal;
}
+// convert 0 ~ 1000 integer to QFont::Weight
+QFont::Weight weightFromInteger(int weight)
+{
+ if (weight < 400)
+ return QFont::Light;
+ else if (weight < 600)
+ return QFont::Normal;
+ else if (weight < 700)
+ return QFont::DemiBold;
+ else if (weight < 800)
+ return QFont::Bold;
+ else
+ return QFont::Black;
+}
+
struct QtFontEncoding
{
signed int encoding : 16;
@@ -497,8 +512,6 @@ QtFontFoundry *QtFontFamily::foundry(const QString &f, bool create)
// ### copied to tools/makeqpf/qpf2.cpp
-#if (defined(Q_WS_QWS) && !defined(QT_NO_FREETYPE)) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN) || (defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA))
-
// see the Unicode subset bitfields in the MSDN docs
static int requiredUnicodeBits[QFontDatabase::WritingSystemsCount][2] = {
// Any,
@@ -576,7 +589,7 @@ static int requiredUnicodeBits[QFontDatabase::WritingSystemsCount][2] = {
#define JapaneseCsbBit 17
#define KoreanCsbBit 21
-static QList<QFontDatabase::WritingSystem> determineWritingSystemsFromTrueTypeBits(quint32 unicodeRange[4], quint32 codePageRange[2])
+QList<QFontDatabase::WritingSystem> qt_determine_writing_systems_from_truetype_bits(quint32 unicodeRange[4], quint32 codePageRange[2])
{
QList<QFontDatabase::WritingSystem> writingSystems;
bool hasScript = false;
@@ -623,7 +636,6 @@ static QList<QFontDatabase::WritingSystem> determineWritingSystemsFromTrueTypeBi
return writingSystems;
}
-#endif
#if defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE)
// class with virtual destructor, derived in qfontdatabase_s60.cpp
@@ -873,7 +885,7 @@ QStringList QFontDatabasePrivate::addTTFile(const QByteArray &file, const QByteA
os2->ulCodePageRange1, os2->ulCodePageRange2
};
- writingSystems = determineWritingSystemsFromTrueTypeBits(unicodeRange, codePageRange);
+ writingSystems = qt_determine_writing_systems_from_truetype_bits(unicodeRange, codePageRange);
//for (int i = 0; i < writingSystems.count(); ++i)
// qDebug() << QFontDatabase::writingSystemName(writingSystems.at(i));
}
@@ -936,6 +948,11 @@ static const int scriptForWritingSystem[] = {
QUnicodeTables::Nko // Nko
};
+int qt_script_for_writing_system(QFontDatabase::WritingSystem writingSystem)
+{
+ return scriptForWritingSystem[writingSystem];
+}
+
#if defined Q_WS_QWS || (defined(Q_WS_X11) && !defined(QT_NO_FONTCONFIG)) || defined(Q_WS_WIN)
static inline bool requiresOpenType(int writingSystem)