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:


    tsCServer  myServer=NULL;    // pointer to TypeServer instance 
    mgCBitmap  myBitmap=NULL;    // pointer to bitmap instance 
    tsCFont    myTTFont=NULL;    // pointer to TrueType font instance 
    tsCStrike  myStrike=NULL;    // pointer to strike instance
    
    // create a TypeServer instance, define a bitmap, open a TrueType font
    myServer = new tsCServer();
    myBitmap = new mgCBitmap( 1024, 768, 8, NULL );
    myTTFont = new tsCFont( tsServer, "arial.ttf", 0, 0 );

    // create a font strike 
    myStrike = new tsCStrike( tsFont, mgBitmap );
    if ( (myServer==NULL) || (myBitmap==NULL) || (myTTFont==NULL) || (myStrike==NULL) ) 
        { /* handle error condition */ }
        
    // set the text size 
    myStrike->SetTypeSize( IntToFix(12), tsPixels );

    // set the text color 
    myStrike->SetColorsRGB( 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.