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
|
(***************************************************************************)
(* *)
(* ftoutln.h *)
(* *)
(* Support for the FT_Outline type used to store glyph shapes of *)
(* most scalable font formats (specification). *)
(* *)
(* Copyright 1996-2001, 2002, 2003, 2005, 2006, 2007 by *)
(* David Turner, Robert Wilhelm, and Werner Lemberg. *)
(* *)
(* This file is part of the FreeType project, and may only be used, *)
(* modified, and distributed under the terms of the FreeType project *)
(* license, LICENSE.TXT. By continuing to use, modify, or distribute *)
(* this file you indicate that you have read the license and *)
(* understand and accept it fully. *)
(* *)
(***************************************************************************)
(***************************************************************************)
(* Pascal port by the UltraStar Deluxe Team *)
(***************************************************************************)
(*************************************************************************)
(* *)
(* <Section> *)
(* outline_processing *)
(* *)
(* <Title> *)
(* Outline Processing *)
(* *)
(* <Abstract> *)
(* Functions to create, transform, and render vectorial glyph images. *)
(* *)
(* <Description> *)
(* This section contains routines used to create and destroy scalable *)
(* glyph images known as `outlines'. These can also be measured, *)
(* transformed, and converted into bitmaps and pixmaps. *)
(* *)
(* <Order> *)
(* FT_Outline *)
(* FT_OUTLINE_FLAGS *)
(* FT_Outline_New *)
(* FT_Outline_Done *)
(* FT_Outline_Copy *)
(* FT_Outline_Translate *)
(* FT_Outline_Transform *)
(* FT_Outline_Embolden *)
(* FT_Outline_Reverse *)
(* FT_Outline_Check *)
(* *)
(* FT_Outline_Get_CBox *)
(* FT_Outline_Get_BBox *)
(* *)
(* FT_Outline_Get_Bitmap *)
(* FT_Outline_Render *)
(* *)
(* FT_Outline_Decompose *)
(* FT_Outline_Funcs *)
(* FT_Outline_MoveTo_Func *)
(* FT_Outline_LineTo_Func *)
(* FT_Outline_ConicTo_Func *)
(* FT_Outline_CubicTo_Func *)
(* *)
(*************************************************************************)
{$IFNDEF TYPE_DECL}
(*************************************************************************)
(* *)
(* <Function> *)
(* FT_Outline_Decompose *)
(* *)
(* <Description> *)
(* Walks over an outline's structure to decompose it into individual *)
(* segments and Bézier arcs. This function is also able to emit *)
(* `move to' and `close to' operations to indicate the start and end *)
(* of new contours in the outline. *)
(* *)
(* <Input> *)
(* outline :: A pointer to the source target. *)
(* *)
(* func_interface :: A table of `emitters', i.e,. function pointers *)
(* called during decomposition to indicate path *)
(* operations. *)
(* *)
(* <InOut> *)
(* user :: A typeless pointer which is passed to each *)
(* emitter during the decomposition. It can be *)
(* used to store the state during the *)
(* decomposition. *)
(* *)
(* <Return> *)
(* FreeType error code. 0 means success. *)
(* *)
function FT_Outline_Decompose(
outline: PFT_Outline;
func_interface: {const} PFT_Outline_Funcs;
user: Pointer): FT_Error;
cdecl; external ft_lib name 'FT_Outline_Decompose';
(*************************************************************************)
(* *)
(* <Function> *)
(* FT_Outline_New *)
(* *)
(* <Description> *)
(* Creates a new outline of a given size. *)
(* *)
(* <Input> *)
(* library :: A handle to the library object from where the *)
(* outline is allocated. Note however that the new *)
(* outline will *not* necessarily be *freed*, when *)
(* destroying the library, by @FT_Done_FreeType. *)
(* *)
(* numPoints :: The maximal number of points within the outline. *)
(* *)
(* numContours :: The maximal number of contours within the outline. *)
(* *)
(* <Output> *)
(* anoutline :: A handle to the new outline. NULL in case of *)
(* error. *)
(* *)
(* <Return> *)
(* FreeType error code. 0 means success. *)
(* *)
(* <Note> *)
(* The reason why this function takes a `library' parameter is simply *)
(* to use the library's memory allocator. *)
(* *)
function FT_Outline_New(
library_: FT_Library;
numPoints: FT_UInt;
numContours: FT_Int;
anoutline: PFT_Outline): FT_Error;
cdecl; external ft_lib name 'FT_Outline_New';
(*************************************************************************)
(* *)
(* <Function> *)
(* FT_Outline_Done *)
(* *)
(* <Description> *)
(* Destroys an outline created with @FT_Outline_New. *)
(* *)
(* <Input> *)
(* library :: A handle of the library object used to allocate the *)
(* outline. *)
(* *)
(* outline :: A pointer to the outline object to be discarded. *)
(* *)
(* <Return> *)
(* FreeType error code. 0 means success. *)
(* *)
(* <Note> *)
(* If the outline's `owner' field is not set, only the outline *)
(* descriptor will be released. *)
(* *)
(* The reason why this function takes an `library' parameter is *)
(* simply to use ft_mem_free(). *)
(* *)
function FT_Outline_Done(library_: FT_Library;
outline: PFT_Outline): FT_Error;
cdecl; external ft_lib name 'FT_Outline_Done';
(*************************************************************************)
(* *)
(* <Function> *)
(* FT_Outline_Check *)
(* *)
(* <Description> *)
(* Check the contents of an outline descriptor. *)
(* *)
(* <Input> *)
(* outline :: A handle to a source outline. *)
(* *)
(* <Return> *)
(* FreeType error code. 0 means success. *)
(* *)
function FT_Outline_Check( outline: PFT_Outline ): FT_Error;
cdecl; external ft_lib name 'FT_Outline_Check';
(*************************************************************************)
(* *)
(* <Function> *)
(* FT_Outline_Get_CBox *)
(* *)
(* <Description> *)
(* Returns an outline's `control box'. The control box encloses all *)
(* the outline's points, including Bézier control points. Though it *)
(* coincides with the exact bounding box for most glyphs, it can be *)
(* slightly larger in some situations (like when rotating an outline *)
(* which contains Bézier outside arcs). *)
(* *)
(* Computing the control box is very fast, while getting the bounding *)
(* box can take much more time as it needs to walk over all segments *)
(* and arcs in the outline. To get the latter, you can use the *)
(* `ftbbox' component which is dedicated to this single task. *)
(* *)
(* <Input> *)
(* outline :: A pointer to the source outline descriptor. *)
(* *)
(* <Output> *)
(* acbox :: The outline's control box. *)
(* *)
procedure FT_Outline_Get_CBox(
outline: {const} PFT_Outline;
acbox: PFT_BBox);
cdecl; external ft_lib name 'FT_Outline_Get_CBox';
(*************************************************************************)
(* *)
(* <Function> *)
(* FT_Outline_Translate *)
(* *)
(* <Description> *)
(* Applies a simple translation to the points of an outline. *)
(* *)
(* <InOut> *)
(* outline :: A pointer to the target outline descriptor. *)
(* *)
(* <Input> *)
(* xOffset :: The horizontal offset. *)
(* *)
(* yOffset :: The vertical offset. *)
(* *)
procedure FT_Outline_Translate(
outline: {const} PFT_Outline;
xOffset: FT_Pos;
yOffset: FT_Pos);
cdecl; external ft_lib name 'FT_Outline_Translate';
(*************************************************************************)
(* *)
(* <Function> *)
(* FT_Outline_Copy *)
(* *)
(* <Description> *)
(* Copies an outline into another one. Both objects must have the *)
(* same sizes (number of points & number of contours) when this *)
(* function is called. *)
(* *)
(* <Input> *)
(* source :: A handle to the source outline. *)
(* *)
(* <Output> *)
(* target :: A handle to the target outline. *)
(* *)
(* <Return> *)
(* FreeType error code. 0 means success. *)
(* *)
function FT_Outline_Copy(
source: {const} PFT_Outline;
target: PFT_Outline): FT_Error;
cdecl; external ft_lib name 'FT_Outline_Copy';
(*************************************************************************)
(* *)
(* <Function> *)
(* FT_Outline_Transform *)
(* *)
(* <Description> *)
(* Applies a simple 2x2 matrix to all of an outline's points. Useful *)
(* for applying rotations, slanting, flipping, etc. *)
(* *)
(* <InOut> *)
(* outline :: A pointer to the target outline descriptor. *)
(* *)
(* <Input> *)
(* matrix :: A pointer to the transformation matrix. *)
(* *)
(* <Note> *)
(* You can use @FT_Outline_Translate if you need to translate the *)
(* outline's points. *)
(* *)
procedure FT_Outline_Transform(
outline: {const} PFT_Outline;
matrix: {const} PFT_Matrix);
cdecl; external ft_lib name 'FT_Outline_Transform';
(*************************************************************************)
(* *)
(* <Function> *)
(* FT_Outline_Embolden *)
(* *)
(* <Description> *)
(* Emboldens an outline. The new outline will be at most 4 times *)
(* `strength' pixels wider and higher. You may think of the left and *)
(* bottom borders as unchanged. *)
(* *)
(* Negative `strength' values to reduce the outline thickness are *)
(* possible also. *)
(* *)
(* <InOut> *)
(* outline :: A handle to the target outline. *)
(* *)
(* <Input> *)
(* strength :: How strong the glyph is emboldened. Expressed in *)
(* 26.6 pixel format. *)
(* *)
(* <Return> *)
(* FreeType error code. 0 means success. *)
(* *)
(* <Note> *)
(* The used algorithm to increase or decrease the thickness of the *)
(* glyph doesn't change the number of points; this means that certain *)
(* situations like acute angles or intersections are sometimes *)
(* handled incorrectly. *)
(* *)
(* Example call: *)
(* *)
(* { *)
(* FT_Load_Glyph( face, index, FT_LOAD_DEFAULT ); *)
(* if ( face->slot->format == FT_GLYPH_FORMAT_OUTLINE ) *)
(* FT_Outline_Embolden( &face->slot->outline, strength ); *)
(* } *)
(* *)
function FT_Outline_Embolden(
outline: PFT_Outline;
strength: FT_Pos): FT_Error;
cdecl; external ft_lib name 'FT_Outline_Embolden';
(*************************************************************************)
(* *)
(* <Function> *)
(* FT_Outline_Reverse *)
(* *)
(* <Description> *)
(* Reverses the drawing direction of an outline. This is used to *)
(* ensure consistent fill conventions for mirrored glyphs. *)
(* *)
(* <InOut> *)
(* outline :: A pointer to the target outline descriptor. *)
(* *)
(* <Note> *)
(* This functions toggles the bit flag @FT_OUTLINE_REVERSE_FILL in *)
(* the outline's `flags' field. *)
(* *)
(* It shouldn't be used by a normal client application, unless it *)
(* knows what it is doing. *)
(* *)
procedure FT_Outline_Reverse( outline: PFT_Outline );
cdecl; external ft_lib name 'FT_Outline_Reverse';
(*************************************************************************)
(* *)
(* <Function> *)
(* FT_Outline_Get_Bitmap *)
(* *)
(* <Description> *)
(* Renders an outline within a bitmap. The outline's image is simply *)
(* OR-ed to the target bitmap. *)
(* *)
(* <Input> *)
(* library :: A handle to a FreeType library object. *)
(* *)
(* outline :: A pointer to the source outline descriptor. *)
(* *)
(* <InOut> *)
(* abitmap :: A pointer to the target bitmap descriptor. *)
(* *)
(* <Return> *)
(* FreeType error code. 0 means success. *)
(* *)
(* <Note> *)
(* This function does NOT CREATE the bitmap, it only renders an *)
(* outline image within the one you pass to it! *)
(* *)
(* It will use the raster corresponding to the default glyph format. *)
(* *)
function FT_Outline_Get_Bitmap(
library_: FT_Library;
outline: PFT_Outline;
abitmap: {const} PFT_Bitmap): FT_Error;
cdecl; external ft_lib name 'FT_Outline_Get_Bitmap';
(*************************************************************************)
(* *)
(* <Function> *)
(* FT_Outline_Render *)
(* *)
(* <Description> *)
(* Renders an outline within a bitmap using the current scan-convert. *)
(* This functions uses an @FT_Raster_Params structure as an argument, *)
(* allowing advanced features like direct composition, translucency, *)
(* etc. *)
(* *)
(* <Input> *)
(* library :: A handle to a FreeType library object. *)
(* *)
(* outline :: A pointer to the source outline descriptor. *)
(* *)
(* <InOut> *)
(* params :: A pointer to an @FT_Raster_Params structure used to *)
(* describe the rendering operation. *)
(* *)
(* <Return> *)
(* FreeType error code. 0 means success. *)
(* *)
(* <Note> *)
(* You should know what you are doing and how @FT_Raster_Params works *)
(* to use this function. *)
(* *)
(* The field `params.source' will be set to `outline' before the scan *)
(* converter is called, which means that the value you give to it is *)
(* actually ignored. *)
(* *)
function FT_Outline_Render(
library_: FT_Library;
outline: PFT_Outline;
params: PFT_Raster_Params): FT_Error;
cdecl; external ft_lib name 'FT_Outline_Render';
{$ENDIF TYPE_DECL}
(**************************************************************************
*
* @enum:
* FT_Orientation
*
* @description:
* A list of values used to describe an outline's contour orientation.
*
* The TrueType and Postscript specifications use different conventions
* to determine whether outline contours should be filled or unfilled.
*
* @values:
* FT_ORIENTATION_TRUETYPE ::
* According to the TrueType specification, clockwise contours must
* be filled, and counter-clockwise ones must be unfilled.
*
* FT_ORIENTATION_POSTSCRIPT ::
* According to the Postscript specification, counter-clockwise contours
* must be filled, and clockwise ones must be unfilled.
*
* FT_ORIENTATION_FILL_RIGHT ::
* This is identical to @FT_ORIENTATION_TRUETYPE, but is used to
* remember that in TrueType, everything that is to the right of
* the drawing direction of a contour must be filled.
*
* FT_ORIENTATION_FILL_LEFT ::
* This is identical to @FT_ORIENTATION_POSTSCRIPT, but is used to
* remember that in Postscript, everything that is to the left of
* the drawing direction of a contour must be filled.
*
* FT_ORIENTATION_NONE ::
* The orientation cannot be determined. That is, different parts of
* the glyph have different orientation.
*
*)
{$IFDEF TYPE_DECL}
FT_Orientation = cint;
{$ELSE TYPE_DECL}
const
FT_ORIENTATION_TRUETYPE = 0;
FT_ORIENTATION_POSTSCRIPT = 1;
FT_ORIENTATION_FILL_RIGHT = FT_ORIENTATION_TRUETYPE;
FT_ORIENTATION_FILL_LEFT = FT_ORIENTATION_POSTSCRIPT;
FT_ORIENTATION_NONE = FT_ORIENTATION_FILL_LEFT+1;
(**************************************************************************
*
* @function:
* FT_Outline_Get_Orientation
*
* @description:
* This function analyzes a glyph outline and tries to compute its
* fill orientation (see @FT_Orientation). This is done by computing
* the direction of each global horizontal and/or vertical extrema
* within the outline.
*
* Note that this will return @FT_ORIENTATION_TRUETYPE for empty
* outlines.
*
* @input:
* outline ::
* A handle to the source outline.
*
* @return:
* The orientation.
*
*)
function FT_Outline_Get_Orientation( outline: PFT_Outline ): FT_Orientation;
cdecl; external ft_lib name 'FT_Outline_Get_Orientation';
{$ENDIF TYPE_DECL}
|