Unit Font

From Ultibo.org
Jump to: navigation, search

Return to Unit Reference


Description


Ultibo Font Interface unit

The fonts supported by Ultibo are a bitmap format that contains a block of data where each character is represented by a number of consecutive bytes.

Fonts can either be statically compiled as a pascal unit and loaded during startup or can be dynamically loaded by passing a header and data block to the FontLoad() function. A Font Builder tool is available to convert common bitmap font formats into a pascal unit for compiling with a project.

For an 8x16 (8 pixels wide and 16 pixels high) font the data contains 8 bits (1 byte) for each of the 16 rows that make up a character and each character would be 16 bytes long.

For a 12x22 font the data contains 12 bits padded to 16 bits (2 bytes) for each of the 22 rows that make up a character. Therefore each character would be 44 bytes in length.

This unit can support any size font from 8x6 to 32x64 including every combination in between. For fonts where the bits per row is greater than one byte both little endian and big endian format is supported. Allowance has been made for including a Unicode translation table with each font so that writing of Unicode text to the console can be supported as well as an extended bitmap format where character data includes alpha or color information or both. These features are yet to be fully implemented.

Constants



[Expand]
Font specific constants FONT_*


[Expand]
Font signature FONT_SIGNATURE_*


[Expand]
Font name FONT_*_LENGTH


[Expand]
Font mode FONT_MODE_*


[Expand]
Font flag FONT_FLAG_*


Type definitions



Font header

[Expand]

PFontHeader = ^TFontHeader;

TFontHeader = record

Font data

[Expand]

PFontData = ^TFontData;

TFontData = record

Font data 8x6

[Expand]

PFontData8x6 = ^TFontData8x6;

TFontData8x6 = record Data:array[0..255,0..5] of Byte;

Font data 8x7

[Expand]

PFontData8x7 = ^TFontData8x7;

TFontData8x7 = record Data:array[0..255,0..6] of Byte;

Font data 8x8

[Expand]

PFontData8x8 = ^TFontData8x8;

TFontData8x8 = record Data:array[0..255,0..7] of Byte;

Font data 8x9

[Expand]

PFontData8x9 = ^TFontData8x9;

TFontData8x9 = record Data:array[0..255,0..8] of Byte;

Font data 8x10

[Expand]

PFontData8x10 = ^TFontData8x10;

TFontData8x10 = record Data:array[0..255,0..9] of Byte;

Font data 8x11

[Expand]

PFontData8x11 = ^TFontData8x11;

TFontData8x11 = record Data:array[0..255,0..10] of Byte;

Font data 8x12

[Expand]

PFontData8x12 = ^TFontData8x12;

TFontData8x12 = record Data:array[0..255,0..11] of Byte;

Font data 8x13

[Expand]

PFontData8x13 = ^TFontData8x13;

TFontData8x13 = record Data:array[0..255,0..12] of Byte;

Font data 8x14

[Expand]

PFontData8x14 = ^TFontData8x14;

TFontData8x14 = record Data:array[0..255,0..13] of Byte;

Font data 8x15

[Expand]

PFontData8x15 = ^TFontData8x15;

TFontData8x15 = record Data:array[0..255,0..14] of Byte;

Font data 8x16

[Expand]

PFontData8x16 = ^TFontData8x16;

TFontData8x16 = record Data:array[0..255,0..15] of Byte;

Font data 12x12

[Expand]

PFontData12x12 = ^TFontData12x12;

TFontData12x12 = record Data:array[0..255,0..11] of Word;

Font data 12x14

[Expand]

PFontData12x14 = ^TFontData12x14;

TFontData12x14 = record Data:array[0..255,0..13] of Word;

Font data 12x16

[Expand]

PFontData12x16 = ^TFontData12x16;

TFontData12x16 = record Data:array[0..255,0..15] of Word;

Font data 12x18

[Expand]

PFontData12x18 = ^TFontData12x18;

TFontData12x18 = record Data:array[0..255,0..17] of Word;

Font data 12x20

[Expand]

PFontData12x20 = ^TFontData12x20;

TFontData12x20 = record Data:array[0..255,0..19] of Word;

Font data 12x22

[Expand]

PFontData12x22 = ^TFontData12x22;

TFontData12x22 = record Data:array[0..255,0..21] of Word;

Font data 16x16

[Expand]

PFontData16x16 = ^TFontData16x16;

TFontData16x16 = record Data:array[0..255,0..15] of Word;

Font data 16x24

[Expand]

PFontData16x24 = ^TFontData16x24;

TFontData16x24 = record Data:array[0..255,0..23] of Word;

Font data 16x32

[Expand]

PFontData16x32 = ^TFontData16x32;

TFontData16x32 = record Data:array[0..255,0..31] of Word;

Font data 32x32

[Expand]

PFontData32x32 = ^TFontData32x32;

TFontData32x32 = record Data:array[0..255,0..31] of LongWord;

Font data 32x48

[Expand]

PFontData32x48 = ^TFontData32x48;

TFontData32x48 = record Data:array[0..255,0..47] of LongWord;

Font data 32x64

[Expand]

PFontData32x64 = ^TFontData32x64;

TFontData32x64 = record Data:array[0..255,0..63] of LongWord;

Font chars 8

[Expand]

PFontChars8 = ^TFontChars8;

TFontChars8 = array[0..0] of Byte;

Font chars 16

[Expand]

PFontChars16 = ^TFontChars16;

TFontChars16 = array[0..0] of Word;

Font chars 32

[Expand]

PFontChars32 = ^TFontChars32;

TFontChars32 = array[0..0] of LongWord;

Font unicode

[Expand]

PFontUnicode = ^TFontUnicode;

TFontUnicode = record

Font properties

[Expand]

PFontProperties = ^TFontProperties;

TFontProperties = record

Font enumeration callback

TFontEnumerate = function(Handle:TFontHandle; Data:Pointer):LongWord;

Font entry

[Expand]

PFontEntry = ^TFontEntry;

TFontEntry = record


Public variables


None defined

Function declarations



Initialization functions

[Expand]
procedure FontInit;
Description: To be documented


Font functions

[Expand]
function FontLoad(Header:PFontHeader; Data:PFontData; Size:LongWord):TFontHandle;
Description: Load a Font from a font data block and add to the Font table


[Expand]
function FontLoadEx(Header:PFontHeader; Data:PFontData; Unicode:PFontUnicode; Size:LongWord; Properties:PFontProperties):TFontHandle;
Description: Load a Font from a font data block and add to the Font table


[Expand]
function FontUnload(Handle:TFontHandle):LongWord;
Description: To be documented


[Expand]
function FontGetName(Handle:TFontHandle):String;
Description: To be documented


[Expand]
function FontGetDescription(Handle:TFontHandle):String;
Description: To be documented


[Expand]
function FontGetWidth(Handle:TFontHandle):LongWord;
Description: To be documented


[Expand]
function FontGetHeight(Handle:TFontHandle):LongWord;
Description: To be documented


[Expand]
function FontGetProperties(Handle:TFontHandle; Properties:PFontProperties):LongWord;
Description: To be documented


[Expand]
function FontCharWidth(Handle:TFontHandle; Character:Word):LongWord;
Description: To be documented


[Expand]
function FontCharHeight(Handle:TFontHandle; Character:Word):LongWord;
Description: To be documented


[Expand]
function FontTextWidth(Handle:TFontHandle; const Text:String):LongWord;
Description: To be documented


[Expand]
function FontTextHeight(Handle:TFontHandle; const Text:String):LongWord;
Description: To be documented


[Expand]
function FontFindByName(const Name:String):TFontHandle;
Description: To be documented


[Expand]
function FontFindByDescription(const Description:String):TFontHandle; 
Description: To be documented


[Expand]
function FontEnumerate(Callback:TFontEnumerate; Data:Pointer):LongWord;
Description: To be documented


PSF font functions

[Expand]
function PSFFontLoad(const FileName:String):TFontHandle;
Description: To be documented


[Expand]
function PSFFontLoadEx(Data:Pointer;Size:LongWord):TFontHandle;
Description: To be documented


Font helper functions

[Expand]
function FontGetCount:LongWord;
Description: Get the current font count


[Expand]
function FontGetDefault:TFontHandle;
Description: Get the current default font


[Expand]
function FontSetDefault(Handle:TFontHandle):LongWord;
Description: Set the current default font


[Expand]
function FontCheck(Font:PFontEntry):PFontEntry;
Description: Check if the supplied Font is in the Font table


Return to Unit Reference