PolyTextOut API – Does It Work?

As MSDN says,

The PolyTextOut function draws several strings using the font and text colors currently selected in the specified device context.

The article also mentions ExtTextOut as a simpler sister function:

To draw a single string of text, the application should call the ExtTextOut function.

It looks like the API is not so Unicode friendly. Code as simple as

PolyTextOut(L"Мама мыла раму");
PolyTextOut(L"Mother washed window");
PolyTextOut(L"ママソープフレーム");
PolyTextOut(L"დედა საპნის კარკასი");

ExtTextOut(L"Мама мыла раму");
ExtTextOut(L"Mother washed window");
ExtTextOut(L"ママソープフレーム");
ExtTextOut(L"დედა საპნის კარკასი");

Outputs correctly in case of ExtTextOut, while PolyTextOut stumbles on strings in Japanese, Georgian. All right, so why did it do Russian?

PolyTextOut Sample

One Reply to “PolyTextOut API – Does It Work?”

  1. Cody Gray from StackOverflow comments:

    I recently happened on your blog post about `PolyTextOut` while Googling for the documentation. Your blog post had me concerned about using the function, so I tested it out. I can’t reproduce your results. On a US English version of Windows 7 (also tested back on US English Win 2k), I get the correct output using `PolyTextOut`. So I’m curious what it is you were doing differently. Obviously you’d know to use a Unicode build of the app, and you have to be using a font that supports those characters, since it worked correctly for `ExtTextOut`.

    The only other thing I can think of is that Visual Studio has a known tendency to mangle source files that are not saved in ASCII format. When I tested it, I used the Unicode escapes to encode the characters (e.g., `L”\x10D3\x10D4\x10D3\x10D0\x10E1″`).

    Even though Visual Studio and non-ASCII characters is a known separate problem, I re-checked the test code in my system upgraded to Windows 8, Windows 8.1 and then to Windows 10 in the meantime since the post date. The problem is still present (same symptoms) in Windows 10 at the time of this comment.

Leave a Reply