Text.h

Description: The following is code from GTest, and not part of the original Genesis3d engine

Source file: …\genesis3d\src\TEXT.H

Contents:

Globals: view

Constants: view

Types: FontType, FontStyle

Functions: Create, Destroy, GetHeight, GetWidth, Text_Out

Notes: view (none currently)

Global Variables:

static char*   Dir = "Bmp\\"; // where font decals are found
static char*   Ext = ".Bmp"; // exetension of decal files
Font_Type    Fonts[MAX_FONTS]; // font list
int32             FontLookup[MAX_SUPPORTED_CHARS]; // character lookup table
static char     FontNames[MAX_FONTS][100] = // font names
  {
      "SFont1", //this is the standard font
      "SFont2",
//this is a highlighted font
      "Console\\640x480\\font"
//this is a small console font
  };

Return to Contents

Constants:

#define MAX_SUPPORTED_CHARS 128

Return to Contents

Types:

FontType

Available fonts
typedef enum {
    Font_Default = 0,
    Font_DefaultSelect,
    Font_Small,
    MAX_FONTS
} FontType;

Return to Contents

 

FontStyle

Output styles
typedef enum {
    Style_Center = 0,
    Style_LeftJustify,
    Style_RightJustify,
} FontStyle;

Return to Contents

 

Font_Type

Font struct
typedef struct {
    geBitmap*  Bitmap;
    
int32           FontWidth; //default is 16, or 8 for Font_Small
    
int32           FontHeight; //default is 16 for all fonts
    
int32           AddWidth; // default is 13, or 7 for Font_Small
    
int32           AddHeight; // default is 21, or 18 for Font_Small
} Font_Type;

Functions:

 

geBoolean Text_Create(geEngine* SaveEngine );

Create everything required for text output.

Uses names in global variables Dir, FontNames[], Ext to open graphic font files. Information about opened fonts is stored in global Fonts[]. Note: if user specifies a different graphic font file for use, then Font[].FontWidth and Font[].FontHeight must be manual reset. Sets transparency color index value for font to be index 255.

SaveEngine: engine used for output, which gets saved

 

Return to Contents

geBoolean Text_Destroy(void ); // no parameters

Free everything

Return to Contents

int32 Text_GetWidth(FontType Font );

Get the width of a font

Font: font whose width we want

Return to Contents

int32 Text_GetHeight(FontType Font );

Get the height of a font

Font: font whose height we want

 

Return to Contents

geBoolean Text_Out(char* Text, FontType Font, int32 x, int32 y, FontStyle Style );

Output a text string.

Uses loaded bitmap fonts to put Text to screen, starting at x, y, in specified Style.

Text: string to output
Font: font to use
x: x location
y: y location
Style: output style

Return to Contents

Notes: