Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BOOL NEAR PASCAL bGetName( CFontFile& file,
- tttag *pTTTag,
- IDBlock_t& ID_Block,
- LPTSTR lpszName,
- LPFONTDESCINFO lpFDI )
- {
- sfnt_pNameTable pNames;
- WORD size;
- TCHAR szSubFamily[ 64 ];
- IDBlock_t ID_DefBlock = ID_Block;
- ID_DefBlock.id_Language = (ID_DefBlock.id_Platform == PLATFORM_MS)
- ? LANG_US_ENG : 0;
- size = (WORD) SWAPL( pTTTag->dwLength );
- *lpszName = 0;
- pNames = (sfnt_pNameTable) LocalAlloc( LPTR, size );
- if( pNames )
- {
- if (ERROR_SUCCESS == file.Read(pNames, size))
- {
- //
- // The logic for what name to find:
- // If font file was converted from a Type1 font
- // 1) POSTCRIPT_ID in current language
- // else
- // 1) FACENAME_ID in current language.
- // 2) FAMILY and SUBFAMILY in current language.
- // 3) FACENAME_ID in default language.
- //
- // If the TrueType font was converted from a Type1 font, we want
- // to use the "postscript" form of the font description so that
- // it matches the description returned by IsPSFont() when invoked
- // on the "parent" Type1 file. These descriptions are used as registry
- // keys in the "Fonts" and "Type1Fonts" sections and must match.
- //
- if (bIsConvertedTrueType(pNames, ID_Block) &&
- bFindNameThing(pNames, ID_Block, POSTSCRIPT_ID, lpszName))
- {
- //
- // Replace all dashes with spaces (same as .PFM/.INF file reader code)
- //
- for (LPTSTR pc = lpszName; *pc; pc++)
- if (*pc == TEXT('-'))
- *pc = TEXT(' ');
- }
- else if( bFindNameThing( pNames, ID_Block, FACENAME_ID, lpszName ) )
- ;
- else if( bFindNameThing( pNames, ID_Block, SUBFAMILY_ID, szSubFamily )
- && (bFindNameThing( pNames, ID_Block, FAMILY_ID, lpszName )
- || bFindNameThing( pNames, ID_DefBlock, FAMILY_ID, lpszName ) ) )
- {
- lstrcat( lpszName, TEXT( " " ) );
- lstrcat( lpszName, szSubFamily );
- }
- else( bFindNameThing( pNames, ID_DefBlock, FACENAME_ID, lpszName ) )
- ;
- <some code skipped>
- }
- LocalFree( (HANDLE)pNames );
- }
- return *lpszName != 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement