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 ;
}