155 const QString &fullName,
156 const LOGFONT &logFont,
157 const TEXTMETRIC *textmetric,
158 const FONTSIGNATURE *signature,
162 if (familyName.isEmpty() || familyName.at(0) == u'@' || familyName.startsWith(
"WST_"_L1))
165 uchar charSet = logFont.lfCharSet;
167 static const int SMOOTH_SCALABLE = 0xffff;
168 const QString foundryName;
169 const bool fixed = !(textmetric->tmPitchAndFamily & TMPF_FIXED_PITCH);
170 const bool ttf = (textmetric->tmPitchAndFamily & TMPF_TRUETYPE);
171 const bool scalable = textmetric->tmPitchAndFamily & (TMPF_VECTOR|TMPF_TRUETYPE);
172 const int size = scalable ? SMOOTH_SCALABLE : textmetric->tmHeight;
173 const QFont::Style style = textmetric->tmItalic ? QFont::StyleItalic : QFont::StyleNormal;
174 const bool antialias =
false;
175 const QFont::Weight weight =
static_cast<QFont::Weight>(textmetric->tmWeight);
176 const QFont::Stretch stretch = QFont::Unstretched;
178#ifndef QT_NO_DEBUG_STREAM
179 if (lcQpaFonts().isDebugEnabled()) {
181 QTextStream str(&message);
182 str <<
__FUNCTION__ <<
' ' << familyName <<
"::" << fullName <<
' ' << charSet <<
" TTF=" << ttf;
183 if (type & DEVICE_FONTTYPE)
185 if (type & RASTER_FONTTYPE)
187 if (type & TRUETYPE_FONTTYPE)
189 str <<
" scalable=" << scalable <<
" Size=" << size
190 <<
" Style=" << style <<
" Weight=" << weight
191 <<
" stretch=" << stretch;
192 qCDebug(lcQpaFonts) << message;
197 QString faceName = familyName;
199 QString subFamilyName;
200 QString subFamilyStyle;
202 QFontNames canonicalNames = qt_getCanonicalFontNames(logFont);
203 if (qt_localizedName(familyName) && !canonicalNames.name.isEmpty())
204 englishName = canonicalNames.name;
205 if (!canonicalNames.preferredName.isEmpty()) {
206 subFamilyName = familyName;
207 subFamilyStyle = styleName;
208 familyName = canonicalNames.preferredName;
209 styleName = canonicalNames.preferredStyle;
212 QSupportedWritingSystems writingSystems;
213 if (type & TRUETYPE_FONTTYPE) {
215 quint32 unicodeRange[4] = {
216 signature->fsUsb[0], signature->fsUsb[1],
217 signature->fsUsb[2], signature->fsUsb[3]
219 quint32 codePageRange[2] = {
220 signature->fsCsb[0], signature->fsCsb[1]
222 writingSystems = QPlatformFontDatabase::writingSystemsFromTrueTypeBits(unicodeRange, codePageRange);
228 if (writingSystems.supported(QFontDatabase::Thai) && faceName ==
"Segoe UI"_L1)
229 writingSystems.setSupported(QFontDatabase::Thai,
false);
231 const QFontDatabase::WritingSystem ws = writingSystemFromCharSet(charSet);
232 if (ws != QFontDatabase::Any)
233 writingSystems.setSupported(ws);
237 const FontKey *key = findFontKey(fullName, &index);
241 QLocale systemLocale = QLocale::system();
242 if (systemLocale.language() != QLocale::C
243 && systemLocale.language() != QLocale::English
244 && styleName !=
"Italic"_L1
245 && styleName !=
"Bold"_L1) {
246 key = findFontKey(qt_getEnglishName(fullName,
true), &index);
249 key = findFontKey(faceName, &index);
250 if (!key && !englishName.isEmpty())
251 key = findFontKey(englishName, &index);
255 QString value = key->fileName;
259 if (!QDir::isAbsolutePath(value))
260 value.prepend(QFile::decodeName(qgetenv(
"windir") +
"\\Fonts\\"));
262 const bool color = detectColorFont(value.toLocal8Bit());
264 QPlatformFontDatabase::registerFont(familyName, styleName, foundryName, weight, style, stretch,
265 antialias, scalable, size, fixed, color, writingSystems, createFontFile(value, index));
268 if (weight <= QFont::DemiBold && styleName.isEmpty())
269 QPlatformFontDatabase::registerFont(familyName, QString(), foundryName, QFont::Bold, style, stretch,
270 antialias, scalable, size, fixed, color, writingSystems, createFontFile(value, index));
272 if (style != QFont::StyleItalic && styleName.isEmpty())
273 QPlatformFontDatabase::registerFont(familyName, QString(), foundryName, weight, QFont::StyleItalic, stretch,
274 antialias, scalable, size, fixed, color, writingSystems, createFontFile(value, index));
276 if (weight <= QFont::DemiBold && style != QFont::StyleItalic && styleName.isEmpty())
277 QPlatformFontDatabase::registerFont(familyName, QString(), foundryName, QFont::Bold, QFont::StyleItalic, stretch,
278 antialias, scalable, size, fixed, color, writingSystems, createFontFile(value, index));
280 if (!subFamilyName.isEmpty() && familyName != subFamilyName) {
281 QPlatformFontDatabase::registerFont(subFamilyName, subFamilyStyle, foundryName, weight,
282 style, stretch, antialias, scalable, size, fixed, color, writingSystems, createFontFile(value, index));
285 if (!englishName.isEmpty() && englishName != familyName)
286 QPlatformFontDatabase::registerAliasToFontFamily(familyName, englishName);