Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't DirectX/DirectWrite/Direct2D text rendering be as sharp as GDI?

Tags:

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:

Larger samples:

Direct2D, aliased:

Direct2D, default:

Direct2D ("classic GDI"):

Direct2D ("natural GDI"):

Actual classic GDI:

![](http://i.stack.imgur.com/kbdPb.png)

Actual ClearType GDI:

enter image description here


Note: If all of these look blurry to you, run

document.body.style.zoom = 1 / window.devicePixelRatio 

in Chrome's console and view it afterward.

like image 239
user541686 Avatar asked Dec 23 '11 04:12

user541686


1 Answers

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.

like image 68
arx Avatar answered Oct 01 '22 13:10

arx