Difference between revisions of "Unit Font"

From Ultibo.org
Jump to: navigation, search
Line 19: Line 19:
 
----
 
----
  
''To be documented''
+
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''Font specific constants''' <code> FONT_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>FONT_MIN_COUNT = 256;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>FONT_MIN_WIDTH = 8;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FONT_MAX_WIDTH = 32;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>FONT_MIN_HEIGHT = 6;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FONT_MAX_HEIGHT = 64;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''Font signature constants''' <code> FONT_SIGNATURE_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>FONT_SIGNATURE = $77DE1BBC;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''Font mode constants''' <code> FONT_MODE_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>FONT_MODE_NONE = 0;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FONT_MODE_PIXEL = 1;</code>
 +
| A font with 1 bit per pixel in the character data
 +
|-
 +
| <code>FONT_MODE_ALPHA8 = 2;</code>
 +
| A font with 8 bits of alpha blending per pixel in the character data
 +
|-
 +
| <code>FONT_MODE_RGBA32 = 3;</code>
 +
| A font with 32 bits RGBA per pixel in the character data
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''Font flag constants''' <code> NAME_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>FONT_FLAG_NONE = $00000000;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FONT_FLAG_UNICODE = $00000001;</code>
 +
| Font includes a unicode translation table
 +
|-
 +
| <code>FONT_FLAG_CODEPAGE = $00000002;</code>
 +
| Font has a specified codepage
 +
|-
 +
| <code>FONT_FLAG_BIGENDIAN = $00000004;</code>
 +
| Font characters are in big endian order (Only applies to characters larger than one byte)
 +
|-
 +
| <code>FONT_FLAG_RIGHTALIGN = $00000008;</code>
 +
| Font characters are right aligned, no need to shift during load
 +
|-
 +
| <code>FONT_FLAG_VARIABLE = $00000010;</code>
 +
| Font characters are variable width rather than fixed
 +
|-
 +
|}
 +
</div></div>
 +
<br />
  
 
=== Type definitions ===
 
=== Type definitions ===

Revision as of 04:08, 25 November 2016

Return to Unit Reference


Description


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 change 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 constants FONT_SIGNATURE_*


[Expand]
Font mode constants FONT_MODE_*


[Expand]
Font flag constants NAME_*


Type definitions


To be documented

Public variables


To be documented

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; inline;
Description: Get the current font count


[Expand]
function FontGetDefault:TFontHandle; inline;
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