Issues with GDI Scaling in Windows

33 views
Skip to first unread message

Michael Staszewski

unread,
Aug 19, 2024, 9:45:04 AMAug 19
to scintilla-interest
We've discovered what appears to be a defect in Scintilla in our Windows application. It is reproducible in SciTE.

Our application uses GDI Scaling which can be configured by compiler option or by overriding the High DPI scaling behavior of the executable and setting it to System (Enhanced).

ScalingBehavior.png

With some font/size combinations and when the technology property is set to SC_TECHNOLOGY_DEFAULT there are various issues including...
  • Characters crowding each other
  • Excessive visual space between characters
  • Characters of the current line shifting left or right
  • Selection painting not aligning with character boundaries
  • Incorrect caret placement and incorrect text modification when editing text using a rectangular selection
Consolas 14 pt is a good combination to produce some of the issues. Here we can see text crowding and selection painting issues and something going on there with the E before INVOICE.

Painting.jpg

We have several workarounds available, each having side effects, and would like something more stable. We can use SC_TECHNOLOGY_DIRECTWRITE and this resolves it with minimal side effects; however, the DirectWrite technologies enable font ligatures.

We surface Font Ligatures as an option in our product and when enabled we use DirectWrite; when disabled we use the Default technology. SciTE doesn't appear to show ligatures when using a suitable font (Fira Code) and I don't see an option for disabling it.

  1. Is this GDI Scaling issue a defect or just a known issue/limitation?
  2. Is there a way to disable font ligatures and still use the DirectWrite API?

Ideally our application would move to the newer PerMonitorV2 scaling in Windows which I believe fixes everything as well, but we have some limitations at the moment preventing us from making the leap.

Thanks,
Michael

Neil Hodgson

unread,
Aug 20, 2024, 8:44:09 AMAug 20
to Scintilla mailing list
Michael Staszewski:

> Our application uses GDI Scaling which can be configured by compiler option or by overriding the High DPI scaling behavior of the executable and setting it to System (Enhanced).

I recommend DPI aware mode and it's less likely that fixes and improvements will be made to scaling.

> With some font/size combinations and when the technology property is set to SC_TECHNOLOGY_DEFAULT there are various issues including...

SC_TECHNOLOGY_DIRECTWRITE is now the focus of development effort.

> … however, the DirectWrite technologies enable font ligatures.
>
> We surface Font Ligatures as an option in our product and when enabled we use DirectWrite; when disabled we use the Default technology. SciTE doesn't appear to show ligatures when using a suitable font (Fira Code) and I don't see an option for disabling it.

SciTE has a "technology" setting corresponding to the API mentioned above.

> • Is this GDI Scaling issue a defect or just a known issue/limitation?

While there is some misplacement for me, it is weaker than the images. The System and Application modes appear better than System (Enhanced).

It can be considered a defect if you want but that doesn't mean that anyone will fix it. There are better supported modes that should be preferred.

> • Is there a way to disable font ligatures and still use the DirectWrite API?

It is likely that IDWriteTypography::AddFontFeature in conjunction with a feature tag like DWRITE_FONT_FEATURE_TAG_DISCRETIONARY_LIGATURES may control this. For Scintilla, there would have to be some abstraction to produce a cross-platform API. There have been similar requests before, including one for surfacing pango_attr_font_features_new for use on GTK.

Neil

Michael Staszewski

unread,
Aug 20, 2024, 10:42:35 AMAug 20
to scintilla-interest
Thank you for the information. We have opted to move forward with DirectWrite which resolves everything and enables font ligatures for supporting fonts. Eventually we will move to DPI Awareness, but we use Delphi which has some core issues with the newer awareness options at the moment.

Michael

Michael Staszewski

unread,
Aug 20, 2024, 11:03:21 AMAug 20
to scintilla-interest
I need to correct my statement from the initial post about SciTE seemingly not showing ligatures even when I had an appropriate font set. I thought I had set my base font to Fira Code, but may have not saved the global properties file or perhaps I had the technology still on Default. I am seeing ligatures in SciTE just fine when configured properly.

Thanks,
Michael

Reply all
Reply to author
Forward
0 new messages