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
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
|
{***************************************************************************}
{* *}
{* ftstroke.h *}
{* *}
{* FreeType path stroker (specification). *}
{* *}
{* Copyright 2002, 2003, 2004, 2005, 2006 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:
* glyph_stroker
*
* @title:
* Glyph Stroker
*
* @abstract:
* Generating bordered and stroked glyphs.
*
* @description:
* This component generates stroked outlines of a given vectorial
* glyph. It also allows you to retrieve the `outside' and/or the
* `inside' borders of the stroke.
*
* This can be useful to generate `bordered' glyph, i.e., glyphs
* displayed with a coloured (and anti-aliased) border around their
* shape.
*}
{$IFDEF TYPE_DECL}
{**************************************************************
*
* @type:
* FT_Stroker
*
* @description:
* Opaque handler to a path stroker object.
*}
FT_Stroker = Pointer;
{**************************************************************
*
* @enum:
* FT_Stroker_LineJoin
*
* @description:
* These values determine how two joining lines are rendered
* in a stroker.
*
* @values:
* FT_STROKER_LINEJOIN_ROUND ::
* Used to render rounded line joins. Circular arcs are used
* to join two lines smoothly.
*
* FT_STROKER_LINEJOIN_BEVEL ::
* Used to render beveled line joins; i.e., the two joining lines
* are extended until they intersect.
*
* FT_STROKER_LINEJOIN_MITER ::
* Same as beveled rendering, except that an additional line
* break is added if the angle between the two joining lines
* is too closed (this is useful to avoid unpleasant spikes
* in beveled rendering).
*}
FT_Stroker_LineJoin = cint;
{$ELSE TYPE_DECL}
const
FT_STROKER_LINEJOIN_ROUND = 0;
FT_STROKER_LINEJOIN_BEVEL = 1;
FT_STROKER_LINEJOIN_MITER = 2;
{$ENDIF TYPE_DECL}
{$IFDEF TYPE_DECL}
{**************************************************************
*
* @enum:
* FT_Stroker_LineCap
*
* @description:
* These values determine how the end of opened sub-paths are
* rendered in a stroke.
*
* @values:
* FT_STROKER_LINECAP_BUTT ::
* The end of lines is rendered as a full stop on the last
* point itself.
*
* FT_STROKER_LINECAP_ROUND ::
* The end of lines is rendered as a half-circle around the
* last point.
*
* FT_STROKER_LINECAP_SQUARE ::
* The end of lines is rendered as a square around the
* last point.
*}
FT_Stroker_LineCap = cint;
{$ELSE TYPE_DECL}
const
FT_STROKER_LINECAP_BUTT = 0;
FT_STROKER_LINECAP_ROUND = 1;
FT_STROKER_LINECAP_SQUARE = 2;
{$ENDIF TYPE_DECL}
{$IFDEF TYPE_DECL}
{**************************************************************
*
* @enum:
* FT_StrokerBorder
*
* @description:
* These values are used to select a given stroke border
* in @FT_Stroker_GetBorderCounts and @FT_Stroker_ExportBorder.
*
* @values:
* FT_STROKER_BORDER_LEFT ::
* Select the left border, relative to the drawing direction.
*
* FT_STROKER_BORDER_RIGHT ::
* Select the right border, relative to the drawing direction.
*
* @note:
* Applications are generally interested in the `inside' and `outside'
* borders. However, there is no direct mapping between these and the
* `left' and `right' ones, since this really depends on the glyph's
* drawing orientation, which varies between font formats.
*
* You can however use @FT_Outline_GetInsideBorder and
* @FT_Outline_GetOutsideBorder to get these.
*}
FT_StrokerBorder = cint;
{$ELSE TYPE_DECL}
const
FT_STROKER_BORDER_LEFT = 0;
FT_STROKER_BORDER_RIGHT = 1;
{**************************************************************
*
* @function:
* FT_Outline_GetInsideBorder
*
* @description:
* Retrieve the @FT_StrokerBorder value corresponding to the
* `inside' borders of a given outline.
*
* @input:
* outline ::
* The source outline handle.
*
* @return:
* The border index. @FT_STROKER_BORDER_LEFT for empty or invalid
* outlines.
*}
function FT_Outline_GetInsideBorder( outline: PFT_Outline ): FT_StrokerBorder;
cdecl; external ft_lib name 'FT_Outline_GetInsideBorder';
{**************************************************************
*
* @function:
* FT_Outline_GetOutsideBorder
*
* @description:
* Retrieve the @FT_StrokerBorder value corresponding to the
* `outside' borders of a given outline.
*
* @input:
* outline ::
* The source outline handle.
*
* @return:
* The border index. @FT_STROKER_BORDER_LEFT for empty or invalid
* outlines.
*}
function FT_Outline_GetOutsideBorder( outline: PFT_Outline ): FT_StrokerBorder;
cdecl; external ft_lib name 'FT_Outline_GetOutsideBorder';
{**************************************************************
*
* @function:
* FT_Stroker_New
*
* @description:
* Create a new stroker object.
*
* @input:
* library ::
* FreeType library handle.
*
* @output:
* astroker ::
* A new stroker object handle. NULL in case of error.
*
* @return:
* FreeType error code. 0 means success.
*}
function FT_Stroker_New(
library_: FT_Library;
out astroker: FT_Stroker ): FT_Error;
cdecl; external ft_lib name 'FT_Stroker_New';
{**************************************************************
*
* @function:
* FT_Stroker_Set
*
* @description:
* Reset a stroker object's attributes.
*
* @input:
* stroker ::
* The target stroker handle.
*
* radius ::
* The border radius.
*
* line_cap ::
* The line cap style.
*
* line_join ::
* The line join style.
*
* miter_limit ::
* The miter limit for the FT_STROKER_LINEJOIN_MITER style,
* expressed as 16.16 fixed point value.
*
* @note:
* The radius is expressed in the same units that the outline
* coordinates.
*}
procedure FT_Stroker_Set(
stroker: FT_Stroker;
radius: FT_Fixed;
line_cap: FT_Stroker_LineCap;
line_join: FT_Stroker_LineJoin;
miter_limit: FT_Fixed );
cdecl; external ft_lib name 'FT_Stroker_Set';
{**************************************************************
*
* @function:
* FT_Stroker_Rewind
*
* @description:
* Reset a stroker object without changing its attributes.
* You should call this function before beginning a new
* series of calls to @FT_Stroker_BeginSubPath or
* @FT_Stroker_EndSubPath.
*
* @input:
* stroker ::
* The target stroker handle.
*}
procedure FT_Stroker_Rewind( stroker: FT_Stroker );
cdecl; external ft_lib name 'FT_Stroker_Rewind';
{**************************************************************
*
* @function:
* FT_Stroker_ParseOutline
*
* @description:
* A convenience function used to parse a whole outline with
* the stroker. The resulting outline(s) can be retrieved
* later by functions like @FT_Stroker_GetCounts and @FT_Stroker_Export.
*
* @input:
* stroker ::
* The target stroker handle.
*
* outline ::
* The source outline.
*
* opened ::
* A boolean. If 1, the outline is treated as an open path instead
* of a closed one.
*
* @return:
* FreeType error code. 0 means success.
*
* @note:
* If `opened' is 0 (the default), the outline is treated as a closed
* path, and the stroker will generate two distinct `border' outlines.
*
* If `opened' is 1, the outline is processed as an open path, and the
* stroker will generate a single `stroke' outline.
*
* This function calls @FT_Stroker_Rewind automatically.
*}
function FT_Stroker_ParseOutline(
stroker: FT_Stroker;
outline: PFT_Outline;
opened: FT_Bool): FT_Error;
cdecl; external ft_lib name 'FT_Stroker_ParseOutline';
{**************************************************************
*
* @function:
* FT_Stroker_BeginSubPath
*
* @description:
* Start a new sub-path in the stroker.
*
* @input:
* stroker ::
* The target stroker handle.
*
* to ::
* A pointer to the start vector.
*
* open ::
* A boolean. If 1, the sub-path is treated as an open one.
*
* @return:
* FreeType error code. 0 means success.
*
* @note:
* This function is useful when you need to stroke a path that is
* not stored as an @FT_Outline object.
*}
function FT_Stroker_BeginSubPath(
stroker: FT_Stroker;
to_: PFT_Vector;
open: FT_Bool ): FT_Error;
cdecl; external ft_lib name 'FT_Stroker_BeginSubPath';
{**************************************************************
*
* @function:
* FT_Stroker_EndSubPath
*
* @description:
* Close the current sub-path in the stroker.
*
* @input:
* stroker ::
* The target stroker handle.
*
* @return:
* FreeType error code. 0 means success.
*
* @note:
* You should call this function after @FT_Stroker_BeginSubPath.
* If the subpath was not `opened', this function will `draw' a
* single line segment to the start position when needed.
*}
function FT_Stroker_EndSubPath( stroker: FT_Stroker ): FT_Error;
cdecl; external ft_lib name 'FT_Stroker_EndSubPath';
{**************************************************************
*
* @function:
* FT_Stroker_LineTo
*
* @description:
* `Draw' a single line segment in the stroker's current sub-path,
* from the last position.
*
* @input:
* stroker ::
* The target stroker handle.
*
* to ::
* A pointer to the destination point.
*
* @return:
* FreeType error code. 0 means success.
*
* @note:
* You should call this function between @FT_Stroker_BeginSubPath and
* @FT_Stroker_EndSubPath.
*}
function FT_Stroker_LineTo(
stroker: FT_Stroker;
to_: PFT_Vector ): FT_Error;
cdecl; external ft_lib name 'FT_Stroker_LineTo';
{**************************************************************
*
* @function:
* FT_Stroker_ConicTo
*
* @description:
* `Draw' a single quadratic Bézier in the stroker's current sub-path,
* from the last position.
*
* @input:
* stroker ::
* The target stroker handle.
*
* control ::
* A pointer to a Bézier control point.
*
* to ::
* A pointer to the destination point.
*
* @return:
* FreeType error code. 0 means success.
*
* @note:
* You should call this function between @FT_Stroker_BeginSubPath and
* @FT_Stroker_EndSubPath.
*}
function FT_Stroker_ConicTo(
stroker: FT_Stroker;
control: PFT_Vector;
to_: PFT_Vector ): FT_Error;
cdecl; external ft_lib name 'FT_Stroker_ConicTo';
{**************************************************************
*
* @function:
* FT_Stroker_CubicTo
*
* @description:
* `Draw' a single cubic Bézier in the stroker's current sub-path,
* from the last position.
*
* @input:
* stroker ::
* The target stroker handle.
*
* control1 ::
* A pointer to the first Bézier control point.
*
* control2 ::
* A pointer to second Bézier control point.
*
* to ::
* A pointer to the destination point.
*
* @return:
* FreeType error code. 0 means success.
*
* @note:
* You should call this function between @FT_Stroker_BeginSubPath and
* @FT_Stroker_EndSubPath.
*}
function FT_Stroker_CubicTo(
stroker: FT_Stroker;
control1: PFT_Vector;
control2: PFT_Vector;
to_: PFT_Vector ): FT_Error;
cdecl; external ft_lib name 'FT_Stroker_CubicTo';
{**************************************************************
*
* @function:
* FT_Stroker_GetBorderCounts
*
* @description:
* Call this function once you have finished parsing your paths
* with the stroker. It will return the number of points and
* contours necessary to export one of the `border' or `stroke'
* outlines generated by the stroker.
*
* @input:
* stroker ::
* The target stroker handle.
*
* border ::
* The border index.
*
* @output:
* anum_points ::
* The number of points.
*
* anum_contours ::
* The number of contours.
*
* @return:
* FreeType error code. 0 means success.
*
* @note:
* When an outline, or a sub-path, is `closed', the stroker generates
* two independent `border' outlines, named `left' and `right'.
*
* When the outline, or a sub-path, is `opened', the stroker merges
* the `border' outlines with caps. The `left' border receives all
* points, while the `right' border becomes empty.
*
* Use the function @FT_Stroker_GetCounts instead if you want to
* retrieve the counts associated to both borders.
*}
function FT_Stroker_GetBorderCounts(
stroker: FT_Stroker;
border: FT_StrokerBorder;
out anum_points: FT_UInt;
out anum_contours: FT_UInt ): FT_Error;
cdecl; external ft_lib name 'FT_Stroker_GetBorderCounts';
{**************************************************************
*
* @function:
* FT_Stroker_ExportBorder
*
* @description:
* Call this function after @FT_Stroker_GetBorderCounts to
* export the corresponding border to your own @FT_Outline
* structure.
*
* Note that this function will append the border points and
* contours to your outline, but will not try to resize its
* arrays.
*
* @input:
* stroker ::
* The target stroker handle.
*
* border ::
* The border index.
*
* outline ::
* The target outline handle.
*
* @note:
* Always call this function after @FT_Stroker_GetBorderCounts to
* get sure that there is enough room in your @FT_Outline object to
* receive all new data.
*
* When an outline, or a sub-path, is `closed', the stroker generates
* two independent `border' outlines, named `left' and `right'
*
* When the outline, or a sub-path, is `opened', the stroker merges
* the `border' outlines with caps. The `left' border receives all
* points, while the `right' border becomes empty.
*
* Use the function @FT_Stroker_Export instead if you want to
* retrieve all borders at once.
*}
procedure FT_Stroker_ExportBorder(
stroker: FT_Stroker;
border: FT_StrokerBorder;
outline: PFT_Outline );
cdecl; external ft_lib name 'FT_Stroker_ExportBorder';
{**************************************************************
*
* @function:
* FT_Stroker_GetCounts
*
* @description:
* Call this function once you have finished parsing your paths
* with the stroker. It returns the number of points and
* contours necessary to export all points/borders from the stroked
* outline/path.
*
* @input:
* stroker ::
* The target stroker handle.
*
* @output:
* anum_points ::
* The number of points.
*
* anum_contours ::
* The number of contours.
*
* @return:
* FreeType error code. 0 means success.
*}
function FT_Stroker_GetCounts(
stroker: FT_Stroker;
out anum_points: FT_UInt;
out anum_contours: FT_UInt ): FT_Error;
cdecl; external ft_lib name 'FT_Stroker_GetCounts';
{**************************************************************
*
* @function:
* FT_Stroker_Export
*
* @description:
* Call this function after @FT_Stroker_GetBorderCounts to
* export the all borders to your own @FT_Outline structure.
*
* Note that this function will append the border points and
* contours to your outline, but will not try to resize its
* arrays.
*
* @input:
* stroker ::
* The target stroker handle.
*
* outline ::
* The target outline handle.
*}
procedure FT_Stroker_Export(
stroker: FT_Stroker;
outline: PFT_Outline );
cdecl; external ft_lib name 'FT_Stroker_Export';
{**************************************************************
*
* @function:
* FT_Stroker_Done
*
* @description:
* Destroy a stroker object.
*
* @input:
* stroker ::
* A stroker handle. Can be NULL.
*}
procedure FT_Stroker_Done( stroker: FT_Stroker );
cdecl; external ft_lib name 'FT_Stroker_Done';
{**************************************************************
*
* @function:
* FT_Glyph_Stroke
*
* @description:
* Stroke a given outline glyph object with a given stroker.
*
* @inout:
* pglyph ::
* Source glyph handle on input, new glyph handle on output.
*
* @input:
* stroker ::
* A stroker handle.
*
* destroy ::
* A Boolean. If 1, the source glyph object is destroyed
* on success.
*
* @return:
* FreeType error code. 0 means success.
*
* @note:
* The source glyph is untouched in case of error.
*}
function FT_Glyph_Stroke(
var glyph: FT_Glyph;
stroker: FT_Stroker;
destroy: FT_Bool ): FT_Error;
cdecl; external ft_lib name 'FT_Glyph_Stroke';
{**************************************************************
*
* @function:
* FT_Glyph_StrokeBorder
*
* @description:
* Stroke a given outline glyph object with a given stroker, but
* only return either its inside or outside border.
*
* @inout:
* pglyph ::
* Source glyph handle on input, new glyph handle on output.
*
* @input:
* stroker ::
* A stroker handle.
*
* inside ::
* A Boolean. If 1, return the inside border, otherwise
* the outside border.
*
* destroy ::
* A Boolean. If 1, the source glyph object is destroyed
* on success.
*
* @return:
* FreeType error code. 0 means success.
*
* @note:
* The source glyph is untouched in case of error.
*}
function FT_Glyph_StrokeBorder(
var glyph: FT_Glyph;
stroker: FT_Stroker;
inside: FT_Bool;
destroy: FT_Bool ): FT_Error;
cdecl; external ft_lib name 'FT_Glyph_StrokeBorder';
{$ENDIF TYPE_DECL}
|