開発環境 |
Microsoft Visual Studio Community 2015 |
実行環境 |
Windows 10 Home (64bit) |
プロジェクトの種類 |
Win32 Console Application |
プロジェクト名 |
fontlist |
アプリケーションの種類 |
Console application |
追加のオプション |
Empty project, SDL checks |
fontlist.cpp
#include <Windows.h>
#include <fcntl.h>
#include <io.h>
#include <stdio.h>
#include <set>
#include <string>
using namespace std;
typedef set<wstring> SFN;
SFN sfn;
int CALLBACK EnumFontFamExProc(const LOGFONT *lpelfe, const TEXTMETRIC *lpntme, DWORD FontType, LPARAM lParam)
{
if (sfn.find(lpelfe->lfFaceName) == sfn.end()) {
sfn.insert(lpelfe->lfFaceName);
}
return 1;
}
int wmain()
{
_setmode(_fileno(stdout), _O_WTEXT);
HDC hdc = GetDC(NULL);
LOGFONT lf = {0};
lf.lfCharSet = DEFAULT_CHARSET;
EnumFontFamiliesEx(hdc, &lf, EnumFontFamExProc, 0, 0);
ReleaseDC(NULL, hdc);
for (SFN::const_iterator it = sfn.begin(); it != sfn.end(); it++) {
wprintf(L"%s\n", it->c_str());
}
return 0;
}
実行結果(抜粋)
メイリオ
游ゴシック
游ゴシック Light
游ゴシック Medium
游明朝
游明朝 Demibold
游明朝 Light
MS ゴシック
MS 明朝
MS Pゴシック
MS P明朝
最終更新:2016年06月28日 05:53