Thanks, good point about the ranges. Sounds like the clamping belongs in the Win32 DirectWrite code rather than in SCI_STYLESETWEIGHT. I tried clamping in the E_INVALIDARG retry and it's nicer where it works: the font gets created and the text is drawn instead of nothing. It also covers stretch, which crashes the same way (stretch 0, 10 and -1 crash 5.6.7 too). It doesn't catch everything though, at least under Wine 9: its DirectWrite refuses weights above 950 even though DWRITE_FONT_WEIGHT is documented...
Thanks, good point about the ranges. Sounds like the clamping belongs in the Win32 DirectWrite code rather than in SCI_STYLESETWEIGHT. I tried clamping in the E_INVALIDARG retry and it's nicer where it works: the font gets created and the text is drawn instead of nothing. It also covers stretch, which crashes the same way (stretch 0, 10 and -1 crash 5.6.7 too). It doesn't catch everything though, at least under Wine 9: its DirectWrite refuses weights above 950 even though DWRITE_FONT_WEIGHT is documented...
[Win32] Crash in FontDirectWrite::HFont when DirectWrite refused the font (e.g. SCI_STYLESETWEIGHT 1000), on showing autocompletion
Hi @zufuliu, Thanks for referencing those here. Having read them, I understand the conclusion: mapping GDI typeface names is a naming policy that belongs to the application, which can use IDWriteGdiInterop and pass the DirectWrite family with SCI_STYLESETWEIGHT and, since 5.5.2, SCI_STYLESETSTRETCH. I'll do it in the application, so please consider the patch withdrawn unless you find this worth keeping. One thing that may still help others: ScintillaDoc.html doesn't seem to mention the difference....
[Win32] Add SCI_SETFONTRENDERINGPARAMETER to set DirectWrite rendering parameters (gamma, contrast, ClearType level, pixel geometry, rendering mode)
[Win32] GDI family names of a weight ("Fira Code Light") draw with a fallback font under DirectWrite; GDI fakes their bold