The font properties extension on
http://www.microsoft.com/truetype/default.asp only works for TTFs. It
doesn't appear to work on TTCs. MS Mincho is a TTC on my Win2K box.
I've appended the source code for a very simple-minded Win2K-only program
that lists the Unicode characters that map directly to a glyph in a
specified font. All the usual disclaimers apply. I can guarantee only that
it seems to work on my machine :-). Fonts can contain additional glyphs that
cannot be accessed directly in the way this program does. For example,
glyphs accessed through surrogates require a different process (call
Uniscribe's ScriptShape API). This should give a developer a good start on
building the utility that you want.
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <tchar.h>
#include "usp10.h" // Uniscribe, so requires usp10.dll
//================================================================
// Run this program with the facename of the font to dump.
int __cdecl main(int argc, char* argv[])
{
int iRet = 0;
if (argc > 1)
{
HFONT hf = CreateFont(
0, // logical height of font
0, // logical average character width
0, // angle of escapement
0, // base-line orientation angle
0, // font weight
0, // italic attribute flag
0, // underline attribute flag
0, // strikeout attribute flag
DEFAULT_CHARSET, // character set identifier
OUT_DEFAULT_PRECIS, // output precision
CLIP_DEFAULT_PRECIS, // clipping precision
DEFAULT_QUALITY, // output quality
DEFAULT_PITCH, // pitch and family
argv[1] // pointer to typeface name string
);
if (!hf)
{
fprintf(stderr, "Cannot create %s\n", argv[1]);
return 1;
}
{
HRESULT hr;
SCRIPT_CACHE sCache = 0;
SCRIPT_FONTPROPERTIES sFontProperties;
WCHAR text[256];
WORD glyphs[256];
WCHAR ch;
int i, j;
HDC hdc = GetDC(NULL);
HFONT hfOld = (HFONT)SelectObject(hdc, hf);
sFontProperties.cBytes = sizeof(sFontProperties);
hr = ScriptGetFontProperties(hdc, &sCache, &sFontProperties);
if (SUCCEEDED(hr))
{
for (j = 0; j < 256; j++)
{
ch = (WCHAR)(j << 8);
for (i = 0; i < 256; i++)
text[i] = ch | (WCHAR)i;
hr = ScriptGetCMap(hdc, &sCache, text, 256, 0, glyphs);
if (FAILED(hr))
{
fprintf(stderr, "ScriptGetCMap failed with 0x%.8x\n", hr);
iRet = 2;
break;
}
for (i = 0; i < 256; i++)
{
if (sFontProperties.wgDefault != glyphs[i])
{
fprintf(stdout, "U+%.4x\n", text[i]);
}
}
}
}
else
{
fprintf(stderr, "ScriptGetFontProperties failed with 0x%.8x\n", hr);
}
if (hfOld)
SelectObject(hdc, hfOld);
ReleaseDC(NULL, hdc);
DeleteObject(hf);
}
}
return iRet;
}
This archive was generated by hypermail 2.1.2 : Tue Jul 10 2001 - 17:21:00 EDT