home *** CD-ROM | disk | FTP | other *** search
- /***********************************************************/
- /* */
- /* Amiga C Encyclopedia (ACE) V3.0 Amiga C Club (ACC) */
- /* ------------------------------- ------------------ */
- /* */
- /* Book: ACM Graphics Amiga C Club */
- /* Chapter: Include Fonts Tulevagen 22 */
- /* File: Example.c 181 41 LIDINGO */
- /* Author: Anders Bjerin SWEDEN */
- /* Date: 92-05-01 */
- /* Version: 1.10 */
- /* */
- /* Copyright 1992, Anders Bjerin - Amiga C Club (ACC) */
- /* */
- /* Registered members may use this program freely in their */
- /* own commercial/noncommercial programs/articles. */
- /* */
- /***********************************************************/
-
-
- /* This is an example on how you can "include" a font in your */
- /* 'C' code. See file "PrintFont.c" for more information. */
- /* */
- /* This example consists of two files which should be compiled */
- /* separately and then linked together. The first file is this */
- /* one, and consists of the program code itself. The second */
- /* file is called "FontFile.c" and was created by PrintFont, */
- /* and contains all information about the font. */
-
-
- /* Include all Intuition declarations: */
- #include <intuition/intuition.h>
-
-
-
-
-
- /* Note that you do not need to open the DiskFont Library in this */
- /* example. It is only when you try to load a new font the library */
- /* has to be open. */
-
- struct Intuition *IntuitionBase = NULL; /* Running under Intuition. */
- struct GfxBase *GfxBase = NULL; /* Move() and Text(). */
-
-
- /* Declare a pointer to a Window structure: */
- struct Window *my_window = NULL;
-
- /* Declare and initialize your NewWindow structure: */
- struct NewWindow my_new_window=
- {
- 0, /* LeftEdge x position of the window. */
- 20, /* TopEdge y positio of the window. */
- 450, /* Width 450 pixels wide. */
- 55, /* Height 55 lines high. */
- 0, /* DetailPen Text should be drawn with colour reg. 0 */
- 1, /* BlockPen Blocks should be drawn with colour reg. 1 */
- NULL, /* IDCMPFlags No IDCMP flags */
- SMART_REFRESH| /* Flags Intuition should refresh the window. */
- WINDOWDRAG| /* Drag gadget. */
- WINDOWDEPTH| /* Depth arrange Gadgets. */
- ACTIVATE, /* The window should be Active when opened. */
- NULL, /* FirstGadget No Custom gadgets. */
- NULL, /* CheckMark Use Intuition's default CheckMark. */
- "IncludeFonts V1.0 Anders Bjerin Amiga C Club", /* Title */
- NULL, /* Screen Connected to the Workbench Screen. */
- NULL, /* BitMap No Custom BitMap. */
- 0, /* MinWidth No sizing gadget. */
- 0, /* MinHeight -"- */
- 0, /* MaxWidth -"- */
- 0, /* MaxHeight -"- */
- WBENCHSCREEN /* Type Connected to the Workbench Screen. */
- };
-
-
-
- /* The text font structure which is defined */
- /* in the other file ("FontFile"): */
- extern struct TextFont NewsletterFont;
-
-
-
- /* Declare our functions: */
- void main( );
- void clean_up( STRPTR );
-
-
-
- void main( )
- {
- /* Open the necessary libraries: */
-
- /* Open the Intuition Library: */
- IntuitionBase = (struct IntuitionBase *)
- OpenLibrary( "intuition.library", 0 );
- if( !IntuitionBase )
- clean_up( "Could not open Intuition library!" );
-
- /* Open the Graphics library: */
- GfxBase = (struct GfxBase *)
- OpenLibrary( "graphics.library", 0 );
- if( !GfxBase )
- clean_up( "Could not open Graphics library!" );
-
-
-
-
-
- /* Open a window in which we will display the new font: */
- my_window = (struct Window *) OpenWindow( &my_new_window );
-
- /* Have we opened the window succesfully? */
- if(my_window == NULL)
- clean_up( "Could not open the window!" );
-
-
-
- /* Set colour and draw mode: */
- SetAPen( my_window->RPort, 1 );
- SetDrMd( my_window->RPort, JAM1 );
-
-
- /* This is the only thing you have to do */
- /* once you have converted the font! */
- /* Change the window's default font: */
- SetFont( my_window->RPort, &NewsletterFont );
-
-
- /* Position the cursor, and print some characters: */
- Move( my_window->RPort, 10, 38 );
- Text( my_window->RPort, "This font is great!", 22 );
-
-
- /* Wait 5 seconds: */
- Delay( 50 * 5 );
-
-
-
- /* The End: */
- clean_up( "" );
- }
-
-
-
- /* Clears and quits: */
- void clean_up( STRPTR message )
- {
- /* Close the window: */
- if( my_window )
- CloseWindow( my_window );
-
- /* Close the Graphics Library: */
- if( GfxBase )
- CloseLibrary( GfxBase );
-
- /* Close the IntuitionLibrary: */
- if( IntuitionBase )
- CloseLibrary( IntuitionBase );
-
- /* Print any message: */
- printf( "%s\n", message );
-
- /* Quit: */
- exit();
- }
-
-