1
\$\begingroup\$

I need to render highly readable text, on par with DirectWrite+Cleartype+Truetype. The Cleartype system uses sub-pixel anti-aliasing. DirectWrite takes things a step further and moves letters around slightly (sub-pixel positioning, pixel snapping, etc.) to maximize readability and minimize distortions. This was important enough that every major web browser uses DirectWrite on Windows.

The obvious plan (with major shortcomings) is to render DirectWrite to a texture with cleartype disabled (because sub-pixel AA doesn't lend itself to transforms) and pixel snapping disabled (because that pixel "grid" is meaningless after transformation.) Unfortunately the text will look worse than it could if glyphs are enlarged or shrunk, and of course the lack of pixel snapping will hurt readability.

Ignoring performance, is there a higher quality way to draw warped text in Windows?

Edit: removed comment about disabling AA (DWRITE_RENDERING_MODE_ALIASED).

\$\endgroup\$
4
  • \$\begingroup\$ In which way are you warping the text, and is it 2D or 3D text? \$\endgroup\$ Mar 25, 2015 at 22:36
  • \$\begingroup\$ 2D only. Good question. The distortions include all the cheesy things you've seen amateurs do with text. Making one side of the string larger, making the string into a semi-circle, making the middle letters smaller based on a curve, etc. \$\endgroup\$
    – Sophit
    Mar 25, 2015 at 22:39
  • \$\begingroup\$ How large will this text be on screen? DirectWrite (and similar systems) will make a big difference in very small text, such as body text on a web page, but its benefits are less dramatic when it comes to larger text, such as titles (which is usually the only place where one would even consider warping, which is why I ask) \$\endgroup\$ Mar 26, 2015 at 0:48
  • \$\begingroup\$ Both large and small. Unfortunately even small text may be warped, and needs to be readable. \$\endgroup\$
    – Sophit
    Mar 26, 2015 at 19:25

1 Answer 1

1
\$\begingroup\$

DirectWrite appears to support drawing glyphs directly

Provides a low-level glyph rendering API for those who employ proprietary text layout and Unicode-to-glyph processing

Using this feature you would be able to load the glyphs from a font using the windows GDI function GetGlyphOutline, morph the quadratic bezier curve for your text and finally render these directly without missing any of the clear-type benefits.

You could also use a utility like Fontforge to convert your font into a simpler format like SVG.

\$\endgroup\$
4
  • \$\begingroup\$ You're referring to DrawGlyphRun which does give some useful information. I looked over that, but it appears I'd have to dig into TrueType data format to render the glyphs myself. That's a major undertaking, from what I understand. Did you have some insight I missed? \$\endgroup\$
    – Sophit
    Mar 25, 2015 at 23:12
  • \$\begingroup\$ @Sophit I've been looking into rendering them as 3d objects, basically the fonts are just bezier curves, windows has functions that load the glyphs for you however, I added more details in my answer \$\endgroup\$ Mar 26, 2015 at 7:54
  • \$\begingroup\$ Good idea. Do you know if it's possible to get sub-pixel positioning information out of DirectWrite? Their API appears under-documented. \$\endgroup\$
    – Sophit
    Mar 26, 2015 at 19:30
  • \$\begingroup\$ @Sophit As far as I know it should be enabled as long as its enabled by the end user in Windows, but I could be wrong about that \$\endgroup\$ Mar 26, 2015 at 20:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .