summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp15
-rw-r--r--src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp15
2 files changed, 24 insertions, 6 deletions
diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp
index bd4338feb8..9e6e5d88c7 100644
--- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp
+++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp
@@ -1118,7 +1118,7 @@ static bool addFontToDatabase(QString familyName,
}
static int QT_WIN_CALLBACK storeFont(const LOGFONT *logFont, const TEXTMETRIC *textmetric,
- DWORD type, LPARAM)
+ DWORD type, LPARAM lparam)
{
const ENUMLOGFONTEX *f = reinterpret_cast<const ENUMLOGFONTEX *>(logFont);
const QString familyName = QString::fromWCharArray(f->elfLogFont.lfFaceName);
@@ -1128,8 +1128,16 @@ static int QT_WIN_CALLBACK storeFont(const LOGFONT *logFont, const TEXTMETRIC *t
// to the documentation is identical to a TEXTMETRIC except for the last four
// members, which we don't use anyway
const FONTSIGNATURE *signature = nullptr;
- if (type & TRUETYPE_FONTTYPE)
+ if (type & TRUETYPE_FONTTYPE) {
signature = &reinterpret_cast<const NEWTEXTMETRICEX *>(textmetric)->ntmFontSig;
+ // We get a callback for each script-type supported, but we register them all
+ // at once using the signature, so we only need one call to addFontToDatabase().
+ QSet<QPair<QString,QString>> *foundFontAndStyles = reinterpret_cast<QSet<QPair<QString,QString>> *>(lparam);
+ QPair<QString,QString> fontAndStyle(familyName, styleName);
+ if (foundFontAndStyles->contains(fontAndStyle))
+ return 1;
+ foundFontAndStyles->insert(fontAndStyle);
+ }
addFontToDatabase(familyName, styleName, *logFont, textmetric, signature, type);
// keep on enumerating
@@ -1149,7 +1157,8 @@ void QWindowsFontDatabase::populateFamily(const QString &familyName)
familyName.toWCharArray(lf.lfFaceName);
lf.lfFaceName[familyName.size()] = 0;
lf.lfPitchAndFamily = 0;
- EnumFontFamiliesEx(dummy, &lf, storeFont, 0, 0);
+ QSet<QPair<QString,QString>> foundFontAndStyles;
+ EnumFontFamiliesEx(dummy, &lf, storeFont, reinterpret_cast<intptr_t>(&foundFontAndStyles), 0);
ReleaseDC(0, dummy);
}
diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp
index db2186644b..fdef0f5ff1 100644
--- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp
+++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp
@@ -303,7 +303,7 @@ static bool addFontToDatabase(QString familyName,
}
static int QT_WIN_CALLBACK storeFont(const LOGFONT *logFont, const TEXTMETRIC *textmetric,
- DWORD type, LPARAM)
+ DWORD type, LPARAM lparam)
{
const ENUMLOGFONTEX *f = reinterpret_cast<const ENUMLOGFONTEX *>(logFont);
const QString faceName = QString::fromWCharArray(f->elfLogFont.lfFaceName);
@@ -314,8 +314,16 @@ static int QT_WIN_CALLBACK storeFont(const LOGFONT *logFont, const TEXTMETRIC *t
// to the documentation is identical to a TEXTMETRIC except for the last four
// members, which we don't use anyway
const FONTSIGNATURE *signature = nullptr;
- if (type & TRUETYPE_FONTTYPE)
+ if (type & TRUETYPE_FONTTYPE) {
signature = &reinterpret_cast<const NEWTEXTMETRICEX *>(textmetric)->ntmFontSig;
+ // We get a callback for each script-type supported, but we register them all
+ // at once using the signature, so we only need one call to addFontToDatabase().
+ QSet<QPair<QString,QString>> *foundFontAndStyles = reinterpret_cast<QSet<QPair<QString,QString>> *>(lparam);
+ QPair<QString,QString> fontAndStyle(faceName, styleName);
+ if (foundFontAndStyles->contains(fontAndStyle))
+ return 1;
+ foundFontAndStyles->insert(fontAndStyle);
+ }
addFontToDatabase(faceName, styleName, fullName, *logFont, textmetric, signature, type);
// keep on enumerating
@@ -344,7 +352,8 @@ void QWindowsFontDatabaseFT::populateFamily(const QString &familyName)
lf.lfFaceName[familyName.size()] = 0;
lf.lfCharSet = DEFAULT_CHARSET;
lf.lfPitchAndFamily = 0;
- EnumFontFamiliesEx(dummy, &lf, storeFont, 0, 0);
+ QSet<QPair<QString,QString>> foundFontAndStyles;
+ EnumFontFamiliesEx(dummy, &lf, storeFont, reinterpret_cast<intptr_t>(&foundFontAndStyles), 0);
ReleaseDC(0, dummy);
}