summaryrefslogtreecommitdiff
path: root/packages/amunits/src/otherlibs/ttengine.pas
blob: 32befd66f9c637bbfc2a2c74a625a2afa15548a7 (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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
{
  This file is part of the Free Pascal run time library.

  A file in Amiga system run time library.
  Copyright (c) 2003 by Nils Sjöholm.
  member of the Amiga RTL development team.

  This is a unit for ttengine.library

  See the file COPYING.FPC, included in this distribution,
  for details about the copyright.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

**********************************************************************}
{
  History:

  First version of this unit.
  16 Jan 2003.

  Changed cardinal > longword.
  Changed startcode for unit.
  12 Feb 2003.

  nils.sjoholm@mailbox.swipnet.se Nils Sjoholm
}

{$mode objfpc}

UNIT TTENGINE;

INTERFACE
USES Exec,utility,agraphics;

VAR TTEngineBase : pLibrary = nil;

const
    TTENGINENAME : PChar = 'ttengine.library';


  { $VER: ttengine.h 6.0 (3.1.2003) (c) by Grzegorz Kraszewski 2002.  }

  const

     TTENGINEVERSION = 6;
     TTENGINEMINVERSION = 3;
  { Tags  }
  { Tags applicability legend:  }
  { O - TT_OpenFont()  }
  { G - TT_GetAttrs()  }
  { S - TT_SetAttrs()  }
  { P - TT_GetPixmap()  }
  { ---- name -------------------- value ----- applicability  }
  { OG..  }
     TT_FontFile = $6EDA0000;
  { OG..  }
     TT_FontStyle = $6EDA0001;
     TT_FontStyle_Regular = 0;
     TT_FontStyle_Italic = 1;
  { O...  }
     TT_FamilyTable = $6EDA0002;
  { OG..  }
     TT_FontSize = $6EDA0003;
  { OG..  }
     TT_FontWeight = $6EDA0004;
     TT_FontWeight_Normal = 400;
     TT_FontWeight_Bold = 700;
  { O...  }
     TT_ColorMap = $6EDA0005;
  { O...  }
     TT_Screen = $6EDA0006;
  { O...  }
     TT_Window = $6EDA0007;
  { .G..  }
     TT_FontAscender = $6EDA0008;
  { .G..  }
     TT_FontDescender = $6EDA0009;
  { .GSP  }
     TT_Antialias = $6EDA000F;
     TT_Antialias_Auto = 0;
     TT_Antialias_Off = 1;
     TT_Antialias_On = 2;
  { .GSP  }
     TT_Encoding = $6EDA0010;
  { supported  }
  { use ENV:ttfcodepage or ISO-8859-1 if not found  }
     TT_Encoding_Default = 0;
  { Western Europe and US  }
     TT_Encoding_ISO8859_1 = 4;
  { Eastern Europe  }
     TT_Encoding_ISO8859_2 = 5;
     TT_Encoding_ISO8859_3 = 6;
     TT_Encoding_ISO8859_4 = 7;
     TT_Encoding_ISO8859_5 = 8;
     TT_Encoding_ISO8859_6 = 9;
     TT_Encoding_ISO8859_7 = 10;
     TT_Encoding_ISO8859_8 = 11;
     TT_Encoding_ISO8859_9 = 12;
     TT_Encoding_ISO8859_10 = 13;
     TT_Encoding_ISO8859_11 = 14;
     TT_Encoding_ISO8859_13 = 109;
     TT_Encoding_ISO8859_14 = 110;
     TT_Encoding_ISO8859_15 = 111;
     TT_Encoding_ISO8859_16 = 112;
     TT_Encoding_UTF16_BE = 1013;
     TT_Encoding_UTF32_BE = 1018;
     TT_Encoding_UTF8 = 106;
     TT_Encoding_UTF16_LE = 1014;
     TT_Encoding_UTF32_LE = 1019;
     TT_Encoding_UTF16 = 1015;
     TT_Encoding_UTF32 = 1017;
  { .G..  }
     TT_FontName = $6EDA0011;
  { .G..  }
     TT_FamilyName = $6EDA0012;
  { .G..  }
     TT_SubfamilyName = $6EDA0013;
  { .GS.  from 0 to 255  }
     TT_Transparency = $6EDA0014;
  { O.SP  single precision floating point +- 0.01 to 100  }
     TT_ScaleX = $6EDA0015;
  { O.SP  single precision floating point +- 0.01 to 100  }
     TT_ScaleY = $6EDA0016;
  { ..SP (V5)  }
     TT_SoftStyle = $6EDA0017;
     TT_SoftStyle_None = $0000;
     TT_SoftStyle_Underlined = $0001;
     TT_SoftStyle_DblUnderlined = $0002;
     TT_SoftStyle_Overstriked = $0004;
     TT_SoftStyle_DblOverstriked = $0008;
  { ..S.  foreground RGB value }
     TT_Foreground = $6EDA0018;
     TT_Foreground_UseRastPort = -(1);
  { ..S.  background RGB value }
     TT_Background = $6EDA0019;
     TT_Background_UseRastPort = -(1);
  { .G..  }
     TT_FontMaxTop = $6EDA001E;
  { .G..  }
     TT_FontMaxBottom = $6EDA001F;
  { .G..  }
     TT_FontDesignHeight = $6EDA0020;
  { .G..  }
     TT_FontRealAscender = $6EDA0021;
  { .G..  }
     TT_FontRealDescender = $6EDA0022;
  { .G..  }
     TT_FontAccentedAscender = $6EDA0023;
  { ..SP  }
     TT_CustomEncoding = $6EDA0024;


  { Structure returned by TT_GetPixmap() (V5) }
  type
     PTT_Pixmap = ^tTT_Pixmap;
     tTT_Pixmap = record
          ttp_Size : ULONG;      { size of the structure inculdung this field  }
          ttp_Width : ULONG;     { also equal to bytes per row  }
          ttp_Height : ULONG;    { number of rows  }
          ttp_Data : Pointer;    { grayscale pixmap data  }
       end;

  { font requester attributes (V6)  }

  const
  { struct Window ,   NULL               }
     TTRQ_Window = $6EDA2000;
  { STRPTR,           NULL [Workbench]   }
     TTRQ_PubScreenName = $6EDA2001;
  { struct Screen ,   NULL               }
     TTRQ_Screen = $6EDA2002;
  { BOOL,             FALSE              }
     TTRQ_SleepWindow = $6EDA2003;
  { STRPTR,           "Select TrueType font" or localized  }
     TTRQ_TitleText = $6EDA2004;
  { STRPTR,           "OK" or localized  }
     TTRQ_PositiveText = $6EDA2005;
  { STRPTR,           "Cancel" or localized  }
     TTRQ_NegativeText = $6EDA2006;
  { WORD,             centered on screen  }
     TTRQ_InitialLeftEdge = $6EDA2007;
  { WORD,             centered on screen  }
     TTRQ_InitialTopEdge = $6EDA2008;
  { WORD,             max(200, 25% of sceeen width)  }
     TTRQ_InitialWidth = $6EDA2009;
  { WORD,             max(200, 50% of screen height)  }
     TTRQ_InitialHeight = $6EDA200A;
  { BOOL,             TRUE               }
     TTRQ_DoSizes = $6EDA2000;

FUNCTION TT_AllocRequest : POINTER; syscall TTEngineBase 102;
PROCEDURE TT_CloseFont(font : POINTER location 'a0'); syscall TTEngineBase 42;
PROCEDURE TT_DoneRastPort(rp : pRastPort location 'a1'); syscall TTEngineBase 96;
PROCEDURE TT_FreePixmap(pixmap : pTT_Pixmap location 'a0'); syscall TTEngineBase 90;
PROCEDURE TT_FreeRequest(request : POINTER location 'a0'); syscall TTEngineBase 114;
FUNCTION TT_GetAttrsA(rp : pRastPort location 'a1'; taglist : pTagItem location 'a0') : longword; syscall TTEngineBase 60;
FUNCTION TT_GetPixmapA(font : POINTER location 'a1'; _string : POINTER location 'a2'; count : longword location 'd0'; taglist : pTagItem location 'a0') : pTT_Pixmap; syscall TTEngineBase 84;
FUNCTION TT_OpenFontA(taglist : pTagItem location 'a0') : POINTER; syscall TTEngineBase 30;
FUNCTION TT_RequestA(request : POINTER location 'a0'; taglist : pTagItem location 'a1') : pTagItem; syscall TTEngineBase 108;
FUNCTION TT_SetAttrsA(rp : pRastPort location 'a1'; taglist : pTagItem location 'a0') : longword; syscall TTEngineBase 54;
FUNCTION TT_SetFont(rp : pRastPort location 'a1'; font : POINTER location 'a0') : BOOLEAN; syscall TTEngineBase 36;
PROCEDURE TT_Text(rp : pRastPort location 'a1'; _string : POINTER location 'a0'; count : longword location 'd0'); syscall TTEngineBase 48;
PROCEDURE TT_TextExtent(rp : pRastPort location 'a1'; _string : POINTER location 'a0'; count : LONGINT location 'd0'; te : pTextExtent location 'a2'); syscall TTEngineBase 72;
FUNCTION TT_TextFit(rp : pRastPort location 'a1'; _string : POINTER location 'a0'; count : longword location 'd0'; te : pTextExtent location 'a2'; tec : pTextExtent location 'a3'; dir : LONGINT location 'd1'; cwidth : longword location 'd2'; cheight : longword location 'd3') : longword; syscall TTEngineBase 78;
FUNCTION TT_TextLength(rp : pRastPort location 'a1'; _string : POINTER location 'a0'; count : longword location 'd0') : longword; syscall TTEngineBase 66;
{
 Functions and procedures with array of const go here
}
FUNCTION TT_GetAttrs(rp : pRastPort; const taglist : Array Of Const) : longword;
FUNCTION TT_GetPixmap(font : POINTER; _string : POINTER; count : longword; const taglist : Array Of Const) : pTT_Pixmap;
FUNCTION TT_OpenFont(const taglist : Array Of Const) : POINTER;
FUNCTION TT_Request(request : POINTER; const taglist : Array Of Const) : pTagItem;
FUNCTION TT_SetAttrs(rp : pRastPort; const taglist : Array Of Const) : longword;

IMPLEMENTATION

uses
  tagsarray;

{
 Functions and procedures with array of const go here
}
FUNCTION TT_GetAttrs(rp : pRastPort; const taglist : Array Of Const) : longword;
begin
    TT_GetAttrs := TT_GetAttrsA(rp , readintags(taglist));
end;

FUNCTION TT_GetPixmap(font : POINTER; _string : POINTER; count : longword; const taglist : Array Of Const) : pTT_Pixmap;
begin
    TT_GetPixmap := TT_GetPixmapA(font , _string , count , readintags(taglist));
end;

FUNCTION TT_OpenFont(const taglist : Array Of Const) : POINTER;
begin
    TT_OpenFont := TT_OpenFontA(readintags(taglist));
end;

FUNCTION TT_Request(request : POINTER; const taglist : Array Of Const) : pTagItem;
begin
    TT_Request := TT_RequestA(request , readintags(taglist));
end;

FUNCTION TT_SetAttrs(rp : pRastPort; const taglist : Array Of Const) : longword;
begin
    TT_SetAttrs := TT_SetAttrsA(rp , readintags(taglist));
end;

const
    { Change VERSION and LIBVERSION to proper values }
    VERSION : string[2] = '0';
    LIBVERSION : longword = 0;

initialization
  TTEngineBase := OpenLibrary(TTENGINENAME,LIBVERSION);
finalization
  if Assigned(TTEngineBase) then
    CloseLibrary(TTEngineBase);
END. (* UNIT TTENGINE *)