使用基于freetype的FTGL,主要代码:
#include <windows.h>
#include "FTGL/ftgl.h"
static FTGLfont *fontStr;
if (fontStr == NULL) {
fontStr = ftglCreateBitmapFont("C://WINDOWS//Fonts//SIMSUN.TTC");
ftglSetFontFaceSize(fontStr, 12, 72);
ftglSetFontCharMap(fontStr, ft_encoding_unicode);
}
//处理多字节字符
nLenOfWideCharStr = MultiByteToWideChar(0, 0, s, -1, NULL, 0);
pWideCharStr = (wchar_t *)HeapAlloc(GetProcessHeap(), 0, nLenOfWideCharStr * sizeof(wchar_t));
MultiByteToWideChar(0, 0, s, -1, pWideCharStr, nLenOfWideCharStr);
ftglRenderFontW(fontStr,pWideCharStr,FTGL_RENDER_ALL);
HeapFree(GetProcessHeap(), 0, pWideCharStr);