From 901ab8fab0829a4551f2d7dd963b770719d2e8e3 Mon Sep 17 00:00:00 2001 From: Zufu Liu Date: Thu, 11 Apr 2019 08:32:09 +1000 Subject: Feature [feature-requests:#1277]. Support coloured text on Windows 8.1+. --- doc/ScintillaHistory.html | 4 ++++ win32/PlatWin.cxx | 18 +++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 12b2597f3..c44fdc1e0 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -593,6 +593,10 @@ Bug #2087.
  • + Support coloured text in Windows 8.1+. + Feature #1277. +
  • +
  • Fix exception when inserting DBCS text. Bug #2093.
  • diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index fa1147b0f..d1ff19b55 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -67,6 +67,7 @@ IDWriteFactory *pIDWriteFactory = nullptr; ID2D1Factory *pD2DFactory = nullptr; IDWriteRenderingParams *defaultRenderingParams = nullptr; IDWriteRenderingParams *customClearTypeRenderingParams = nullptr; +D2D1_DRAW_TEXT_OPTIONS d2dDrawTextOptions = D2D1_DRAW_TEXT_OPTIONS_NONE; static HMODULE hDLLD2D {}; static HMODULE hDLLDWrite {}; @@ -105,9 +106,20 @@ bool LoadD2D() { if (hDLLDWrite) { DWriteCFSig fnDWCF = reinterpret_cast(::GetProcAddress(hDLLDWrite, "DWriteCreateFactory")); if (fnDWCF) { - fnDWCF(DWRITE_FACTORY_TYPE_SHARED, - __uuidof(IDWriteFactory), + const GUID IID_IDWriteFactory2 = // 0439fc60-ca44-4994-8dee-3a9af7b732ec + { 0x0439fc60, 0xca44, 0x4994, { 0x8d, 0xee, 0x3a, 0x9a, 0xf7, 0xb7, 0x32, 0xec } }; + + const HRESULT hr = fnDWCF(DWRITE_FACTORY_TYPE_SHARED, + IID_IDWriteFactory2, reinterpret_cast(&pIDWriteFactory)); + if (SUCCEEDED(hr)) { + // D2D1_DRAW_TEXT_OPTIONS_ENABLE_COLOR_FONT + d2dDrawTextOptions = static_cast(0x00000004); + } else { + fnDWCF(DWRITE_FACTORY_TYPE_SHARED, + __uuidof(IDWriteFactory), + reinterpret_cast(&pIDWriteFactory)); + } } } @@ -1894,7 +1906,7 @@ void SurfaceD2D::DrawTextCommon(PRectangle rc, Font &font_, XYPOSITION ybase, st rc.Width(), rc.Height(), &pTextLayout); if (SUCCEEDED(hr)) { D2D1_POINT_2F origin = {rc.left, ybase-yAscent}; - pRenderTarget->DrawTextLayout(origin, pTextLayout, pBrush, D2D1_DRAW_TEXT_OPTIONS_NONE); + pRenderTarget->DrawTextLayout(origin, pTextLayout, pBrush, d2dDrawTextOptions); pTextLayout->Release(); } -- cgit v1.2.3