如何获取系统的字体?

tg15 2005-05-19 11:53:42
我正在做一个要画图的东西,里面要输入文字,可以设置文字的字体,我又不想用CFontDialog,要自己做一个选择字体的对话框,用什么方法可获取当前系统的所有字体信息?
...全文
818 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
dongfa 2005-05-19
  • 打赏
  • 举报
回复
EnumFontFamiliesEx
bohut 2005-05-19
  • 打赏
  • 举报
回复
枚举所有字体
LOGFONT lf;
lf.lfCharSet = DEFAULT_CHARSET; // Initialize the LOGFONT structure
strcpy(lf.lfFaceName,"");
CClientDC dc (this);

//Enumerate the font families
::EnumFontFamiliesEx((HDC) dc,&lf,
(FONTENUMPROC) EnumFontFamProc,(LPARAM) this,0);

//枚举函数
int CALLBACK EnumFontFamProc(LPENUMLOGFONT lpelf,LPNEWTEXTMETRIC lpntm,DWORD nFontType,long lparam)
{
// Create a pointer to the dialog window
CDay7Dlg* pWnd = (CDay7Dlg*) lparam;
// add the font name to the list box

pWnd ->m_ctlFontList.AddString(lpelf ->elfLogFont.lfFaceName);

// Return 1 to continue font enumeration
return 1;
}
其中m_ctlFontList是一个列表控件变量
taianmonkey 2005-05-19
  • 打赏
  • 举报
回复
int CALLBACK EnumFontsProc(LPLOGFONT lplf, LPTEXTMETRIC lptm,DWORD dwStyle, LONG lParam)
{
UINT i ;

/* check to see if the font is already there right off the bat
and just continue the enumeration if it is... */


i = SendDlgItemMessage((HWND) lParam, IDC_LIST1, LB_ADDSTRING, (WPARAM) 0,
(LONG) (LPTSTR) lplf->lfFaceName) ;
return 1 ;
}

*******************************************
HDC hdc;
hdc = ::GetDC(m_hWnd);
EnumFontFamilies(hdc, (LPTSTR) NULL, (FONTENUMPROC) EnumFontsProc, (LONG) m_hWnd) ;
::ReleaseDC(m_hWnd, hdc) ;

zkxz 2005-05-19
  • 打赏
  • 举报
回复
名字为“System”的字体就是系统当前使用的字体。

2,643

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 硬件/系统
社区管理员
  • 硬件/系统社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧