ホーム » Windows » EnumFontFam…Proc

2023年10月
1234567
891011121314
15161718192021
22232425262728
293031  

カテゴリー

アーカイブ

ブログ統計情報

  • 80,677 アクセス



EnumFontFam…Proc

CALLBACK で呼び出されたものを FontType で分類して文字列の配列に登録.

#include	<Windows.h>

class	EnumFont	{
public:
	static	int	CALLBACK	CB_EnumFontFam		(const ENUMLOGFONT*   lpelf_,const NEWTEXTMETRIC*   lpntm_,DWORD font_type,LPARAM lparam) ;
	static	int	CALLBACK	CB_EnumFontFamEx	(const ENUMLOGFONTEX* lpelfe,const NEWTEXTMETRICEX* lpntme,DWORD font_type,LPARAM lparam) ;
protected:
public:
	v_tstring	Font_________ ;		//	0
	v_tstring	Font_raster__ ;		//	1	RASTER_FONTTYPE
	v_tstring	Font_device__ ;		//	2	DEVICE_FONTTYPE
	v_tstring	Font_truetype ;		//	4	TRUETYPE_FONTTYPE
	} ;

inline	int	CALLBACK	EnumFont::CB_EnumFontFam	(const ENUMLOGFONT*   lpelf_,const NEWTEXTMETRIC*   lpntm_,DWORD font_type,LPARAM p_this)
{
	const	LOGFONT&	lf = lpelf_->elfLogFont ;
	EnumFont*	pthis = (EnumFont*)p_this ;
	if      (font_type & RASTER_FONTTYPE)	{	pthis->Font_raster__.push_back(lf.lfFaceName) ;		}
	else if (font_type & TRUETYPE_FONTTYPE)	{	pthis->Font_truetype.push_back(lf.lfFaceName) ;		}
	else if (font_type & DEVICE_FONTTYPE)	{	pthis->Font_device__.push_back(lf.lfFaceName) ;		}
	else                                    	{	pthis->Font_________.push_back(lf.lfFaceName) ;		}
	return	1 ;
	}

inline	int	CALLBACK	EnumFont::CB_EnumFontFamEx	(const ENUMLOGFONTEX* lpelfe,const NEWTEXTMETRICEX* lpntme,DWORD font_type,LPARAM p_this)
{
	const	LOGFONT&	lf = lpelfe->elfLogFont ;
	EnumFont*	pthis = (EnumFont*)p_this ;
	if      (font_type & RASTER_FONTTYPE)	{	pthis->Font_raster__.push_back(lf.lfFaceName) ;		}
	else if (font_type & TRUETYPE_FONTTYPE)	{	pthis->Font_truetype.push_back(lf.lfFaceName) ;		}
	else if (font_type & DEVICE_FONTTYPE)	{	pthis->Font_device__.push_back(lf.lfFaceName) ;		}
	else                                    	{	pthis->Font_________.push_back(lf.lfFaceName) ;		}
	return	1 ;
	}

次の様に呼出し.

bool	test	(void)
{
	HWND	hWnd = ::GetConsoleWindow() ;
	HDC	hdc = ::GetDC(hWnd);
	{
		EnumFont	ef_ ;
		EnumFont	efe ;
		{
			::EnumFontFamilies  (hdc,NULL,(FONTENUMPROC)EnumFont::CB_EnumFontFam,  (LPARAM)&ef_) ;
			::EnumFontFamiliesEx(hdc,NULL,(FONTENUMPROC)EnumFont::CB_EnumFontFamEx,(LPARAM)&efe,0) ;
			}
		{
			tstring	tmp_path = ::Get_i_Tools_tmp_date() ;
			tstring	fet_name = ::Path_AddLastSP(tmp_path) + ::Now_Format(_T("%H%M%S")) + _T("_ffe_t.txt") ;
			tstring	fer_name = ::Path_AddLastSP(tmp_path) + ::Now_Format(_T("%H%M%S")) + _T("_ffe_r.txt") ;
			tstring	fed_name = ::Path_AddLastSP(tmp_path) + ::Now_Format(_T("%H%M%S")) + _T("_ffe_d.txt") ;
			tstring	fe__name = ::Path_AddLastSP(tmp_path) + ::Now_Format(_T("%H%M%S")) + _T("_ffe__.txt") ;
			tstring	f_t_name = ::Path_AddLastSP(tmp_path) + ::Now_Format(_T("%H%M%S")) + _T("_ff__t.txt") ;
			tstring	f_r_name = ::Path_AddLastSP(tmp_path) + ::Now_Format(_T("%H%M%S")) + _T("_ff__r.txt") ;
			tstring	f_d_name = ::Path_AddLastSP(tmp_path) + ::Now_Format(_T("%H%M%S")) + _T("_ff__d.txt") ;
			tstring	f___name = ::Path_AddLastSP(tmp_path) + ::Now_Format(_T("%H%M%S")) + _T("_ff___.txt") ;
			::SaveText(fet_name.c_str(),efe.Font_truetype) ;
			::SaveText(fer_name.c_str(),efe.Font_raster__) ;
			::SaveText(fed_name.c_str(),efe.Font_device__) ;
			::SaveText(fe__name.c_str(),efe.Font_________) ;
			::SaveText(f_t_name.c_str(),ef_.Font_truetype) ;
			::SaveText(f_r_name.c_str(),ef_.Font_raster__) ;
			::SaveText(f_d_name.c_str(),ef_.Font_device__) ;
			::SaveText(f___name.c_str(),ef_.Font_________) ;
			}
		}
	::ReleaseDC(NULL,hdc);
	return	true ;
	}

これで出力したもの.
EnumFontFam...Proc  FontType

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

1件のコメント

  1. […] EnumFont… を調べていて,::IsFontInstalled を見つけた. MFC 6 位に追加されたみたいだが,static 宣言されている. VC 6 RTM では存在していなさそう. 正確なタイミングはわからないが,VC 6 SP6 には存在していて …MFCSRCCCDATA.CPP にある, フォントがインストールされているかのチェックに利用できそうなので,関数として定義予定. […]

コメントは停止中です。

%d人のブロガーが「いいね」をつけました。