问题
I already know that sub-pixel positioning causes DirectWrite text rendering to be blurry compared to GDI.
However, my question is a bit more fundamental: Why can't DirectWrite (and related methods) be made to render text as sharply as GDI?
In other words:
What prevents DirectWrite from being able to snap text to the nearest pixel, the way GDI can?
Is it, for example, a hardware issue? A driver architecture issue? Is it simply not implemented? Or something else?
Smaller sample:
![](https://www.eimg.top/images/2020/03/22/7cd088f766a75d916d86aa6bd6d7eb2c.png)
Larger samples:
Direct2D, aliased:
![](https://www.eimg.top/images/2020/03/22/e7160382d6a3a20c9cb34f1cda11a8a0.png)
Direct2D, default:
![](https://www.eimg.top/images/2020/03/22/18b04fadb3451fc624f74aaeeb24d925.png)
Direct2D ("classic GDI"):
![](https://www.eimg.top/images/2020/03/22/4daeb4a9457149472a60f2c871460472.png)
Direct2D ("natural GDI"):
![](https://www.eimg.top/images/2020/03/22/a10d48ac8938ea59185b28231e123e5b.png)
Actual GDI:
![](https://www.eimg.top/images/2020/03/22/6041323bcfffd236e3518b9874fb681e.png)
回答1:
You aren't comparing like with like. Your Direct2D samples are all rendered in grayscale, whereas the GDI and Linux samples are using sub-pixel anti-aliasing (aka ClearType on Windows).
This page describes what you need to do to enable cleartype: http://msdn.microsoft.com/en-us/library/windows/desktop/dd368170%28v=vs.85%29.aspx
N.B. When testing rendering like this, it's always worth using Windows Magnifier or similar to check that you are actually getting what you think you are getting.
来源:https://stackoverflow.com/questions/8612266/why-cant-directx-directwrite-direct2d-text-rendering-be-as-sharp-as-gdi