Support customized fallback fonts by user when using "directwrite" to render fonts.
Problem description
In this forum post, the author reported the issue that Chinese language displayed poorly. He solved the problem by setting "theme_font_options": ["gdi"], but I don't think it's a good solution, since Sublime is migrating to DirectWrite totally recently.
After some investigation, I found the root cause is Sublime picks mixed fonts for CJK language: first from Japanese font, and then from Chinese font.
The developer said in #5 that they implement their own font fallback for DirectWrite by simply selecting from Window’s default list of fallback fonts:
Since we needed to provide support for high DPI users, and we wanted to bring font render up-to-date with the rest of Windows 8 and 10, we decided to implement our own font fallback for DirectWrite. In general, I think we do an ok job. However, we simply select from Window’s default list of fallback fonts until we find one that has the character that needs to be rendered.
However, such way doesn't work very well. The Window’s default list of fallback fonts is a dark box, we don't know how it's generated. At least, it doesn't respect system locale setting, e.g., for Simplified Chinese (Region setting), it chooses Japanese font first.
The text area of file content also has the same issue.
Preferred solution
I suggest Sublime add a new option named like "fallback_font": "", so that user can specify their own preferred fallback font, which will be much more controlled. If the option is not set, Sublime can still selects fallback font from system default.
Alternatives
For gdi rendering, we may use font link in Registry to customize fallback font, but it doesn't work for directwrite.
Additional Information (optional)
Also very much looking forward to the implementation of this feature! Most of the time, a beautiful English font, and no beautiful Chinese part...
I chose to install the font Microsoft YaHei Mono to solve this, this requirement may be too small... Almost no one responded.
Just to update this with more recent info, the forum post in question was discussing Sublime text 3 beta and 3.0. At that point we were using Skia to draw text on Windows. We were using some of the Skia APIs to try and provide info about font fallback, but the Skia implementation didn't allow us to do everything we needed, and in some places provided for poor performance.
In the dev cycle for Sublime Text 3.1 (build 3176) we added a custom font shaping and rendering library that uses DirectWrite or GDI based on user settings. This now utilizes CreateTextLayout() for DirectWrite. We don't have any way within Sublime Text to customize font fallback, but it should theoretically use whatever Windows has configured.
If Sublime Text 3.1+ isn't falling back properly, it may be that DirectWrite needs configuration of this API in some way to make the fallback happen.
According to http://www.unicode.org/mail-arch/unicode-ml/y2013-m07/0068.html, the default font fallback rules are not user-configurable for DirectWrite. There are some APIs starting in Windows 8.1 that allow configuring font fallbacks in C++, but it would require us implementing things in the Sublime Text codebase to make it happen.
This would probably need to be part of a larger investigation into how such functionality would be implemented on Linux and Mac, and how to handle Windows 7.