back TypeServer QuickTour   next
Step 6 - Terminate, Close Instances

Once we're finished using a TypeServer component we need to close it.  In this simple example we'll close everything prior to exiting:


    TSSERVER  myServer=NULL;    /* TypeServer-handle          */
    MGBITMAP  myBitmap=NULL;    /* bitmap-handle              */
    TSFONT    myTTFont=NULL;    /* TrueType font-handle       */
    TSSTRIKE  myStrike=NULL;    /* strike-handle              */
    FIXPOINT  fxPoint;          /* fixed-point x,y-coordinate */
         
    /* create a TypeServer, define a bitmap, open a font, create a strike */
    tsServer_Create( &myServer );
    mgBitmap_CreateDirect( 1024, 768, 8, NULL, &myBitmap );
    tsFont_OpenFile( myServer, "arial.ttf", 0, 0, &myTTFont );
    tsStrike_Create( myFont, myBitmap, &myStrike );
    if ( (myServer==NULL) || (myBitmap==NULL) || (myTTFont==NULL) || (myStrike==NULL) ) 
        { /* handle error conidition */ }
        
    /* set text size and color */
    tsStrike_SetTypeSize( myStrike, IntToFix(12), tsPixels );
    tsStrike_SetColorsRGB( myStrike, RGB_Make(0,0,0), RGB_Make(255,255,255) );

    /* draw "Hello World" starting at pixel location (80.0, 100.0) */
    fxPoint.x = IntToFix(80);
    fxPoint.y = IntToFix(100);
    tsStrike_DrawString( myStrike, &fxPoint, "Hello World" );
    
    /* close strike, font, bitmap and server instances */
    tsStrike_Destroy( &myStrike );
    tsFont_Destroy(   &myTTFont );
    tsBitmap_Destroy( &myBitmap );
    tsServer_Destroy( &myServer );

As you can see TypeServer is quite easy to use.  But there's much more you can do.  For more information on TypeServer programming and use, please see the TypeServer Programming Reference Manual.

TypeServer objects

next»


Home | Products | Order | Register | Support | Company | Contact | Feedback

Copyright © 1999-2001 - Metagraphics Software Corporation.