OkfInitialize

Initialize the OKF Font Engine.

int OkfInitialize( GPDRAWSURFACE *pSurfaces, int *pCurSurface );

Routine Required Header
OkfInitialize "okf.h", <gpgraphic.h>
 

Libraries

OKLIB.A Oankali's GP32 run-time library
 

Return Value

In case of success OkfInitialize returns 0, otherwise it returns -1. Look at okf.lastError for details on what happened.


Parameters

pSurfaces

A pointer to an array of GP32 surfaces.

pCurSurface

A pointer to the integer variable that holds the current surface (usually the back screen if there is more than one surface).


Remarks

The OkfInitialize function initializes the OKF Font Engine setting all members of okf to their default, and creating an empty font list pointed by okf.pFonts. It also creates a default alpha blending look up table of 32 levels of precision (32KB).
If there is not enough memory, an error occurs.

Pointers of the screen surface structures and of the current surface are used by all printing functions.

If the OKF Font Engine is already initialized, the font list is not created, but all members of okf are set to their defaults and screen pointers are updated. Alpha LUT members are left as is.

If you need to set the font engine to its default state, call OkfSetToDefaults instead of OkfInitialize. If you need to update screen pointers, update okf.pSurfaces and okf.pCurSurface members instead of calling OkfInitialize.

If you want to change the precision of the alpha LUT to save memory usage, use OkfInitializeAlphaLUT.


Example

#include <gpstdlib.h>
#include <gpgraphic.h>
#include "okf.h"
...

GPDRAWSURFACE gtSurface[2];
int giSurface;

void GpMain(void *arg)
{
  // Init graphics mode and surfaces
  ...

  // Initialize OKF Font Engine
  if (OkfInitialize(gtSurface, &giSurface) == -1)
  {
    switch (okf.lastError)
    {
      case ...
    }
  }

  // Register fonts
  ...

  // Follow with the execution of the program
  ...

  // Terminate OKF Font Engine
  OkfTerminate();

  // Exit program
  GpAppExit();
}


See Also

OKF Font Engine Routines, OKF Font Engine Constants, OkfInitializeAlphaLUT, OkfSetToDefaults, OkfTerminate