diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2023-10-02 12:29:07 +0200 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2023-10-02 18:00:33 +0200 |
commit | 0138d910b2a249f27a824d5cbead0b034d5b2918 (patch) | |
tree | 1c376f5414efa5c1d86a27c898111ace43dac31a /src/gui/text/windows/qwindowsfontenginedirectwrite.cpp | |
parent | d4e5898ba0324a0e9a9f25e47861a5279b9416c5 (diff) |
DirectWrite: Fetch correct style name in font info
When getting the font info for a resolved QFont on DirectWrite,
the style name would not be set, so there would be no way to
check the style name of the actual resolved font.
Change-Id: I5ff27e95619a330b7d2a0252222fad8629837418
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/gui/text/windows/qwindowsfontenginedirectwrite.cpp')
-rw-r--r-- | src/gui/text/windows/qwindowsfontenginedirectwrite.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/gui/text/windows/qwindowsfontenginedirectwrite.cpp b/src/gui/text/windows/qwindowsfontenginedirectwrite.cpp index 24417ac79e..9c4ca33f91 100644 --- a/src/gui/text/windows/qwindowsfontenginedirectwrite.cpp +++ b/src/gui/text/windows/qwindowsfontenginedirectwrite.cpp @@ -15,7 +15,12 @@ #include <QtGui/private/qhighdpiscaling_p.h> #include <QtGui/qpainterpath.h> -#include <dwrite_2.h> +#if QT_CONFIG(directwrite3) +# include "qwindowsdirectwritefontdatabase_p.h" +# include <dwrite_3.h> +#else +# include <dwrite_2.h> +#endif #include <d2d1.h> @@ -1009,6 +1014,21 @@ void QWindowsFontEngineDirectWrite::initFontInfo(const QFontDef &request, fontDef.pointSize = fontDef.pixelSize * 72. / dpi; else if (fontDef.pixelSize == -1) fontDef.pixelSize = qRound(fontDef.pointSize * dpi / 72.); + +#if QT_CONFIG(directwrite3) + IDWriteFontFace3 *face3 = nullptr; + if (SUCCEEDED(m_directWriteFontFace->QueryInterface(__uuidof(IDWriteFontFace3), + reinterpret_cast<void **>(&face3)))) { + IDWriteLocalizedStrings *names; + if (SUCCEEDED(face3->GetFaceNames(&names))) { + wchar_t englishLocale[] = L"en-us"; + fontDef.styleName = QWindowsDirectWriteFontDatabase::localeString(names, englishLocale); + names->Release(); + } + + face3->Release(); + } +#endif } QString QWindowsFontEngineDirectWrite::fontNameSubstitute(const QString &familyName) |