Recommended Approach for Drawing Text RRS feed

  • Question

  • Hey all.  I'm wanting to write a terminal emulator that runs as a Windows Store app.  I was originally going to try using an HTML 5 canvas, but its text rendering is kinda weird.  Which leaves me with using a Windows API of some kind.

    Right now, I'm tempted to resort to delving into 2D rendering with DirectX only because I can't find any real graphics API exposed in the Windows Store API's.  Can anyone recommend an alternative approach?  I have thought about Silverlight, but I'm not too familiar with it.  I'd consider it if it would be easier/more portable than trying to mess with DirectX.

    Keep in mind that I would like to be able to use system fonts and let users pick what font to use, so something that has access to the Windows fonts in some form or fashion with the ability to get font metrics would be <del>absolutely necessary</del> ideal.

    Thanks for your time!

    • Edited by nogh0st Thursday, April 11, 2013 1:02 PM
    Thursday, April 11, 2013 1:01 PM

All replies

  • It depends on what exactly you need for the text rendering.

    DirectWrite provides the most advanced font rendering by far. If HTML is too "weird" for you then you probably need to use DirectWrite to get more control. DirectWrite is the only way to enumerate the fonts on the system, but once you have done that you can load the fonts in Xaml by name.

    Silverlight is not supported for Windows Store apps. Windows.UI.Xaml provides simple access to basic text rendering, but doesn't expose all of the advanced capabilities that DirectWrite does.


    Saturday, April 13, 2013 6:39 AM
  • Thanks, Rob. HTML is "weird" for me because it doesn't render at (0, 0) like I think it will/should. In my opinion it should start by drawing the top left of the character bounding box at (0, 0) but it doesn't for some reason. I haven't found any good documentation on the fillText() method for the 2D canvas context so far. I'll mess around with DirectWrite and Xaml and see how it goes. I'd like it to be portable between device platforms, so I don't know if DirectWrite will do the trick since (from what I've seen) you have to use native C++. The biggest thing I need is the ability to move a (custom rendered) block cursor around the screen. Thanks again!
    Saturday, April 13, 2013 2:34 PM