Difference between revisions of "Unit Font"
(3 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
---- | ---- | ||
− | '''Ultibo Font | + | '''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. | 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. | ||
Line 56: | Line 56: | ||
| <code>FONT_SIGNATURE = $77DE1BBC;</code> | | <code>FONT_SIGNATURE = $77DE1BBC;</code> | ||
| style="width: 50%;"| | | style="width: 50%;"| | ||
+ | |- | ||
+ | |} | ||
+ | </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 name''' <code> FONT_*_LENGTH </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>FONT_NAME_LENGTH = SIZE_64;</code> | ||
+ | | Length of font name | ||
+ | |- | ||
+ | | <code>FONT_DESC_LENGTH = SIZE_128;</code> | ||
+ | | Length of font description | ||
|- | |- | ||
|} | |} | ||
Line 141: | Line 155: | ||
| Font codepage (CP_ACP if not specified) | | Font codepage (CP_ACP if not specified) | ||
|- | |- | ||
− | | <code>Name:String[ | + | | <code>Name:String[63];</code> |
| Font name | | Font name | ||
|- | |- | ||
− | | <code>Description:String[ | + | | <code>Description:String[127];</code> |
| Font description | | Font description | ||
|- | |- | ||
Line 631: | Line 645: | ||
| Font flags (eg FONT_FLAG_UNICODE) | | Font flags (eg FONT_FLAG_UNICODE) | ||
|- | |- | ||
− | | <code>FontName: | + | | <code>FontName:array[0..FONT_NAME_LENGTH - 1] of Char;</code> |
| Font name | | Font name | ||
|- | |- | ||
− | | <code>FontDescription: | + | | <code>FontDescription:array[0..FONT_DESC_LENGTH - 1] of Char;</code> |
| Font description | | Font description | ||
|- | |- | ||
Line 684: | Line 698: | ||
| Font flags (eg FONT_FLAG_UNICODE) | | Font flags (eg FONT_FLAG_UNICODE) | ||
|- | |- | ||
− | | <code>FontName: | + | | <code>FontName:array[0..FONT_NAME_LENGTH - 1] of Char;</code> |
| Font name | | Font name | ||
|- | |- | ||
− | | <code>FontDescription: | + | | <code>FontDescription:array[0..FONT_DESC_LENGTH - 1] of Char;</code> |
| Font description | | Font description | ||
|- | |- | ||
Line 980: | Line 994: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
− | <pre style="border: 0; padding-bottom:0px;">function FontGetCount:LongWord | + | <pre style="border: 0; padding-bottom:0px;">function FontGetCount:LongWord;</pre> |
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current font count</div> | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current font count</div> | ||
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
Line 992: | Line 1,006: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
− | <pre style="border: 0; padding-bottom:0px;">function FontGetDefault:TFontHandle | + | <pre style="border: 0; padding-bottom:0px;">function FontGetDefault:TFontHandle;</pre> |
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current default font</div> | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current default font</div> | ||
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> |
Latest revision as of 04:58, 21 June 2023
Return to Unit Reference
Contents
[hide]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
FONT_*
FONT_SIGNATURE_*
FONT_*_LENGTH
FONT_MODE_*
FONT_FLAG_*
Type definitions
Font header
Font data
Font data 8x6
Font data 8x7
Font data 8x8
Font data 8x9
Font data 8x10
Font data 8x11
Font data 8x12
Font data 8x13
Font data 8x14
Font data 8x15
Font data 8x16
Font data 12x12
PFontData12x12 = ^TFontData12x12;
TFontData12x12 = record Data:array[0..255,0..11] of Word;
Font data 12x14
PFontData12x14 = ^TFontData12x14;
TFontData12x14 = record Data:array[0..255,0..13] of Word;
Font data 12x16
PFontData12x16 = ^TFontData12x16;
TFontData12x16 = record Data:array[0..255,0..15] of Word;
Font data 12x18
PFontData12x18 = ^TFontData12x18;
TFontData12x18 = record Data:array[0..255,0..17] of Word;
Font data 12x20
PFontData12x20 = ^TFontData12x20;
TFontData12x20 = record Data:array[0..255,0..19] of Word;
Font data 12x22
PFontData12x22 = ^TFontData12x22;
TFontData12x22 = record Data:array[0..255,0..21] of Word;
Font data 16x16
PFontData16x16 = ^TFontData16x16;
TFontData16x16 = record Data:array[0..255,0..15] of Word;
Font data 16x24
PFontData16x24 = ^TFontData16x24;
TFontData16x24 = record Data:array[0..255,0..23] of Word;
Font data 16x32
PFontData16x32 = ^TFontData16x32;
TFontData16x32 = record Data:array[0..255,0..31] of Word;
Font data 32x32
PFontData32x32 = ^TFontData32x32;
TFontData32x32 = record Data:array[0..255,0..31] of LongWord;
Font data 32x48
PFontData32x48 = ^TFontData32x48;
TFontData32x48 = record Data:array[0..255,0..47] of LongWord;
Font data 32x64
PFontData32x64 = ^TFontData32x64;
TFontData32x64 = record Data:array[0..255,0..63] of LongWord;
Font chars 8
Font chars 16
Font chars 32
Font unicode
Font properties
Font enumeration callback
TFontEnumerate = function(Handle:TFontHandle; Data:Pointer):LongWord;
|
Font entry
Public variables
None defined
Function declarations
Initialization functions
Font functions
function FontLoad(Header:PFontHeader; Data:PFontData; Size:LongWord):TFontHandle;
function FontLoadEx(Header:PFontHeader; Data:PFontData; Unicode:PFontUnicode; Size:LongWord; Properties:PFontProperties):TFontHandle;
function FontGetProperties(Handle:TFontHandle; Properties:PFontProperties):LongWord;
function FontCharWidth(Handle:TFontHandle; Character:Word):LongWord;
function FontCharHeight(Handle:TFontHandle; Character:Word):LongWord;
function FontTextWidth(Handle:TFontHandle; const Text:String):LongWord;
function FontTextHeight(Handle:TFontHandle; const Text:String):LongWord;
function FontFindByDescription(const Description:String):TFontHandle;
function FontEnumerate(Callback:TFontEnumerate; Data:Pointer):LongWord;
PSF font functions
function PSFFontLoadEx(Data:Pointer;Size:LongWord):TFontHandle;
Font helper functions
function FontSetDefault(Handle:TFontHandle):LongWord;
function FontCheck(Font:PFontEntry):PFontEntry;
Return to Unit Reference