back TypeServer QuickTour next
Step 4 - Create a Font Strike

A font Strike is the actual object that is used for drawing text.  In creating a strike, you select a TrueType font and a target bitmap.  A default set of rendering attributes for character size, color, alignment position, etc. are set when the strike is initially created.  Your application can issue calls to change rendering attributes at any time before issuing text drawing calls.  Here is how to create a font strike and set some basic attributes for text size and color:


    TSSERVER  myServer=NULL;    /* TypeServer-handle       */
    MGBITMAP  myBitmap=NULL;    /* bitmap-handle           */
    TSFONT    myTTFont=NULL;    /* TrueType font-handle    */
    TSSTRIKE  myStrike=NULL;    /* strike-handle           */
    
    /* create a TypeServer instance, define a bitmap, open a TrueType font */
    tsServer_Create( &myServer );
    mgBitmap_CreateDirect( 1024, 768, 8, NULL, &myBitmap );
    tsFont_OpenFile( myServer, "arial.ttf", 0, 0, &myTTFont );

    /* create a font strike */
    tsStrike_Create( myTTFont, myBitmap, &myStrike );
    if ( (myServer==NULL) || (myBitmap==NULL) || (myTTFont==NULL) || (myStrike==NULL) ) 
        { /* handle error condition */ }
        
    /* set the text size */
    tsStrike_SetTypeSize( myStrike, IntToFix(12), tsPixels );

    /* set the text color */
    tsStrike_SetColorsRGB( myStrike, RGB_Make(0,0,0), RGB_Make(255,255,255) );

Just as you can have multiple fonts open at one time, a single font can have multiple strikes defined at one time.  For example, once a TypeServer instance is created and an Arial font is opened, several different strikes could be created for rendering text for different size characters and/or to different bitmaps.  A single Arial font, for example, could have one strike defined for rendering characters to one bitmap at 10-point @ 96DPI, and another strike defined for rendering to a different bitmap at 16-point @ 300DPI.

TypeServer Strike

next»


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

Copyright © 1999-2001 - Metagraphics Software Corporation.