I'm trying to learn about the DirectWrite API so I can get a flexible solution to the problem of rendering text from any culture, and potentially use it to incorporate rich text editing into an application with a lot more control than the "canned" ways of editing/displaying text.
The PadWrite sample looks great, and shows off how well-designed the API is - this is Microsoft's own screenshot of how it should look:
The example text includes a line that starts "Mixed scripts:" In the source code all the sample text is specified by a single C++ wchar_t[]
literal, and the mixed scripts all display correctly in Visual Studio 2012's code editor. If I copy and paste them into ordinary Windows WordPad they also display correctly. And the Arabic right-to-left section has the correct caret-navigation behaviour in both of those editors.
But none of this works when I actually run the PadWrite sample. Instead I see this:
It almost looks like it's being converted into UTF-8 and then misinterpreted (which doesn't make sense because it's all being done with wchar_t
.)
I'm running Windows 8.1. What do I need to do to make PadWrite work as well as WordPad or Visual Studio 2012? Is it a defunct sample from a pre-release version of the API that never got updated?
NB. first warning sign was that PadWrite didn't even compile at first - in the files EditableLayout.cpp
and TextEditor.cpp
I had to add this after the #include
statements:
#undef max
#undef min