13 : _pDir( (PTTFDirectory)NULL ), _hfMemo( NULL ), _Size( 0 ), _nFonts( 0 )
19 : _pDir( (PTTFDirectory)NULL ), _hfMemo( NULL ), _Size( 0 ), _nFonts( 0 )
22 Load( hModule, Id, Type );
34 if (!hModule) hModule = GetModuleHandle( NULL );
38 _hfMemo = _pDir ? AddFontMemResourceEx( _pDir, _Size, NULL, (
DWORD*)&_nFonts ) : NULL;
40 if (_hfMemo) _getTypeface();
41 return (_hfMemo != NULL);
51 void TTResFont::_freeFontMem()
55 RemoveFontMemResourceEx( _hfMemo );
60 bool TTResFont::_getTypeface()
66 PTTFDirEntry pNameTbl = NULL;
67 UINT ix = 0, nTbl =
_bswap16( _pDir->NrTables );
70 PTTFDirEntry pEntry = &_pDir->Entry[ix];
82 ULONG tblOffs =
_bswap32( pNameTbl->Offset );
83 PTTFNames pNames = PTTFNames(
PBYTE(_pDir) + tblOffs );
87 USHORT nNames =
_bswap16( pNames->NrNames );
91 PTTFNameRec pRec = &pNames->Names[ix];
97 USHORT strOffs =
_bswap16( pNames->Offset );
98 USHORT nameOffs =
_bswap16( pRec->Offset );
99 USHORT nameLen =
_bswap16( pRec->Length );
HFONT WINAPI CreateFontEx(CSTR Typeface, int Points, int Weight, DWORD Charset=ANSI_CHARSET, DWORD Quality=ANTIALIASED_QUALITY)
UINT16 __cdecl _bswap16(UINT16 Val)
bool Load(HMODULE hModule, CSTR Id, CSTR Type)
HFONT CreateFont(int Points, int Weight, DWORD CharSet=ANSI_CHARSET, DWORD Quality=ANTIALIASED_QUALITY)
UINT32 __cdecl _bswap32(UINT32 Val)
PVOID WINAPI LoadCustomResource(HMODULE hModule, CSTR Id, CSTR Type, UINT *pSize OPTOUT=NULL)
TCHAR TypeFace[LF_FACESIZE]