PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

How to support the Chinese?

Drawing Chinese drawtext not, how can we show that this kind?
wdfwdf wrote:Drawing Chinese drawtext not, how can we show that this kind?


If you are talking about the default font (CGapiDisplay::GetSystemFont), your are right, because the image does not contain chinees characters. You have to make your own font, and after you make your GapiBitmapFont, you need to load the font with the create surface function, and after that you use the create font function with the chinees characters.

Its pritty easy and you can read about it here. http://www.gapidraw.com/docs/gapidraw/3 ... -frame.htm
I would like to use the system fonts
wdfwdf wrote:I would like to use the system fonts


Easiest way to do this is to use GetDC on a surface and draw to it using standard Win32 device context functions.

It will however be slower than using bitmapped fonts, and there might also be an overhead if the surface needs to be rotated to fit the device context.

Cheers
Johan
// CGapiSurface* m_background;
if (SUCCEEDED(m_background->GetDC(&hdcSurf;)))
{
CDC dc;
dc.Attach(hdcSurf);
//设置显示字体
dc.SetBkMode(TRANSPARENT);
CFont font;

VERIFY(font.CreateFont(
40, // nHeight
0, // nWidth
0, // nEscapement
0, // nOrientation
FW_BOLD,//FW_NORMAL, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
0, // cStrikeOut
ANSI_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
_T("宋体"))); // lpszFacename
dc.SelectObject(&font;);

//dc.SetTextColor(RGB(0,0,255)); //设置字体颜色白色
CString txt(_T("你好"));
dc.DrawText(txt,CRect(10,30,200,70),DT_LEFT);
font.DeleteObject();
m_background->ReleaseDC(hdcSurf);
}