When using DirectWrite - SCI_SETTECHNOLOGY(1) and leaving everything else at default, smaller text (10-20pt) is much harder to read compared to the GDI. Text is much lighter and thinner with DirectWrite and it can be problematic to look at it for a longer period of time. The main issue is that greyscale antialiasing mode is used instead of ClearType. According to MSDN Direct2D uses ClearType by default, but when the render target has alpha channel antialiasing mode gets changed to greyscale. Thankfully, this particular issue can be fixed by forcing the use of ClearType using SCI_SETFONTQUALITY(SC_EFF_QUALITY_LCD_OPTIMIZED). However, this brings us to another issue. Colors are way off when DirectWrite ClearType implementation is used compared to the GDI ClearType implementation. This is because these two different ClearType implementations use different gamma correction values (GDI usually 1.2, DirectWrite usually 2.2). Setting gamma value of DirectWrite to the same value as GDI brings us much closer to the GDI look (although text will appear a little darker since there is another parameter that controls contrast). In order to be able to change gamma value Scintilla should allow containers to set custom DirectWrite rendering parameters, particularly: gamma, enhancedContrast and clearTypeLevel parameters of IDWriteFactory::CreateCustomRenderingParams() method should be available to the container. Something like SCI_SETDWRITEGAMMA, SCI_SETDWRITEENHANCEDCONTRAST and SCI_SETCLEARTYPELEVEL. Exporting other parameters, like renderingMode would require more internal changes related to text measurement and is of no real use since the main point is to have sub pixel positioning and antialiasing.
I've attached a sample screenshot that shows the difference between text rendering using the worst case scenario - Consolas 10pt (it is the worst case since Consolas simply requires ClearType in order to look good, Visual Studio 2010 always enables ClearType for Consolas, for example). I also attached a sample patch that would set gamma value to the same level as GDI. The patch is made just to illustrate the difference between text rendering, the actual Scintilla modification should export above mentioned DirectWrite parameters and leave up to the container to change them. However, Scintilla should at least automatically activate ClearType (if enabled on user's computer) when using DirectWrite in the same way how it's automatically done by Windows when using GDI.
In my opinion ultimate goal should be to make Scintilla draw text and colors (gamma and contrast) as close to the Visual Studio 2010 as possible when using DirectWrite, since MS did make it look very nice to the eye with all the changes to the WPF and text rendering during Visual Studio 2010 development cycle.
Log in to post a comment.