summaryrefslogtreecommitdiff
path: root/fpcsrc/packages/palmunits/src/font.pp
blob: a9a11bdcea216189b681341e7ef8b9aabac0acda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
(******************************************************************************
 *
 * Copyright (c) 1994-2000 Palm, Inc. or its subsidiaries.
 * All rights reserved.
 *
 * File: Font.h
 *
 * Release: Palm OS SDK 4.0 (63220)
 *
 * Description:
 *   This file defines font structures and routines.
 *
 * History:
 *    09/13/94 art   Created by Art Lamb.
 *    05/05/98 art   Add structures for font mapping table.
 *    07/03/98 kwk   Added FntWidthToOffset.
 *    10/23/98 kwk   Changed fontMapTable to 0xC000 (was 0xFFFF).
 *    10/20/99 kwk   Moved private values to FontPrv.h
 *    05/12/00 kwk   Added FntWCharWidth.
 *
 *****************************************************************************)
{$MACRO ON}
unit font;

interface

uses palmos, coretraps;

// Pixel width of tab stops in fields
const
  fntTabChrWidth = 20;

// Width of character missing from font.
const
  fntMissingChar = -1;

type
  FontCharInfoType = record
  {$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_FONTS} // These fields will not be available in the next OS release!
    offset: Int8;
    width: Int8;
  {$endif}
  end;
  FontCharInfoTag = FontCharInfoType;
  FontCharInfoPtr = ^FontCharInfoType;

type
  FontType = record
  {$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_FONTS} // These fields will not be available in the next OS release!
    fontType: Int16;    // font type
    firstChar: Int16;   // ASCII code of first character
    lastChar: Int16;    // ASCII code of last character
    maxWidth: Int16;    // maximum character width
    kernMax: Int16;     // negative of maximum character kern
    nDescent: Int16;    // negative of descent
    fRectWidth: Int16;  // width of font rectangle
    fRectHeight: Int16; // height of font rectangle
    owTLoc: Int16;      // offset to offset/width table
    ascent: Int16;      // ascent
    descent: Int16;     // descent
    leading: Int16;     // leading
    rowWords: Int16;    // row width of bit image / 2
  {$endif}
  end;
  FontTag = FontType;
  FontPtr = ^FontType;
  FontTablePtr = ^FontPtr;

type
  FontID = Enum;

const
  stdFont = $00;                    // Small font used for the user's writing.  Shows a good amount
  boldFont = Succ(stdFont);         // Small font.  Bold for easier reading.  Used often for ui.
  largeFont = Succ(boldFont);       // Larger font for easier reading.  Shows a lot less.
  symbolFont = Succ(largeFont);     // Various ui images like check boxes and arrows
  symbol11Font = Succ(symbolFont);  // Larger various ui images
  symbol7Font = Succ(symbol11Font); // Smaller various ui images
  ledFont = Succ(symbol7Font);      // Calculator specific font
  largeBoldFont = Succ(ledFont);    // A thicker version of the large font.  More readable.
  fntAppFontCustomBase = $80;       // First available application-defined font ID

const
  checkboxFont = symbol11Font;

function FntIsAppDefined(fnt: FontID): Boolean;

//--------------------------------------------------------------------
//
// Font Function
//
//--------------------------------------------------------------------

function FntGetFont: FontID; syscall sysTrapFntGetFont;

function FntSetFont(font: FontID): FontID; syscall sysTrapFntSetFont;

function FntGetFontPtr: FontPtr; syscall sysTrapFntGetFontPtr;

function FntBaseLine: Int16; syscall sysTrapFntBaseLine;

function FntCharHeight: Int16; syscall sysTrapFntCharHeight;

function FntLineHeight: Int16; syscall sysTrapFntLineHeight;

function FntAverageCharWidth: Int16; syscall sysTrapFntAverageCharWidth;

function FntCharWidth(ch: Char): Int16; syscall sysTrapFntCharWidth;

function FntWCharWidth(iChar: WChar): Int16; syscall sysTrapFntWCharWidth;

function FntCharsWidth(const chars: PChar; len: Int16): Int16; syscall sysTrapFntCharsWidth;

function FntWidthToOffset(const pChars: PChar; length: UInt16; pixelWidth: Int16; var leadingEdge: Boolean; var truncWidth: Int16): Int16; syscall sysTrapFntWidthToOffset;

procedure FntCharsInWidth(const AString: PChar; var stringWidthP, stringLengthP: Int16;
                          var fitWithinWidth: Boolean); syscall sysTrapFntCharsInWidth;

function FntDescenderHeight: Int16; syscall sysTrapFntDescenderHeight;

function FntLineWidth(const pChars: PChar; length: UInt16): Int16; syscall sysTrapFntLineWidth;

function FntWordWrap(const chars: PChar; maxWidth: UInt16): UInt16; syscall sysTrapFntWordWrap;

procedure FntWordWrapReverseNLines(const chars: PChar; maxWidth: UInt16; var linesToScrollP, scrollPosP: UInt16); syscall sysTrapFntWordWrapReverseNLines;

procedure FntGetScrollValues(const chars: PChar; width, scrollPos: UInt16; var linesP, topLine: UInt16); syscall sysTrapFntGetScrollValues;

function FntDefineFont(font: FontID; fontP: FontPtr): Err; syscall sysTrapFntDefineFont;

implementation

function FntIsAppDefined(fnt: FontID): Boolean;
begin
  FntIsAppDefined := fnt >= fntAppFontCustomBase;
end;

end.