https://docs.microsoft.com/en-us/windows/desktop/api/d2d1/ne-d2d1-d2d1_draw_text_options
D2D1_DRAW_TEXT_OPTIONS_ENABLE_COLOR_FONT is available for Windows 8.1 and above ( not available in Win7 SDK and MinGW-w64 before 2019-02-12).
Using this option crashed on early systems.
The patch is just an outline, need portable version checking (versionhelpers.h only usable for _WIN32_WINNT >= 0x0501 and not available in MinGW-w64 before 2015-03-09. call GetVersion() may got deprecated warnings).
Versionhelpers have an unchecked version dependency themselves since VerifyVersionInfo is only from Windows 2000 or later. Not that Windows NT 4 has been checked recently.
https://docs.microsoft.com/en-us/windows/desktop/api/Winbase/nf-winbase-verifyversioninfoa
Attempting to dynamically load and use VerifyVersionInfo is complex.
https://walbourn.github.io/whats-in-a-version-number/
Its unclear just which call 'crashed on early systems' and its possible the crash can be avoided by checking the results from some test calls with coloured characters.
kD2D1DrawTextOptions isn't a constant and Scintilla doesn't use 'k' prefixes for constants. Its also inside the Scintilla namespace so doesn't need to be static.
Perhaps its better to have a more direct check. The coloured text support arrived with the dwrite_2.h file and IDWriteFactory2.
https://docs.microsoft.com/en-us/windows/desktop/api/dwrite_2/nn-dwrite_2-idwritefactory2
So, the code could ask for IDWriteFactory2, and set D2D1_DRAW_TEXT_OPTIONS_ENABLE_COLOR_FONT if that worked. If it fails, ask for IDWriteFactory. Something like:
Including dwrite_2.h could have its own problems with older SDKs or MinGW distributions.
Your code works.
the patch replaced
__uuidof(IDWriteFactory2)
with hard-coded UUID (which not changes), no dependency on dwrite_2.h.'crashed on early systems': application (i.e. SciTE) not crashed, but draws nothing when open files, only got a black editor window, no caret, no text.
Change committed as [76fcbb].
Related
Commit: [76fcbb]