2

I'm attempting to render the following text using the ExtTextOut function with the Courier New font:

C₁C₂C²C³

The superscript characters show up fine, but the subscript characters show up as blocks. If I use the DrawText function, then the subscript characters show up fine.

I was under the impression that DrawText internally calls ExtTextOut. Am I mistaken or does DrawText perform some extra processing of the string to allow subscript characters to show up?

Is there anything I can do to get ExtTextOut to display the subscript characters using the Courier New font?

My code for using ExtTextOut looks like this:

ExtTextOutW(hdc,x,y,0,0,szText,wcslen(szText),0);
flashk
  • 2,451
  • 2
  • 20
  • 31

2 Answers2

3

As Hans noted in a comment, DrawText() is nowadays implemented using font linking, but it would appear that ExtTextOut() is not.

If you really want this to work reliably, you'll probably have to do font linking yourself. Some code of mine that solves a similar problem: TextOutput C++ class

DavidK
  • 3,929
  • 1
  • 19
  • 26
1

If you get rectangles instead of glyphs then the problem is the font you are using. It doesn't have the necessary glyph. Common on XP for example, I don't have it installed anymore to check. Use the Windows charmap.exe applet to find a suitable font. The subscript 2 is Unicode codepoint '\x2082'.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • I am aware of this. Selecting a different (e.g. Segoe UI) will display the subscript characters. However, why does the DrawText function display the subscript characters, even when using the Courier New font? Does the DrawText function perform some extra font substitutions? – flashk Apr 12 '11 at 23:18
  • 1
    That API function dates from the stone age, it might not implement the font linking feature. Not sure, I haven't used it in ages. Backgrounder is here: http://msdn.microsoft.com/en-us/goglobal/bb688134.aspx – Hans Passant Apr 12 '11 at 23:38