⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subject_24939.htm

📁 一些关于vc的问答
💻 HTM
字号:
<p>
序号:24939 发表者:赵付强 发表日期:2002-12-17 21:06:08
<br>主题:请问如何编程获知系统中可用的字体?
<br>内容:小弟先谢过了!<BR>
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:tjhe 回复日期:2002-12-17 22:01:01
<br>内容:可使用SDK的如下一些函数(具体使用可参见msdn)<BR><BR>EnumFonts(....)<BR>EnumFontsProc(...)<BR>EnumFontFamilies(....)<BR><BR>.......<BR><BR><BR>msdn中的例子(参考):<BR>UINT uAlignPrev; <BR>&nbsp;&nbsp;&nbsp;&nbsp;int aFontCount[] = { 0, 0, 0 }; <BR>&nbsp;&nbsp;&nbsp;&nbsp;char szCount[8]; <BR> <BR>&nbsp;&nbsp;&nbsp;&nbsp;EnumFontFamilies(hdc, (LPCTSTR) NULL, <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(FONTENUMPROC) EnumFamCallBack, (LPARAM) aFontCount); <BR> <BR>&nbsp;&nbsp;&nbsp;&nbsp;uAlignPrev = SetTextAlign(hdc, TA_UPDATECP); <BR> <BR>&nbsp;&nbsp;&nbsp;&nbsp;MoveToEx(hdc, 10, 50, (LPPOINT)NULL); <BR>&nbsp;&nbsp;&nbsp;&nbsp;TextOut(hdc, 0, 0, "Number of raster fonts: ", 24); <BR>&nbsp;&nbsp;&nbsp;&nbsp;itoa(aFontCount[0], szCount, 10); <BR>&nbsp;&nbsp;&nbsp;&nbsp;TextOut(hdc, 0, 0, szCount, strlen(szCount)); <BR> <BR>&nbsp;&nbsp;&nbsp;&nbsp;MoveToEx(hdc, 10, 75, (LPPOINT)NULL); <BR>&nbsp;&nbsp;&nbsp;&nbsp;TextOut(hdc, 0, 0, "Number of vector fonts: ", 24); <BR>&nbsp;&nbsp;&nbsp;&nbsp;itoa(aFontCount[1], szCount, 10); <BR>&nbsp;&nbsp;&nbsp;&nbsp;TextOut(hdc, 0, 0, szCount, strlen(szCount)); <BR> <BR>&nbsp;&nbsp;&nbsp;&nbsp;MoveToEx(hdc, 10, 100, (LPPOINT)NULL); <BR>&nbsp;&nbsp;&nbsp;&nbsp;TextOut(hdc, 0, 0, "Number of TrueType fonts: ", 26); <BR>&nbsp;&nbsp;&nbsp;&nbsp;itoa(aFontCount[2], szCount, 10); <BR>&nbsp;&nbsp;&nbsp;&nbsp;TextOut(hdc, 0, 0, szCount, strlen(szCount)); <BR> <BR>&nbsp;&nbsp;&nbsp;&nbsp;SetTextAlign(hdc, uAlignPrev); <BR> <BR>BOOL CALLBACK EnumFamCallBack(LPLOGFONT lplf, LPNEWTEXTMETRIC lpntm, DWORD FontType, LPVOID aFontCount) <BR>{ <BR>&nbsp;&nbsp;&nbsp;&nbsp;int far * aiFontCount = (int far *) aFontCount; <BR> <BR>&nbsp;&nbsp;&nbsp;&nbsp;// Record the number of raster, TrueType, and vector <BR>&nbsp;&nbsp;&nbsp;&nbsp;// fonts in the font-count array. <BR> <BR>&nbsp;&nbsp;&nbsp;&nbsp;if (FontType &amp; RASTER_FONTTYPE) <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;aiFontCount[0]++; <BR>&nbsp;&nbsp;&nbsp;&nbsp;else if (FontType &amp; TRUETYPE_FONTTYPE) <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;aiFontCount[2]++; <BR>&nbsp;&nbsp;&nbsp;&nbsp;else <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;aiFontCount[1]++; <BR> <BR>&nbsp;&nbsp;&nbsp;&nbsp;if (aiFontCount[0] || aiFontCount[1] || aiFontCount[2]) <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return TRUE; <BR>&nbsp;&nbsp;&nbsp;&nbsp;else <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return FALSE; <BR> <BR>&nbsp;&nbsp;&nbsp;&nbsp;UNREFERENCED_PARAMETER( lplf ); <BR>&nbsp;&nbsp;&nbsp;&nbsp;UNREFERENCED_PARAMETER( lpntm ); <BR>} <BR> <BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -