我尝试使用 Courier New
字体的 >ExtTextOut 函数:
C₁C₂C²C³
上标字符显示正常,但下标字符显示为块。如果我使用 DrawText
< /a> 函数,则下标字符显示正常。
我的印象是 DrawText
内部调用 ExtTextOut
。我是错了还是 DrawText
对字符串执行一些额外的处理以允许下标字符显示?
我能做些什么来获取 ExtTextOut< /code>
使用 Courier New
字体显示下标字符?
我使用 ExtTextOut
< 的代码/a> 看起来像这样:
ExtTextOutW(hdc,x,y,0,0,szText,wcslen(szText),0);
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);
发布评论
评论(2)
正如 Hans 在评论中指出的那样,DrawText() 现在是使用字体链接实现的,但 ExtTextOut() 似乎不是。
如果您确实希望它可靠地工作,您可能必须自己进行字体链接。我的一些代码解决了类似的问题: TextOutput C++ 类
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
如果您得到的是矩形而不是字形,那么问题就出在您使用的字体上。它没有必要的字形。例如在XP上很常见,我没有再安装它来检查。使用 Windows charmap.exe 小程序查找合适的字体。下标 2 是 Unicode 代码点“\x2082”。
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'.