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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
|
{
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}
{$I useamigasmartlink.inc}
{$ifdef use_amiga_smartlink}
{$smartlink on}
{$endif use_amiga_smartlink}
UNIT TTENGINE;
INTERFACE
USES Exec,utility,graphics;
VAR TTEngineBase : pLibrary;
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;
PROCEDURE TT_CloseFont(font : POINTER);
PROCEDURE TT_DoneRastPort(rp : pRastPort);
PROCEDURE TT_FreePixmap(pixmap : pTT_Pixmap);
PROCEDURE TT_FreeRequest(request : POINTER);
FUNCTION TT_GetAttrsA(rp : pRastPort; taglist : pTagItem) : longword;
FUNCTION TT_GetPixmapA(font : POINTER; _string : POINTER; count : longword; taglist : pTagItem) : pTT_Pixmap;
FUNCTION TT_OpenFontA(taglist : pTagItem) : POINTER;
FUNCTION TT_RequestA(request : POINTER; taglist : pTagItem) : pTagItem;
FUNCTION TT_SetAttrsA(rp : pRastPort; taglist : pTagItem) : longword;
FUNCTION TT_SetFont(rp : pRastPort; font : POINTER) : BOOLEAN;
PROCEDURE TT_Text(rp : pRastPort; _string : POINTER; count : longword);
PROCEDURE TT_TextExtent(rp : pRastPort; _string : POINTER; count : LONGINT; te : pTextExtent);
FUNCTION TT_TextFit(rp : pRastPort; _string : POINTER; count : longword; te : pTextExtent; tec : pTextExtent; dir : LONGINT; cwidth : longword; cheight : longword) : longword;
FUNCTION TT_TextLength(rp : pRastPort; _string : POINTER; count : longword) : longword;
{
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;
{You can remove this include and use a define instead}
{$I useautoopenlib.inc}
{$ifdef use_init_openlib}
procedure InitTTENGINELibrary;
{$endif use_init_openlib}
{This is a variable that knows how the unit is compiled}
var
TTENGINEIsCompiledHow : longint;
IMPLEMENTATION
uses
{$ifndef dont_use_openlib}
msgbox,
{$endif dont_use_openlib}
tagsarray;
FUNCTION TT_AllocRequest : POINTER;
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L TTEngineBase,A6
JSR -102(A6)
MOVEA.L (A7)+,A6
MOVE.L D0,@RESULT
END;
END;
PROCEDURE TT_CloseFont(font : POINTER);
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L font,A0
MOVEA.L TTEngineBase,A6
JSR -042(A6)
MOVEA.L (A7)+,A6
END;
END;
PROCEDURE TT_DoneRastPort(rp : pRastPort);
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L rp,A1
MOVEA.L TTEngineBase,A6
JSR -096(A6)
MOVEA.L (A7)+,A6
END;
END;
PROCEDURE TT_FreePixmap(pixmap : pTT_Pixmap);
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L pixmap,A0
MOVEA.L TTEngineBase,A6
JSR -090(A6)
MOVEA.L (A7)+,A6
END;
END;
PROCEDURE TT_FreeRequest(request : POINTER);
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L request,A0
MOVEA.L TTEngineBase,A6
JSR -114(A6)
MOVEA.L (A7)+,A6
END;
END;
FUNCTION TT_GetAttrsA(rp : pRastPort; taglist : pTagItem) : longword;
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L rp,A1
MOVEA.L taglist,A0
MOVEA.L TTEngineBase,A6
JSR -060(A6)
MOVEA.L (A7)+,A6
MOVE.L D0,@RESULT
END;
END;
FUNCTION TT_GetPixmapA(font : POINTER; _string : POINTER; count : longword; taglist : pTagItem) : pTT_Pixmap;
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L font,A1
MOVEA.L _string,A2
MOVE.L count,D0
MOVEA.L taglist,A0
MOVEA.L TTEngineBase,A6
JSR -084(A6)
MOVEA.L (A7)+,A6
MOVE.L D0,@RESULT
END;
END;
FUNCTION TT_OpenFontA(taglist : pTagItem) : POINTER;
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L taglist,A0
MOVEA.L TTEngineBase,A6
JSR -030(A6)
MOVEA.L (A7)+,A6
MOVE.L D0,@RESULT
END;
END;
FUNCTION TT_RequestA(request : POINTER; taglist : pTagItem) : pTagItem;
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L request,A0
MOVEA.L taglist,A1
MOVEA.L TTEngineBase,A6
JSR -108(A6)
MOVEA.L (A7)+,A6
MOVE.L D0,@RESULT
END;
END;
FUNCTION TT_SetAttrsA(rp : pRastPort; taglist : pTagItem) : longword;
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L rp,A1
MOVEA.L taglist,A0
MOVEA.L TTEngineBase,A6
JSR -054(A6)
MOVEA.L (A7)+,A6
MOVE.L D0,@RESULT
END;
END;
FUNCTION TT_SetFont(rp : pRastPort; font : POINTER) : BOOLEAN;
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L rp,A1
MOVEA.L font,A0
MOVEA.L TTEngineBase,A6
JSR -036(A6)
MOVEA.L (A7)+,A6
TST.W D0
BEQ.B @end
MOVEQ #1,D0
@end: MOVE.B D0,@RESULT
END;
END;
PROCEDURE TT_Text(rp : pRastPort; _string : POINTER; count : longword);
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L rp,A1
MOVEA.L _string,A0
MOVE.L count,D0
MOVEA.L TTEngineBase,A6
JSR -048(A6)
MOVEA.L (A7)+,A6
END;
END;
PROCEDURE TT_TextExtent(rp : pRastPort; _string : POINTER; count : LONGINT; te : pTextExtent);
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L rp,A1
MOVEA.L _string,A0
MOVE.L count,D0
MOVEA.L te,A2
MOVEA.L TTEngineBase,A6
JSR -072(A6)
MOVEA.L (A7)+,A6
END;
END;
FUNCTION TT_TextFit(rp : pRastPort; _string : POINTER; count : longword; te : pTextExtent; tec : pTextExtent; dir : LONGINT; cwidth : longword; cheight : longword) : longword;
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L rp,A1
MOVEA.L _string,A0
MOVE.L count,D0
MOVEA.L te,A2
MOVEA.L tec,A3
MOVE.L dir,D1
MOVE.L cwidth,D2
MOVE.L cheight,D3
MOVEA.L TTEngineBase,A6
JSR -078(A6)
MOVEA.L (A7)+,A6
MOVE.L D0,@RESULT
END;
END;
FUNCTION TT_TextLength(rp : pRastPort; _string : POINTER; count : longword) : longword;
BEGIN
ASM
MOVE.L A6,-(A7)
MOVEA.L rp,A1
MOVEA.L _string,A0
MOVE.L count,D0
MOVEA.L TTEngineBase,A6
JSR -066(A6)
MOVEA.L (A7)+,A6
MOVE.L D0,@RESULT
END;
END;
{
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;
{$ifdef use_init_openlib}
{$Info Compiling initopening of ttengine.library}
{$Info don't forget to use InitTTENGINELibrary in the beginning of your program}
var
ttengine_exit : Pointer;
procedure ClosettengineLibrary;
begin
ExitProc := ttengine_exit;
if TTEngineBase <> nil then begin
CloseLibrary(TTEngineBase);
TTEngineBase := nil;
end;
end;
procedure InitTTENGINELibrary;
begin
TTEngineBase := nil;
TTEngineBase := OpenLibrary(TTENGINENAME,LIBVERSION);
if TTEngineBase <> nil then begin
ttengine_exit := ExitProc;
ExitProc := @ClosettengineLibrary;
end else begin
MessageBox('FPC Pascal Error',
'Can''t open ttengine.library version ' + VERSION + #10 +
'Deallocating resources and closing down',
'Oops');
halt(20);
end;
end;
begin
TTENGINEIsCompiledHow := 2;
{$endif use_init_openlib}
{$ifdef use_auto_openlib}
{$Info Compiling autoopening of ttengine.library}
var
ttengine_exit : Pointer;
procedure ClosettengineLibrary;
begin
ExitProc := ttengine_exit;
if TTEngineBase <> nil then begin
CloseLibrary(TTEngineBase);
TTEngineBase := nil;
end;
end;
begin
TTEngineBase := nil;
TTEngineBase := OpenLibrary(TTENGINENAME,LIBVERSION);
if TTEngineBase <> nil then begin
ttengine_exit := ExitProc;
ExitProc := @ClosettengineLibrary;
TTENGINEIsCompiledHow := 1;
end else begin
MessageBox('FPC Pascal Error',
'Can''t open ttengine.library version ' + VERSION + #10 +
'Deallocating resources and closing down',
'Oops');
halt(20);
end;
{$endif use_auto_openlib}
{$ifdef dont_use_openlib}
begin
TTENGINEIsCompiledHow := 3;
{$Warning No autoopening of ttengine.library compiled}
{$Warning Make sure you open ttengine.library yourself}
{$endif dont_use_openlib}
END. (* UNIT TTENGINE *)
|