開発環境 Microsoft Visual Studio Community 2017
実行環境 Windows 10 Home (64bit)
プロジェクトの種類 Visual C++/空のプロジェクト
プロジェクト名 dw_fontglyph

dw_fontglyph.cpp
// Unicode文字セット
 
#pragma comment(lib, "dwrite")
 
#include <dwrite.h>
#include <stdio.h>
 
template <class T> inline void SafeRelease(T **ppT)
{
	if (*ppT) {
		(*ppT)->Release();
		*ppT = NULL;
	}
}
 
int wmain(int argc, LPWSTR argv[])
{
	if (argc != 2) {
		fwprintf(stderr, L"usage: dw_fontglyph unicode\n");
		return 1;
	}
 
	UINT32 unicodeValue = wcstol(argv[1], NULL, 16);
 
	HRESULT hr;
	IDWriteFactory* pDWriteFactory = NULL;
	hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory),
		reinterpret_cast<IUnknown**>(&pDWriteFactory));
 
	IDWriteFontCollection* pFontCollection = NULL;
	hr = pDWriteFactory->GetSystemFontCollection(&pFontCollection);
 
	UINT32 familyCount = pFontCollection->GetFontFamilyCount();
 
	UINT32 count = 0;
	for (UINT32 i = 0; i < familyCount; i++) {
		IDWriteFontFamily* pFontFamily = NULL;
		hr = pFontCollection->GetFontFamily(i, &pFontFamily);
 
		IDWriteFont* pFont = NULL;
		hr = pFontFamily->GetFirstMatchingFont(DWRITE_FONT_WEIGHT_NORMAL,
			DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STYLE_NORMAL, &pFont);
 
		BOOL exists;
		hr = pFont->HasCharacter(unicodeValue, &exists);
 
		if (exists) {
			count++;
 
			IDWriteLocalizedStrings* pFamilyNames = NULL;
			hr = pFontFamily->GetFamilyNames(&pFamilyNames);
 
			WCHAR name[32];
			hr = pFamilyNames->GetString(0, name, _countof(name));
 
			wprintf(L"%s\n", name);
 
			SafeRelease(&pFamilyNames);
		}
 
		SafeRelease(&pFont);
		SafeRelease(&pFontFamily);
	}
	wprintf(L"U+%04X ( %u / %u )\n", unicodeValue, count, familyCount);
 
	SafeRelease(&pFontCollection);
	SafeRelease(&pDWriteFactory);
	return 0;
}
 

実行例
C:\Projects\vc++\dw_fontglyph\Debug>dw_fontglyph fdfd
Arial
Calibri
Microsoft Sans Serif
Segoe UI
Tahoma
Times New Roman
Amiri
Amiri Quran
Noto Naskh Arabic
Noto Naskh Arabic UI
Noto Sans Arabic
Noto Sans Arabic UI
U+FDFD ( 12 / 146 )
 
C:\Projects\vc++\dw_fontglyph\Debug>dw_fontglyph 1f000
Segoe UI Emoji
Segoe UI Symbol
U+1F000 ( 2 / 146 )
 
C:\Projects\vc++\dw_fontglyph\Debug>dw_fontglyph 1f0a1
Segoe UI Symbol
DejaVu Sans
U+1F0A1 ( 2 / 146 )
 
最終更新:2019年01月26日 21:23