back TypeServer QuickTour next
Step 3 - Open a TrueType Font

TypeServer can operate with TrueType fonts stored either in a disk file, or that are preloaded into memory or ROM(1).  A separate function is provided for each case.  tsFont_OpenFile() opens a TrueType font stored on disk, and tsFont_OpenMemory() opens a TrueType font that resides in memory or ROM.  Here is an example of how we open a TrueType font file:


    TSSERVER  myServer=NULL;    /* TypeServer-handle       */
    TSFONT    myTTFont=NULL;    /* TrueType font-handle    */
    
    /* create a TypeServer instance */
    tsServer_Create( &myServer );
    
    /* open a TrueType font file */
    tsFont_OpenFile( myServer, "arial.ttf", 0, 0, &myTTFont );
    if ( (myServer == NULL) || (myTTFont == NULL) )
        { /* handle error condition */ }

That's all there is to opening a TrueType font.  Upon return, the font-handle contains a instance identifier that is used when calling other TypeServer funtions.

TypeServer can have multiple fonts open at the same time if your application needs to display text that combines multiple fonts or typefaces.  For example, Arial normal, Arial-Bold, Times-Roman and Symbol TrueType fonts could all be opened for processing.  Any number of fonts can be open at one time if your application requires mixed rendering of multiple fonts.

TypeServer Font

next»


NOTES:
1 -  The TypeServer Developer Kit includes "TypeEmbedder", a utility program that allows you to convert TrueType font files (.ttf) into C header files (.h) that can be compiled directly with your program or stored into ROM.
2 -  The third and fourth arguments in the tsFont_OpenFile() function call are the fileOffset and fontNumber parameters, respectively.  fileOffset is used if the TrueType font is embedded within a larger resource file, and specifies a byte offset to where the TrueType font actually begins within the file.  fontNumber specifies the font number if the TrueType file is a "collection" containing more than one font.  These paramenters are used infrequently and are normally set to zero (but they're there if you need them).

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

Copyright © 1999-2001 - Metagraphics Software Corporation.