通过提取楷体的字形轮廓可以获得汉字笔画。只不过选⽤的字体必须是楷体。其他字体不⾏。 这功能没什么⽤途吧,我只是好玩⽽已。
int GetCharStrokes(UINT ch)
青少年网球 {
HFONT hFont;
{ // create font;
空心歌词 LOGFONT lfFont;
memt(&lfFont, 0, sizeof(lfFont));
lstrcpy(lfFont.lfFaceName, "楷体_GB2312");
lfFont.lfHeight = 72;
lfFont.lfWeight = FW_NORMAL;
lfFont.lfItalic = FALSE;钢铁是怎样炼成的第一章读后感
lfFont.lfStrikeOut = FALSE;
lfFont.lfCharSet = DEFAULT_CHARSET;
lfFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
lfFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
lfFont.lfQuality = DRAFT_QUALITY;
lfFont.lfPitchAndFamily = DEFAULT_PITCH;
hFont = CreateFontIndirect(&lfFont);
}
HDC hDC = GetDC(NULL);
if (hDC==NULL) return 0;
HGDIOBJ hOldFont = SelectObject(hDC,hFont);
MAT2 mat;
memt(&mat,0,sizeof(mat));
mat.eM11.value = 1;
mat.eM22.value = -1;
驾照扣分 GLYPHMETRICS gm;
memt(&gm,0,sizeof(gm));
建树什么意思
DWORD dwSize = GetGlyphOutline(hDC,ch,GGO_NATIVE,&gm,0,NULL,&mat);
int cnt = 0;
LPVOID pBuff = NULL;
if (dwSize>0)
{
pBuff = malloc(dwSize);
memt(&gm,0,sizeof(gm));
DWORD res = GetGlyphOutline(hDC,ch,GGO_NATIVE,&gm,dwSize,pBuff,&mat);
if (res!=dwSize)
{
free(pBuff);
pBuff = NULL;
}
}
if (pBuff)
{
BYTE * ptr = (BYTE *)pBuff;
while (dwSize>0)
{
簧文秀
TTPOLYGONHEADER * header = (TTPOLYGONHEADER *)ptr;
cnt ++;
ptr += header->cb;
dwSize -= header->cb;
}
free(pBuff);
}
SelectObject(hDC,hOldFont);
ReleaDC(NULL,hDC);
return cnt;
}
测试:
union {
UINT ch;
char szText[4];
} a;
char * szText = "疆";
女性牛仔裤 a.ch = 0;
a.szText[1] = szText[0];
遥远的拼音
a.szText[0] = szText[1];
int cnt = GetCharStrokes(a.ch);
TRACE("\"%s\"的笔画%d\n",szText,cnt); 运⾏结果:
"疆"的笔画19