CharMap.EXE ( Character Map ) and GetGlyphIndices().
Re: You ( CodeGhoib ) writing something like a RichText editor,
CharMap.EXE ( Character Map ) and GetGlyphIndices()
accurately tells you what glyphs are or are not in any particular font.
Always use the Unicode ??? Character Set ???.
Internally, you only have to deal with UTF-16 Small-Byte-First.
Don't worry about surrogate pairs ( e.g. Plane One glyphs )
Files can be stored using whatever CodePage you like,
e.g. UTF-8 or, shudder, Windows-1252 .
If you're going to cache your own glyphs using DirectDraw...
You might be interested in these ( out of context ) snippetes
from X.CPP ( my hand-rolled newsreader )
in ??? www.Cotse.NET/users/jeffrelf/Games.ZIP ???:
const wchar_t Magic_UTF_16 = 0xFeFF ;
IMultiLanguage3 * Outlook ; MIMECSETINFO _Encoding ;
.......................
_Encoding.uiInternetEncoding = CP_UTF8 ;
...........
#define Eqi ! wcsicmp
Outlook->GetCharsetInfo (
! Eqi( L"ISO-8859-1", CharSet ) ? CharSet : L"Windows-1252"
, & _Encoding ) ;
..............
Encode:
int Sz = MultiByteToWideChar(
_Encoding.uiInternetEncoding
, 0 , ( __LnP ) _BLines, Sz_To_Encode, B_Sh, MaxCache );
if ( Sz_To_Encode && ! Sz ) {
_Encoding.uiInternetEncoding = CP_UTF8 ; goto Encode ; }
............
HFONT SymFnt, BassFnt, Fnt ;
int ScrRight, ScrBot, ScrLeft, ScrTop, ScrW, ScrH ;
int CacheW, CacheH ; float ScrCols, CharW, CharH ;
int I_Cache, ColsDC ;
#define IncCache I_Cache = 0, NewSur( aCache, ColsDC * CacheW, 2 * CacheH );
typedef unsigned short ushort ; typedef ushort * pUShort ;
int UseKey ;
NewSur( _SurT & Sur, int W, int H ) {
Z.dwWidth = W , Z.dwHeight = H , Z.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY ;
if ( 0 > DirectDraw->CreateSurface( & Z, & Sur, 0 ) )
Z.ddsCaps.dwCaps = DDSCAPS_TEXTURE, DirectDraw->CreateSurface( & Z, & Sur, 0 );
if ( ! Sur ) exit( 1 ); static DDCOLORKEY BlackKey ;
if ( UseKey ) Sur->SetColorKey( DDCKEY_SRCBLT, & BlackKey ); }
........
{ long R [ 4 ];
SystemParametersInfo( SPI_GETWORKAREA, 0, ( RECT * ) R, 0 );
ScrRight = R [ 2 ]; ScrBot = R [ 3 ];
R [ 2 ] -= R [ 0 ]; R [ 3 ] -= R[ 1 ];
ScrLeft = R [ 0 ]; ScrTop = R [ 1 ];
ScrW = R [ 2 ]; ScrH = R [ 3 ]; }
// ScrCols is the number of columns per screen, monospaced.
// My window is always maximized.
CharW = ScrW / ( ScrCols = 123 );
CacheW = CharW + 1, ColsDC = ScrW / CacheW ;
#define _CharH( WtoH ) ( CacheW / ( WtoH ) )
CharH = _CharH( 120. / 256 );
CacheH = CharH + 1, ScrRows = ScrH / CharH ;
Fnt = CreateFont(
CharH, 0,0,0,0,0,0,0,0,0,0,0, FIXED_PITCH, L"Consolas");
SymFnt = CreateFont(
_CharH( 128. / 256 )
, 0,0,0,0,0,0,0,0,0,0,0, FIXED_PITCH, L"MS Mincho");
..........
short Good ;
SetPtr( DC, Fnt );
// GetGlyphIndices() tells you if a font has the ??? * B ??? Glyph.
GetGlyphIndices(
DC, B, 1, pUShort( & Good ), GGI_MARK_NONEXISTING_GLYPHS );
if ( Good != -1 ) goto HaveGlyph ;
SetPtr( DC, SymFnt );
GetGlyphIndices(
DC, B, 1, pUShort( & Good ), GGI_MARK_NONEXISTING_GLYPHS );
if ( Good != -1 ) goto HaveGlyph ;
Chk( TheCache->ReleaseDC( DC ) ); return 1 ;
HaveGlyph: