Qt 4.8
Classes | Macros | Functions | Variables
qfontdatabase.cpp File Reference
#include <qdir.h>
#include "qfontdatabase.h"
#include "qdebug.h"
#include "qalgorithms.h"
#include "qapplication.h"
#include "qvarlengtharray.h"
#include "qthread.h"
#include "qmutex.h"
#include "private/qunicodetables_p.h"
#include "qfontengine_p.h"
#include <locale.h>
#include <stdlib.h>
#include <limits.h>
#include <ft2build.h>
#include <FT_TRUETYPE_TABLES_H>
#include <dwrite.h>
#include "qfontdatabase_x11.cpp"

Go to the source code of this file.

Classes

class  QFontDatabasePrivate
 
struct  QFontDatabasePrivate::ApplicationFont
 
struct  QtFontDesc
 
struct  QtFontEncoding
 
struct  QtFontFamily
 
struct  QtFontFoundry
 
struct  QtFontSize
 
struct  QtFontStyle
 
struct  QtFontStyle::Key
 

Macros

#define FD_DEBUG   if (false) qDebug
 
#define FM_DEBUG   if (false) qDebug
 
#define JapaneseCsbBit   17
 
#define KoreanCsbBit   21
 
#define SimplifiedChineseCsbBit   18
 
#define SMOOTH_SCALABLE   0xffff
 
#define TraditionalChineseCsbBit   20
 

Functions

static QtFontStylebestStyle (QtFontFoundry *foundry, const QtFontStyle::Key &styleKey, const QString &styleName=QString())
 
static QStringList familyList (const QFontDef &req)
 
static QtFontEncodingfindEncoding (int script, int styleStrategy, QtFontSize *size, int force_encoding_id)
 
static void getEngineData (const QFontPrivate *d, const QFontCache::Key &key)
 
static int getFontWeight (const QString &weightString)
 
static void parseFontName (const QString &name, QString &foundry, QString &family)
 This makes sense of the font family name: More...
 
QList< QFontDatabase::WritingSystemqt_determine_writing_systems_from_truetype_bits (quint32 unicodeRange[4], quint32 codePageRange[2])
 
Q_GUI_EXPORT QByteArray qt_fontdata_from_index (int index)
 
QMutexqt_fontdatabase_mutex ()
 
static void qt_mac_get_fixed_pitch (QtFontFamily *f)
 
int qt_script_for_writing_system (QFontDatabase::WritingSystem writingSystem)
 
Q_AUTOTEST_EXPORT void qt_setQtEnableTestFont (bool value)
 
static bool requiresOpenType (int writingSystem)
 
static bool scriptRequiresOpenType (int script)
 
static QString styleStringHelper (int weight, QFont::Style style)
 
QFont::Weight weightFromInteger (int weight)
 

Variables

bool qt_enable_test_font = false
 
static int requiredUnicodeBits [QFontDatabase::WritingSystemsCount][2]
 
static const int scriptForWritingSystem []
 

Macro Definition Documentation

◆ FD_DEBUG

#define FD_DEBUG   if (false) qDebug

Definition at line 74 of file qfontdatabase.cpp.

Referenced by initializeDb(), and load().

◆ FM_DEBUG

#define FM_DEBUG   if (false) qDebug

◆ JapaneseCsbBit

#define JapaneseCsbBit   17

Definition at line 584 of file qfontdatabase.cpp.

Referenced by qt_determine_writing_systems_from_truetype_bits().

◆ KoreanCsbBit

#define KoreanCsbBit   21

Definition at line 585 of file qfontdatabase.cpp.

Referenced by qt_determine_writing_systems_from_truetype_bits().

◆ SimplifiedChineseCsbBit

#define SimplifiedChineseCsbBit   18

Definition at line 582 of file qfontdatabase.cpp.

Referenced by qt_determine_writing_systems_from_truetype_bits().

◆ SMOOTH_SCALABLE

#define SMOOTH_SCALABLE   0xffff

◆ TraditionalChineseCsbBit

#define TraditionalChineseCsbBit   20

Definition at line 583 of file qfontdatabase.cpp.

Referenced by qt_determine_writing_systems_from_truetype_bits().

Function Documentation

◆ bestStyle()

static QtFontStyle* bestStyle ( QtFontFoundry foundry,
const QtFontStyle::Key styleKey,
const QString styleName = QString() 
)
static

Definition at line 1125 of file qfontdatabase.cpp.

Referenced by findEncoding(), and QFontDatabase::font().

1127 {
1128  int best = 0;
1129  int dist = 0xffff;
1130 
1131  for ( int i = 0; i < foundry->count; i++ ) {
1132  QtFontStyle *style = foundry->styles[i];
1133 
1134  if (!styleName.isEmpty() && styleName == style->styleName) {
1135  dist = 0;
1136  best = i;
1137  break;
1138  }
1139 
1140  int d = qAbs( styleKey.weight - style->key.weight );
1141 
1142  if ( styleKey.stretch != 0 && style->key.stretch != 0 ) {
1143  d += qAbs( styleKey.stretch - style->key.stretch );
1144  }
1145 
1146  if (styleKey.style != style->key.style) {
1147  if (styleKey.style != QFont::StyleNormal && style->key.style != QFont::StyleNormal)
1148  // one is italic, the other oblique
1149  d += 0x0001;
1150  else
1151  d += 0x1000;
1152  }
1153 
1154  if ( d < dist ) {
1155  best = i;
1156  dist = d;
1157  }
1158  }
1159 
1160  FM_DEBUG( " best style has distance 0x%x", dist );
1161  return foundry->styles[best];
1162 }
double d
Definition: qnumeric_p.h:62
QtFontStyle ** styles
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define FM_DEBUG
QString styleName

◆ familyList()

static QStringList familyList ( const QFontDef req)
static

Definition at line 1065 of file qfontdatabase.cpp.

Referenced by QFontDialogPrivate::_q_familyHighlighted(), QFontDialogPrivate::_q_updateSample(), QFontDatabase::findFont(), getFcPattern(), QFontDialogPrivate::init(), loadFromDatabase(), loadWin(), QFontDatabase::loadXlfd(), QFontDialogPrivate::updateFamilies(), QFontDialogPrivate::updateSizes(), and QFontDialogPrivate::updateStyles().

1066 {
1067  // list of families to try
1068  QStringList family_list;
1069  if (req.family.isEmpty())
1070  return family_list;
1071 
1072  QStringList list = req.family.split(QLatin1Char(','));
1073  for (int i = 0; i < list.size(); ++i) {
1074  QString str = list.at(i).trimmed();
1075  if ((str.startsWith(QLatin1Char('"')) && str.endsWith(QLatin1Char('"')))
1076  || (str.startsWith(QLatin1Char('\'')) && str.endsWith(QLatin1Char('\''))))
1077  str = str.mid(1, str.length() - 2);
1078  family_list << str;
1079  }
1080 
1081  // append the substitute list for each family in family_list
1082  QStringList subs_list;
1083  QStringList::ConstIterator it = family_list.constBegin(), end = family_list.constEnd();
1084  for (; it != end; ++it)
1085  subs_list += QFont::substitutes(*it);
1086 // qDebug() << "adding substs: " << subs_list;
1087 
1088  family_list += subs_list;
1089 
1090  return family_list;
1091 }
#define it(className, varName)
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString trimmed() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end.
Definition: qstring.cpp:4506
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
static QStringList substitutes(const QString &)
Returns a list of family names to be used whenever familyName is specified.
Definition: qfont.cpp:2139
const_iterator ConstIterator
Qt-style synonym for QList::const_iterator.
Definition: qlist.h:279
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
Definition: qstring.cpp:6526
QString family
Definition: qfont_p.h:82
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
Definition: qstring.cpp:3796
static const KeyPair *const end
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272

◆ findEncoding()

static QtFontEncoding* findEncoding ( int  script,
int  styleStrategy,
QtFontSize size,
int  force_encoding_id 
)
static

Definition at line 1165 of file qfontdatabase.cpp.

1167 {
1168  QtFontEncoding *encoding = 0;
1169 
1170  if (force_encoding_id >= 0) {
1171  encoding = size->encodingID(force_encoding_id);
1172  if (!encoding)
1173  FM_DEBUG(" required encoding_id not available");
1174  return encoding;
1175  }
1176 
1177  if (styleStrategy & (QFont::OpenGLCompatible | QFont::PreferBitmap)) {
1178  FM_DEBUG(" PreferBitmap and/or OpenGL set, skipping Freetype");
1179  } else {
1180  encoding = size->encodingID(-1); // -1 == prefer Freetype
1181  if (encoding)
1182  return encoding;
1183  }
1184 
1185  // FT not available, find an XLFD font, trying the default encoding first
1186  encoding = size->encodingID(QFontPrivate::defaultEncodingID);
1187  if (encoding) {
1188  // does it support the requested script?
1189  bool supportsScript = false;
1190  for (int ws = 1; !supportsScript && ws < QFontDatabase::WritingSystemsCount; ++ws) {
1192  continue;
1193  supportsScript = writingSystems_for_xlfd_encoding[encoding->encoding][ws];
1194  }
1195  if (!supportsScript)
1196  encoding = 0;
1197  }
1198  // find the first encoding that supports the requested script
1199  for (int ws = 1; !encoding && ws < QFontDatabase::WritingSystemsCount; ++ws) {
1201  continue;
1202  for (int x = 0; !encoding && x < size->count; ++x) {
1203  const int enc = size->encodings[x].encoding;
1205  encoding = size->encodings + x;
1206  }
1207  }
1208 
1209  return encoding;
1210 }
static int defaultEncodingID
Definition: qfont_p.h:167
#define FM_DEBUG
signed int encoding
Q_CORE_EXPORT int QT_FASTCALL script(uint ucs4)
QTextStream & ws(QTextStream &stream)
Calls skipWhiteSpace() on stream and returns stream.
QtFontEncoding * encodingID(int id, uint xpoint=0, uint xres=0, uint yres=0, uint avgwidth=0, bool add=false)
unsigned short count
static const char writingSystems_for_xlfd_encoding[sizeof(xlfd_encoding)][QFontDatabase::WritingSystemsCount]
QtFontEncoding * encodings
static const int scriptForWritingSystem[]

◆ getEngineData()

static void getEngineData ( const QFontPrivate d,
const QFontCache::Key key 
)
static

Definition at line 1051 of file qfontdatabase.cpp.

Referenced by QFontDatabase::findFont(), loadWin(), and QFontDatabase::loadXlfd().

1052 {
1053  // look for the requested font in the engine data cache
1055  if (!d->engineData) {
1056  // create a new one
1057  d->engineData = new QFontEngineData;
1059  } else {
1060  d->engineData->ref.ref();
1061  }
1062 }
bool ref()
Atomically increments the value of this QAtomicInt.
static QFontCache * instance()
Definition: qfont.cpp:2919
void insertEngineData(const Key &key, QFontEngineData *engineData)
Definition: qfont.cpp:3046
QAtomicInt ref
Definition: qfont_p.h:152
QFontEngineData * findEngineData(const Key &key) const
Definition: qfont.cpp:3036
QFontEngineData * engineData
Definition: qfont_p.h:179

◆ getFontWeight()

static int getFontWeight ( const QString weightString)
static

Definition at line 101 of file qfontdatabase.cpp.

Referenced by getStyle(), QtFontStyle::Key::Key(), and qt_fillFontDef().

102 {
103  QString s = weightString.toLower();
104 
105  // Test in decreasing order of commonness
106  if (s == QLatin1String("medium") ||
107  s == QLatin1String("normal")
108  || s.compare(QApplication::translate("QFontDatabase", "Normal"), Qt::CaseInsensitive) == 0)
109  return QFont::Normal;
110  if (s == QLatin1String("bold")
111  || s.compare(QApplication::translate("QFontDatabase", "Bold"), Qt::CaseInsensitive) == 0)
112  return QFont::Bold;
113  if (s == QLatin1String("demibold") || s == QLatin1String("demi bold")
114  || s.compare(QApplication::translate("QFontDatabase", "Demi Bold"), Qt::CaseInsensitive) == 0)
115  return QFont::DemiBold;
116  if (s == QLatin1String("black")
117  || s.compare(QApplication::translate("QFontDatabase", "Black"), Qt::CaseInsensitive) == 0)
118  return QFont::Black;
119  if (s == QLatin1String("light"))
120  return QFont::Light;
121 
122  if (s.contains(QLatin1String("bold"))
123  || s.contains(QApplication::translate("QFontDatabase", "Bold"), Qt::CaseInsensitive)) {
124  if (s.contains(QLatin1String("demi"))
125  || s.compare(QApplication::translate("QFontDatabase", "Demi"), Qt::CaseInsensitive) == 0)
126  return (int) QFont::DemiBold;
127  return (int) QFont::Bold;
128  }
129 
130  if (s.contains(QLatin1String("light"))
131  || s.compare(QApplication::translate("QFontDatabase", "Light"), Qt::CaseInsensitive) == 0)
132  return (int) QFont::Light;
133 
134  if (s.contains(QLatin1String("black"))
135  || s.compare(QApplication::translate("QFontDatabase", "Black"), Qt::CaseInsensitive) == 0)
136  return (int) QFont::Black;
137 
138  return (int) QFont::Normal;
139 }
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
int compare(const QString &s) const
Definition: qstring.cpp:5037
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
Definition: qstring.cpp:5389

◆ parseFontName()

static void parseFontName ( const QString name,
QString foundry,
QString family 
)
static

This makes sense of the font family name:

if the family name contains a '[' and a ']', then we take the text between the square brackets as the foundry, and the text before the square brackets as the family (ie.

Warning
This function is not part of the public interface.

"Arial [Monotype]")

Definition at line 970 of file qfontdatabase.cpp.

Referenced by QFontDatabase::bold(), QFontDatabase::font(), getFcPattern(), QFontDatabase::hasFamily(), QFontDatabase::isBitmapScalable(), QFontDatabase::isFixedPitch(), QFontDatabase::isSmoothlyScalable(), QFontDatabase::italic(), loadWin(), QFontDatabase::loadXlfd(), QFontDatabase::parseFontName(), QFontDatabase::pointSizes(), registerFont(), QFontDatabase::smoothSizes(), QFontDatabase::styles(), QFontDatabase::weight(), and QFontDatabase::writingSystems().

971 {
972  int i = name.indexOf(QLatin1Char('['));
973  int li = name.lastIndexOf(QLatin1Char(']'));
974  if (i >= 0 && li >= 0 && i < li) {
975  foundry = name.mid(i + 1, li - i - 1);
976  if (i > 0 && name[i - 1] == QLatin1Char(' '))
977  i--;
978  family = name.left(i);
979  } else {
980  foundry.clear();
981  family = name;
982  }
983 
984  // capitalize the family/foundry names
985  bool space = true;
986  QChar *s = family.data();
987  int len = family.length();
988  while(len--) {
989  if (space) *s = s->toUpper();
990  space = s->isSpace();
991  ++s;
992  }
993 
994  space = true;
995  s = foundry.data();
996  len = foundry.length();
997  while(len--) {
998  if (space) *s = s->toUpper();
999  space = s->isSpace();
1000  ++s;
1001  }
1002 }
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QChar * data()
Returns a pointer to the data stored in the QString.
Definition: qstring.h:710
bool isSpace() const
Returns true if the character is a separator character (Separator_* categories); otherwise returns fa...
Definition: qchar.cpp:609
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
const char * name
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
QChar toUpper() const
Returns the uppercase equivalent if the character is lowercase or titlecase; otherwise returns the ch...
Definition: qchar.cpp:1287
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
void clear()
Clears the contents of the string and makes it empty.
Definition: qstring.h:723
int lastIndexOf(QChar c, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:3000
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ qt_determine_writing_systems_from_truetype_bits()

QList<QFontDatabase::WritingSystem> qt_determine_writing_systems_from_truetype_bits ( quint32  unicodeRange[4],
quint32  codePageRange[2] 
)

Definition at line 587 of file qfontdatabase.cpp.

Referenced by addFontToDatabase(), QFontDatabasePrivate::addTTFile(), QRawFont::fontTable(), initWritingSystems(), and QRawFont::supportedWritingSystems().

588 {
590  bool hasScript = false;
591 
592  int i;
593  for(i = 0; i < QFontDatabase::WritingSystemsCount; i++) {
594  int bit = requiredUnicodeBits[i][0];
595  int index = bit/32;
596  int flag = 1 << (bit&31);
597  if (bit != 126 && unicodeRange[index] & flag) {
598  bit = requiredUnicodeBits[i][1];
599  index = bit/32;
600 
601  flag = 1 << (bit&31);
602  if (bit == 127 || unicodeRange[index] & flag) {
603  writingSystems.append(QFontDatabase::WritingSystem(i));
604  hasScript = true;
605  // qDebug("font %s: index=%d, flag=%8x supports script %d", familyName.latin1(), index, flag, i);
606  }
607  }
608  }
609  if(codePageRange[0] & (1 << SimplifiedChineseCsbBit)) {
611  hasScript = true;
612  //qDebug("font %s supports Simplified Chinese", familyName.latin1());
613  }
614  if(codePageRange[0] & (1 << TraditionalChineseCsbBit)) {
616  hasScript = true;
617  //qDebug("font %s supports Traditional Chinese", familyName.latin1());
618  }
619  if(codePageRange[0] & (1 << JapaneseCsbBit)) {
620  writingSystems.append(QFontDatabase::Japanese);
621  hasScript = true;
622  //qDebug("font %s supports Japanese", familyName.latin1());
623  }
624  if(codePageRange[0] & (1 << KoreanCsbBit)) {
625  writingSystems.append(QFontDatabase::Korean);
626  hasScript = true;
627  //qDebug("font %s supports Korean", familyName.latin1());
628  }
629  if (!hasScript)
630  writingSystems.append(QFontDatabase::Symbol);
631 
632  return writingSystems;
633 }
static int requiredUnicodeBits[QFontDatabase::WritingSystemsCount][2]
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
#define SimplifiedChineseCsbBit
quint16 index
#define JapaneseCsbBit
#define KoreanCsbBit
#define TraditionalChineseCsbBit

◆ qt_fontdata_from_index()

Q_GUI_EXPORT QByteArray qt_fontdata_from_index ( int  index)

Definition at line 2594 of file qfontdatabase.cpp.

Referenced by QFreetypeFace::getFace().

2595 {
2596  QMutexLocker locker(fontDatabaseMutex());
2597  return privateDb()->applicationFonts.value(index).data;
2598 }
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
quint16 index

◆ qt_fontdatabase_mutex()

QMutex* qt_fontdatabase_mutex ( )

◆ qt_mac_get_fixed_pitch()

static void qt_mac_get_fixed_pitch ( QtFontFamily f)
inlinestatic

Definition at line 473 of file qfontdatabase.cpp.

Referenced by findEncoding(), and QFontDatabase::isFixedPitch().

474 {
475  if(f && !f->fixedPitchComputed) {
476  QFontMetrics fm(f->name);
477  f->fixedPitch = fm.width(QLatin1Char('i')) == fm.width(QLatin1Char('m'));
478  f->fixedPitchComputed = true;
479  }
480 }
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ qt_script_for_writing_system()

int qt_script_for_writing_system ( QFontDatabase::WritingSystem  writingSystem)

Definition at line 938 of file qfontdatabase.cpp.

Referenced by QRawFont::fromFont(), and QRawFont::supportsCharacter().

939 {
940  return scriptForWritingSystem[writingSystem];
941 }
static const int scriptForWritingSystem[]

◆ qt_setQtEnableTestFont()

Q_AUTOTEST_EXPORT void qt_setQtEnableTestFont ( bool  value)

Definition at line 96 of file qfontdatabase.cpp.

97 {
98  qt_enable_test_font = value;
99 }
bool qt_enable_test_font

◆ requiresOpenType()

static bool requiresOpenType ( int  writingSystem)
inlinestatic

Definition at line 945 of file qfontdatabase.cpp.

Referenced by loadFontConfig().

946 {
947  return ((writingSystem >= QFontDatabase::Syriac && writingSystem <= QFontDatabase::Sinhala)
948  || writingSystem == QFontDatabase::Khmer || writingSystem == QFontDatabase::Nko);
949 }

◆ scriptRequiresOpenType()

static bool scriptRequiresOpenType ( int  script)
inlinestatic

◆ styleStringHelper()

static QString styleStringHelper ( int  weight,
QFont::Style  style 
)
static

Definition at line 1503 of file qfontdatabase.cpp.

Referenced by initializeDb(), QFontDatabase::styles(), and QFontDatabase::styleString().

1504 {
1505  QString result;
1506  if (weight >= QFont::Black)
1507  result = QApplication::translate("QFontDatabase", "Black");
1508  else if (weight >= QFont::Bold)
1509  result = QApplication::translate("QFontDatabase", "Bold");
1510  else if (weight >= QFont::DemiBold)
1511  result = QApplication::translate("QFontDatabase", "Demi Bold");
1512  else if (weight < QFont::Normal)
1513  result = QApplication::translate("QFontDatabase", "Light");
1514 
1515  if (style == QFont::StyleItalic)
1516  result += QLatin1Char(' ') + QApplication::translate("QFontDatabase", "Italic");
1517  else if (style == QFont::StyleOblique)
1518  result += QLatin1Char(' ') + QApplication::translate("QFontDatabase", "Oblique");
1519 
1520  if (result.isEmpty())
1521  result = QApplication::translate("QFontDatabase", "Normal");
1522 
1523  return result.simplified();
1524 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QString simplified() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end, and that has each sequence o...
Definition: qstring.cpp:4415
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ weightFromInteger()

QFont::Weight weightFromInteger ( int  weight)

Definition at line 142 of file qfontdatabase.cpp.

Referenced by addFontToDatabase(), getEnglishName(), qt_LOGFONTtoQFont(), and resolveGdi32().

143 {
144  if (weight < 400)
145  return QFont::Light;
146  else if (weight < 600)
147  return QFont::Normal;
148  else if (weight < 700)
149  return QFont::DemiBold;
150  else if (weight < 800)
151  return QFont::Bold;
152  else
153  return QFont::Black;
154 }

Variable Documentation

◆ qt_enable_test_font

bool qt_enable_test_font = false

◆ requiredUnicodeBits

int requiredUnicodeBits[QFontDatabase::WritingSystemsCount][2]
static

Definition at line 511 of file qfontdatabase.cpp.

◆ scriptForWritingSystem

const int scriptForWritingSystem[]
static

Definition at line 901 of file qfontdatabase.cpp.

Referenced by load().