7#include <QtGui/private/qfontengine_ft_p.h>
10#include FT_TRUETYPE_TABLES_H
13#include <QtCore/QDirIterator>
14#include <QtCore/QSettings>
15#if QT_CONFIG(regularexpression)
16#include <QtCore/QRegularExpression>
18#include <QtCore/private/qduplicatetracker_p.h>
20#include <QtGui/QGuiApplication>
21#include <QtGui/QFontDatabase>
33 case EASTEUROPE_CHARSET:
49 case CHINESEBIG5_CHARSET:
51 case SHIFTJIS_CHARSET:
56 case VIETNAMESE_CHARSET:
89 QStringLiteral(
"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts") };
94#if QT_CONFIG(regularexpression)
100 for (
int i = 0;
i <
size; ++
i) {
103 fontKey.fileName = fontRegistry.
value(registryFontKey).
toString();
104 QString realKey = registryFontKey;
106#if QT_CONFIG(regularexpression)
107 realKey.
remove(sizeListMatch);
110 fontKey.fontNames.reserve(fontNames.size());
111 for (
const auto &
fontName : fontNames)
112 fontKey.fontNames.append(
fontName.trimmed().toString());
123 for (
auto it =
keys.constBegin(), cend =
keys.constEnd();
it != cend; ++
it) {
139 const LOGFONT &logFont,
140 const TEXTMETRIC *textmetric,
141 const FONTSIGNATURE *signature,
148 uchar charSet = logFont.lfCharSet;
152 const bool fixed = !(textmetric->tmPitchAndFamily & TMPF_FIXED_PITCH);
153 const bool ttf = (textmetric->tmPitchAndFamily & TMPF_TRUETYPE);
154 const bool scalable = textmetric->tmPitchAndFamily & (TMPF_VECTOR|TMPF_TRUETYPE);
157 const bool antialias =
false;
161#ifndef QT_NO_DEBUG_STREAM
162 if (lcQpaFonts().isDebugEnabled()) {
165 str << __FUNCTION__ <<
' ' << familyName <<
"::" <<
fullName <<
' ' << charSet <<
" TTF=" << ttf;
166 if (
type & DEVICE_FONTTYPE)
168 if (
type & RASTER_FONTTYPE)
170 if (
type & TRUETYPE_FONTTYPE)
172 str <<
" scalable=" << scalable <<
" Size=" <<
size
173 <<
" Style=" << style <<
" Weight=" <<
weight
174 <<
" stretch=" << stretch;
187 englishName = canonicalNames.
name;
189 subFamilyName = familyName;
190 subFamilyStyle = styleName;
196 if (
type & TRUETYPE_FONTTYPE) {
199 signature->fsUsb[0], signature->fsUsb[1],
200 signature->fsUsb[2], signature->fsUsb[3]
203 signature->fsCsb[0], signature->fsCsb[1]
227 && styleName !=
"Italic"_L1
228 && styleName !=
"Bold"_L1) {
261 if (!subFamilyName.
isEmpty() && familyName != subFamilyName) {
266 if (!englishName.
isEmpty() && englishName != familyName)
272static int QT_WIN_CALLBACK
storeFont(
const LOGFONT *logFont,
const TEXTMETRIC *textmetric,
273 DWORD
type, LPARAM lparam)
275 const ENUMLOGFONTEX *
f =
reinterpret_cast<const ENUMLOGFONTEX *
>(logFont);
283 const FONTSIGNATURE *signature =
nullptr;
284 if (
type & TRUETYPE_FONTTYPE) {
285 signature = &
reinterpret_cast<const NEWTEXTMETRICEX *
>(textmetric)->ntmFontSig;
289 if (foundFontAndStyles->hasSeen({faceName, styleName}))
306 for (
const QString &family : families)
323 qCDebug(lcQpaFonts) << familyName;
324 if (familyName.
size() >= LF_FACESIZE) {
325 qCWarning(lcQpaFonts) <<
"Unable to enumerate family '" << familyName <<
'\'';
328 HDC dummy = GetDC(0);
330 memset(&lf, 0,
sizeof(LOGFONT));
332 lf.lfFaceName[familyName.
size()] = 0;
333 lf.lfCharSet = DEFAULT_CHARSET;
334 lf.lfPitchAndFamily = 0;
336 EnumFontFamiliesEx(dummy, &lf,
storeFont,
reinterpret_cast<intptr_t>(&foundFontAndStyles), 0);
345 const ENUMLOGFONTEX *
f =
reinterpret_cast<const ENUMLOGFONTEX *
>(logFont);
347 const wchar_t *faceNameW =
f->elfLogFont.lfFaceName;
348 if (faceNameW[0] && faceNameW[0] != L
'@' && wcsncmp(faceNameW, L
"WST_", 4)) {
350 const bool ttf = textmetric->tmPitchAndFamily & TMPF_TRUETYPE;
373 HDC dummy = GetDC(0);
375 lf.lfCharSet = DEFAULT_CHARSET;
376 lf.lfFaceName[0] = 0;
377 lf.lfPitchAndFamily = 0;
396 qCDebug(lcQpaFonts) << __FUNCTION__ <<
"FONTDATA" <<
fontData << pixelSize << hintingPreference << fe;
407 qCDebug(lcQpaFonts) << __FUNCTION__ << family << style << styleHint
static bool isAbsolutePath(const QString &path)
Returns true if path is absolute; returns false if it is relative.
static QString decodeName(const QByteArray &localFileName)
This does the reverse of QFile::encodeName() using localFileName.
WritingSystem
\value Any \value Latin \value Greek \value Cyrillic \value Armenian \value Hebrew \value Arabic \val...
static QStringList families(WritingSystem writingSystem=Any)
Returns a sorted list of the available font families which support the writingSystem.
StyleHint
Style hints are used by the \l{QFont}{font matching} algorithm to find an appropriate default family ...
QStringList families() const
Stretch
Predefined stretch values that follow the CSS naming convention.
Weight
Qt uses a weighting scale from 1 to 1000 compatible with OpenType.
Style
This enum describes the different styles of glyphs that are used to display text.
QFontEngine * fontEngine(const QFontDef &fontDef, void *handle) override
Returns the font engine that can be used to render the font described by the font definition,...
static QLocale system()
Returns a QLocale object initialized to the system locale.
\inmodule QtCore \reentrant
bool isValid() const
Returns true if the regular expression is a valid regular expression (that is, it contains no syntax ...
QVariant value(QAnyStringView key, const QVariant &defaultValue) const
Returns the value for setting key.
QStringList allKeys() const
Returns a list of all keys, including subkeys, that can be read using the QSettings object.
Q_CORE_EXPORT QList< QStringView > split(QStringView sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Splits the view into substring views wherever sep occurs, and returns the list of those string views.
QStringView trimmed() const noexcept
Strips leading and trailing whitespace and returns the result.
\macro QT_RESTRICTED_CAST_FROM_ASCII
qsizetype toWCharArray(wchar_t *array) const
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
qsizetype size() const
Returns the number of characters in this string.
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
static QString fromWCharArray(const wchar_t *string, qsizetype size=-1)
QString & remove(qsizetype i, qsizetype len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
QString & prepend(QChar c)
The QSupportedWritingSystems class is used when registering fonts with the internal Qt fontdatabase.
bool supported(QFontDatabase::WritingSystem) const
Returns true if the writing system specified by writingSystem is supported; otherwise returns false.
void setSupported(QFontDatabase::WritingSystem, bool supported=true)
Sets or clears support for the specified writingSystem based on the value given by support.
QString toString() const
Returns the variant as a QString if the variant has a userType() including, but not limited to:
static QFont systemDefaultFont()
static QStringList extraTryFontsForFamily(const QString &family)
static QString familyForStyleHint(QFont::StyleHint styleHint)
QFontEngine * fontEngine(const QFontDef &fontDef, void *handle) override
Returns the font engine that can be used to render the font described by the font definition,...
bool m_hasPopulatedAliases
QFont defaultFont() const override
Returns the default system font.
bool populateFamilyAliases(const QString &familyName) override
void populateFamily(const QString &familyName) override
This function is called whenever a lazily populated family, populated through registerFontFamily(),...
void populateFontDatabase() override
This function is called once at startup by Qt's internal font database.
QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const override
Returns a list of alternative fonts for the specified family and style and script using the styleHint...
QString fontDir() const override
Returns the directory containing the fonts used by the database.
QSet< QString >::iterator it
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
static const QSystemLocale * systemLocale()
#define qCWarning(category,...)
#define qCDebug(category,...)
GLuint64 GLenum void * handle
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint GLuint GLfloat weight
GLuint GLsizei const GLchar * message
GLenum const void * fontName
GLenum GLsizeiptr const void * fontData
static void allKeys(HKEY parentHandle, const QString &rSubKey, NameSet *result, REGSAM access=0)
#define QStringLiteral(str)
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
QFontNames qt_getCanonicalFontNames(const LOGFONT &lf)
QString qt_getEnglishName(const QString &familyName, bool includeStyle)
static int QT_WIN_CALLBACK storeFont(const LOGFONT *logFont, const TEXTMETRIC *textmetric, DWORD type, LPARAM lparam)
bool qt_localizedName(const QString &name)
static int QT_WIN_CALLBACK populateFontFamilies(const LOGFONT *logFont, const TEXTMETRIC *textmetric, DWORD, LPARAM)
static FontKeys & fontKeys()
static int QT_WIN_CALLBACK storeFont(const LOGFONT *logFont, const TEXTMETRIC *textmetric, DWORD type, LPARAM lparam)
static FontFile * createFontFile(const QString &fileName, int index)
static QFontDatabase::WritingSystem writingSystemFromCharSet(uchar charSet)
static int QT_WIN_CALLBACK populateFontFamilies(const LOGFONT *logFont, const TEXTMETRIC *textmetric, DWORD, LPARAM)
static bool addFontToDatabase(QString familyName, QString styleName, const QString &fullName, const LOGFONT &logFont, const TEXTMETRIC *textmetric, const FONTSIGNATURE *signature, int type)
static const FontKey * findFontKey(const QString &name, int *indexIn=nullptr)