The OKF Font Engine is the most advanced font technology actually available for the GP32. This font engine that leans on OKF Fonts will help you in the task of displaying text on your GP32 program with the possibility of applying some interesting special effects to change in real-time the appearance of the font.
The OKF Font Engine is easy to use and, hopefully, should not give to much headaches to new programmers :).
The OKF Font Engine is based on a structure of type OKFENGINE, that is pointed by the global variable okf declared in okf.h, and through which the programmer will set properties that will dictate the behaviour of the printing functions, like font selection, text justification, character and line spacing, or real-time special effects.
okf.x and okf.y always points to the actual cursor position and are automatically updated by the font engine. The programmer can set the position by setting manually these properties or by calling the correct printing function.
Once properties have been correctly settled, all the following calls to the OKF Font Engine functions will be submitted to these properties.
Besides the printing functions, the OKF Font Engine also incorporates functions to load, register or clone fonts, to apply permanent special effects on a font, to split a text in multiple lines, to get the width and height of a given text, to automatically paint a background behind a text, and other more technical functions useful for font manager programs.
The first function call of the OKF Font Engine must be OkfInitialize, and if you want to be purist you should call OkfTerminate to release memory resources allocated by the font engine. If you call a function prior to initialize the font engine, an error will be returned in okf.lastError.
The majority of functions in the OKF Font Engine return -1 in case of error. But if you want to know exactly what happened look at okf.lastError that always contains the last error code returned by any function of the font engine. For other return codes, look at each function individually.
OKF Font Engine Routines
Routine | Use |
OkfApplyEffect | Apply a definitive special effect on a registered font |
OkfClone | Clone a registered font and register it under a new handle |
OkfGetCurrentFont | Get the OKFFONT pointer of the current font |
OkfGetEmbeddedFontHandle | Get the handle of a registered font given the address of an OKF Font file in memory |
OkfGetFont | Get the OKFFONT pointer of a given registered font |
OkfGetFontChar | Get the OKFCHAR pointer of a given font character |
OkfGetHandle | Get the handle of a registered font given the pointer of its OKFFONT structure |
OkfGetTextHeight | Get the total height in pixels of a string taking into account the properties in okf |
OkfGetTextSize (v2) | Get the total height and width in pixels of a string taking into account the properties in okf |
OkfGetTextWidth | Get the total width in pixels of a string taking into account the properties in okf |
OkfInitialize (v2*) | Initialise the OKF Font Engine |
OkfInitializeAlphaLUT (v2) | Initialise manually the alpha blending look up table |
OkfLoadAndRegister | Load an OKF Font file located in the SMC card and register it |
OkfPaintBackground (v2) | Paint manually a background behind a string taking into account the properties in okf |
OkfPaintBackgroundAt (v2) | Paint manually a background behind a string at a given position taking into account the properties in okf |
OkfPrint | Print a string taking into account the properties in okf |
OkfPrintAt | Print a string at a given position taking into account the properties in okf |
OkfPrintChar | Print a single character taking into account the properties in okf |
OkfPrintCharAt | Print a single character at a given position taking into account the properties in okf |
OkfPrintLong | Print a formatted number taking into account the properties in okf |
OkfPrintLongAt | Print a formatted number at a given position taking into account the properties in okf |
OkfRegister | Register an OKF Font given a pointer to an OKF Font located in memory. Usually used for embedded fonts |
OkfRelease | Drop a registered font from the OKF Font Engine font list and release the allocated resources |
OkfSetToDefaults | Set all properties of the okf global variable to their default values |
OkfSplitLines | Split a text in multiple lines given a width and taking into account the properties in okf |
OkfTerminate | Release resources allocated by the OKF Font Engine |
v2: new in version 2
v2*: updated in version 2
Related files
OKF File Format Specification, OKF Font Engine and OKF File Format GP32 License
See Also
OKF Font Engine Structures, OKF Font Engine Constants, List Routines