/* %kw # %v %n %d %t # */ /* Version # 5 MWFONT.C 29-Apr-96 11:36:52 # */ /**********************************************************/ /* METAGRAPHICS SOFTWARE CORPORATION (c) 1987-1992 */ /* */ /* Description: This program is an example of how to */ /* manually load a font and make it active. */ /* */ /* Functions used: FileQuery, FileLoad, SetFont, TextSize */ /**********************************************************/ #include #include #include #include "metawndo.h" /* master MetaWINDOW include file */ /* special stack size declaration if using Turbo or Borland C++ */ #ifdef TurboC extern unsigned _stklen = 14336U; /* stack size 14K */ #endif void main( int argc, char *argv[] ) { rect scrnR; int i,loadErr; int GrafixCard; dirRec dirRcd; /* file directory record */ fontRcd *original, *font1Ptr, *font2Ptr, *font3Ptr, *font4Ptr; grafPort *screenPort; /* let user specify video mode from command line */ GrafixCard = FindUserDisplay( argc, argv ); if( GrafixCard == 0 ) { /* no command line selection, auto detect best video */ GrafixCard = FindBestDisplay( 640, 480, 16 ); } /* init the system */ i = InitGraphics( GrafixCard ); if( i != 0 ) { printf("InitGraphics Error %d\n", i); exit(i); } /* save original font buffer pointer */ GetPort( &screenPort ); original = screenPort->txFont; /* - - - Load SYSTEM08.FNT - - - - - - - - - - */ /* locate the font and get its info */ loadErr = FileQuery( "SYSTEM08.FNT", &dirRcd, 1); if ( loadErr != 1 ) { printf("SYSTEM08.FNT file not found - %d\n", loadErr); exit(1); } /* allocate a buffer for the font */ font1Ptr = (fontRcd *)malloc( (Word)dirRcd.fileSize ); if ( font1Ptr == NULL ) { printf("Memory allocation error1\n"); exit(1); } /* load the font into the buffer */ loadErr = FileLoad( "SYSTEM08.FNT", font1Ptr, (Word)dirRcd.fileSize ); if ( loadErr < 0 ) { printf("FileLoad1 error=%d\n",loadErr); exit(1); } /* - - - Load SYSTEM16.FNT - - - - - - - - - - */ /* locate the font and get its info */ loadErr = FileQuery( "SYSTEM16.FNT", &dirRcd, 1); if ( loadErr != 1 ) { printf("SYSTEM16.FNT file not found - %d\n", loadErr); exit(1); } /* allocate a buffer for the font */ font2Ptr = (fontRcd *)malloc( (Word)dirRcd.fileSize ); if ( font2Ptr == NULL ) { printf("Memory allocation error2\n"); exit(1); } /* load the font into the buffer */ loadErr = FileLoad( "SYSTEM16.FNT", font2Ptr, (Word)dirRcd.fileSize ); if ( loadErr < 0 ) { printf("FileLoad2 error=%d\n",loadErr); exit(1); } /* - - - Load EXTSYS16.FNT - - - - - - - - - - */ /* locate the font and get its info */ loadErr = FileQuery( "EXTSYS16.FNT", &dirRcd, 1); if ( loadErr != 1 ) { printf("EXTSYS16.FNT file not found - %d\n", loadErr); exit(1); } /* allocate a buffer for the font */ font3Ptr = (fontRcd *)malloc( (Word)dirRcd.fileSize ); if ( font3Ptr == NULL ) { printf("Memory allocation error2\n"); exit(1); } /* load the font into the buffer */ loadErr = FileLoad( "EXTSYS16.FNT", font3Ptr, (Word)dirRcd.fileSize ); if ( loadErr < 0 ) { printf("FileLoad3 error=%d\n",loadErr); exit(1); } /* - - - Load ROMANSIM.FNT - - - - - - - - - - */ /* locate the font and get its info */ loadErr = FileQuery( "ROMANSIM.FNT", &dirRcd, 1); if ( loadErr != 1 ) { printf("ROMANSIM.FNT file not found - %d\n", loadErr); exit(1); } /* allocate a buffer for the font */ font4Ptr = (fontRcd *)malloc( (Word)dirRcd.fileSize ); if ( font4Ptr == NULL ) { printf("Memory allocation error2\n"); exit(1); } /* load the font into the buffer */ loadErr = FileLoad( "ROMANSIM.FNT", font4Ptr, (Word)dirRcd.fileSize ); if ( loadErr < 0 ) { printf("FileLoad4 error=%d\n",loadErr); exit(1); } ScreenRect(&scrnR); /* get the screen dimensions */ SetDisplay(GrafPg0); /* switch to graphics mode */ EraseRect(&scrnR); /* erase the screen */ TextSize(14,14); /* Set text size for stroked font, ROMANSIM.FNT */ /* Set font 1 active */ SetFont( font1Ptr ); MoveTo(10,130); DrawString("Text output using SYSTEM08.FNT"); /* Set font 2 active */ SetFont( font2Ptr ); MoveTo(10,150); DrawString("Text output using SYSTEM16.FNT"); /* Set font 3 active */ SetFont( font3Ptr ); MoveTo(10,170); DrawString("Text output using EXTSYS16.FNT"); /* Set font 4 active */ SetFont( font4Ptr ); MoveTo(10,190); DrawString("Text output using ROMANSIM.FNT"); /* Set original font active */ SetFont( original ); MoveTo(10,210); DrawString("Text output using original system font"); MoveTo(10,20); DrawString("press return to terminate"); getch(); SetDisplay(TextPg0); i=QueryError(); printf("QueryError=%d/%d",i >> 7,i & 127); StopGraphics(); exit(i); } #include "metfind.c" /* End of File - MWFONT.C */