static int setCurLogfont( int overrideSize ) { LRESULT index; char size[8]; int height; HDC hdc; FARPROC fp; if( overrideSize == 0 ) { index = SendMessage( hwndSize, CB_GETCURSEL, 0, 0L ); if( index == CB_ERR ) { return( 0 ); } SendMessage( hwndSize, CB_GETLBTEXT, index, (LPARAM)size ); height = atoi( size ); } else { height = overrideSize; } CurLogfont.lfHeight = -height; CurLogfont.lfWidth = 0; CurLogfont.lfEscapement = 0; CurLogfont.lfOrientation = 0; index = SendMessage( hwndStyle, LB_GETCURSEL, 0, 0L ); if( index == LB_ERR ) return( 0 ); CurLogfont.lfWeight = ( Style[index] & STYLE_BOLD ) ? FW_BOLD : FW_NORMAL; CurLogfont.lfItalic = ( Style[index] & STYLE_ITALIC ) ? 1 : 0; CurLogfont.lfUnderline = 0; CurLogfont.lfStrikeOut = 0; /* use defaults set below by SetupFontData */ #if 0 CurLogfont.lfCharSet = ANSI_CHARSET; CurLogfont.lfOutPrecision = OUT_DEFAULT_PRECIS; CurLogfont.lfClipPrecision = CLIP_DEFAULT_PRECIS; CurLogfont.lfQuality = PROOF_QUALITY; CurLogfont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; #endif index = SendMessage( hwndTypeface, LB_GETCURSEL, 0, 0L ); if( index == LB_ERR ) { return( 0 ); } SendMessage( hwndTypeface, LB_GETTEXT, index, (LPARAM)CurLogfont.lfFaceName ); /* set up defaults for charset, etc. from info for 1st font of this type */ hdc = GetDC( EditContainer ); fp = MakeFontEnumProcInstance( SetupFontData, InstanceHandle ); EnumFontFamilies( hdc, CurLogfont.lfFaceName, (FONTENUMPROC)fp, 0L ); FreeProcInstance( fp ); ReleaseDC( EditContainer, hdc ); return( 1 ); }
static void fillTypefaceBox( HWND hwnd ) { FARPROC fp; HDC hdc; hwnd = hwnd; /* put typefaces in combo box */ hdc = GetDC( EditContainer ); fp = MakeFontEnumProcInstance( EnumFamTypefaces, InstanceHandle ); EnumFontFamilies( hdc, NULL, (FONTENUMPROC)fp, 0L ); FreeProcInstance( fp ); ReleaseDC( EditContainer, hdc ); SendMessage( hwndTypeface, LB_SETCURSEL, 0, 0L ); }
int CALLBACK EnumFontsEnumFunc( const LOGFONT FAR *lf, const TEXTMETRIC FAR *tm, DWORD ftype, LPARAM data ) #endif { #ifdef __WINDOWS_386__ const LOGFONT __far *lf = MK_FP32( (void *)_lf ); tm = tm; #elif defined( __WINDOWS__ ) const LOGFONT FAR *lf = (const LOGFONT FAR *)elf; // const TEXTMETRIC FAR *tm = (const TEXTMETRIC FAR *)ntm; ntm = ntm; #else tm = tm; #endif ftype = ftype; data = data; /* * Something has happened in the font world and Windows font mapper since * the original source was written, it checked only for Courier. All the * font names below are verified as good monospaced fonts. Check for the * best fonts first, so that the system picks the best if enumerated first. * Changed the test to == 0, because it is easier to read and understand. */ #if defined( __NT__ ) if( FARstricmp( lf->lfFaceName, "andale mono" ) == 0 || FARstricmp( lf->lfFaceName, "lucida console" ) == 0 || FARstricmp( lf->lfFaceName, "vera sans mono" ) == 0 || FARstricmp( lf->lfFaceName, "courier new" ) == 0 || FARstricmp( lf->lfFaceName, "courier" ) == 0 ) { #else if( FARstricmp( lf->lfFaceName, "courier new" ) == 0 || FARstricmp( lf->lfFaceName, "courier" ) == 0 ) { #endif courierFont = CreateFont( 13, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, lf->lfCharSet, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, lf->lfPitchAndFamily, lf->lfFaceName ); return( 0 ); } return( 1 ); } /* EnumFunc */ /* * getCourierFont - find a mono font */ static void getCourierFont( HANDLE inst ) { LOGFONT logfont; FARPROC fp; HDC hdc; inst = inst; /* shut up the compiler for NT */ hdc = GetDC( HWND_DESKTOP ); fp = MakeFontEnumProcInstance( EnumFontsEnumFunc, inst ); #if defined( __WINDOWS__ ) && defined( _M_I86 ) EnumFonts( hdc, NULL, (OLDFONTENUMPROC)fp, 0 ); #else EnumFonts( hdc, NULL, (FONTENUMPROC)fp, 0 ); #endif FreeProcInstance( fp ); ReleaseDC( (HWND)NULL, hdc ); if( courierFont == NULL ) { courierFont = GetStockObject( ANSI_FIXED_FONT ); GetObject( courierFont, sizeof( LOGFONT ), (LPSTR)&logfont ); courierFont = CreateFontIndirect( &logfont ); } } /* getCourierFont */
static void fillInfoBoxes( HWND hwnd ) { FARPROC fp; LRESULT index; HDC hdc; char typeface[LF_FACESIZE + 1]; char size[8]; long isTrueType = 0; char oldSize[8], oldStyle[40]; static int vPitchSizes[] = { 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72 }; hwnd = hwnd; index = SendMessage( hwndStyle, LB_GETCURSEL, 0, 0L ); if( index != LB_ERR ) { SendMessage( hwndStyle, LB_GETTEXT, index, (LPARAM)oldStyle ); } else { oldStyle[0] = 0; } index = SendMessage( hwndSize, CB_GETCURSEL, 0, 0L ); if( index != CB_ERR ) { SendMessage( hwndSize, CB_GETLBTEXT, index, (LPARAM)oldSize ); } else { oldSize[0] = 0; } SendMessage( hwndStyle, LB_RESETCONTENT, 0, 0L ); SendMessage( hwndSize, CB_RESETCONTENT, 0, 0L ); NStyles = NSizes = 0; index = SendMessage( hwndTypeface, LB_GETCURSEL, 0, 0L ); if( index == LB_ERR ) { return; } fillStyleBox(); SendMessage( hwndTypeface, LB_GETTEXT, index, (LPARAM)typeface ); fp = MakeFontEnumProcInstance( EnumFamInfo, InstanceHandle ); hdc = GetDC( EditContainer ); EnumFontFamilies( hdc, typeface, (FONTENUMPROC)fp, (LPARAM)(&isTrueType) ); ReleaseDC( EditContainer, hdc ); FreeProcInstance( fp ); if( isTrueType ) { /* suggest a few truetype point values */ int nelements = sizeof( vPitchSizes ) / sizeof( vPitchSizes [0] ); if( NSizes ) { SendMessage( hwndSize, CB_RESETCONTENT, 0, 0L ); NSizes = 0; } for( index = 0; index < nelements; index++ ) { sprintf( size, "%d", vPitchSizes[index] ); if( SendMessage( hwndSize, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)size ) == CB_ERR ) { SendMessage( hwndSize, CB_INSERTSTRING, NSizes, (LPARAM)size ); NSizes++; } } } if( oldStyle[0] ) { index = SendMessage( hwndStyle, LB_SELECTSTRING, (WPARAM)-1, (LPARAM)oldStyle ); if( index == LB_ERR ) { SendMessage( hwndStyle, LB_SETCURSEL, 0, 0L ); } } if( oldSize[0] ) { index = SendMessage( hwndSize, CB_SELECTSTRING, (WPARAM)-1, (LPARAM)oldSize ); if( index == CB_ERR ) { SendMessage( hwndSize, CB_SETCURSEL, 0, 0L ); } } }