sdk-world
v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Toggle main menu visibility
Loading...
Searching...
No Matches
ftimage.h
Go to the documentation of this file.
1
/****************************************************************************
2
*
3
* ftimage.h
4
*
5
* FreeType glyph image formats and default raster interface
6
* (specification).
7
*
8
* Copyright (C) 1996-2025 by
9
* David Turner, Robert Wilhelm, and Werner Lemberg.
10
*
11
* This file is part of the FreeType project, and may only be used,
12
* modified, and distributed under the terms of the FreeType project
13
* license, LICENSE.TXT. By continuing to use, modify, or distribute
14
* this file you indicate that you have read the license and
15
* understand and accept it fully.
16
*
17
*/
18
19
/**************************************************************************
20
*
21
* Note: A 'raster' is simply a scan-line converter, used to render
22
* `FT_Outline`s into `FT_Bitmap`s.
23
*
24
* Note: This file can be used for `STANDALONE_` compilation of raster
25
* (B/W) and smooth (anti-aliased) renderers. Therefore, it must
26
* rely on standard variable types only instead of aliases in
27
* `fttypes.h`.
28
*
29
*/
30
31
36
#ifndef FTIMAGE_H_
37
#define FTIMAGE_H_
38
39
40
FT_BEGIN_HEADER
41
42
43
/**************************************************************************
44
*
45
* @section:
46
* basic_types
47
*
48
*/
49
50
51
/**************************************************************************
52
*
53
* @type:
54
* FT_Pos
55
*
56
* @description:
57
* The type FT_Pos is used to store vectorial coordinates. Depending on
58
* the context, these can represent distances in integer font units, or
59
* 16.16, or 26.6 fixed-point pixel coordinates.
60
*/
61
typedef
signed
long
FT_Pos;
62
63
64
/**************************************************************************
65
*
66
* @struct:
67
* FT_Vector
68
*
69
* @description:
70
* A simple structure used to store a 2D vector; coordinates are of the
71
* FT_Pos type.
72
*
73
* @fields:
74
* x ::
75
* The horizontal coordinate.
76
* y ::
77
* The vertical coordinate.
78
*/
79
typedef
struct
FT_Vector_
80
{
81
FT_Pos x;
82
FT_Pos y;
83
84
} FT_Vector;
85
86
87
/**************************************************************************
88
*
89
* @struct:
90
* FT_BBox
91
*
92
* @description:
93
* A structure used to hold an outline's bounding box, i.e., the
94
* coordinates of its extrema in the horizontal and vertical directions.
95
*
96
* @fields:
97
* xMin ::
98
* The horizontal minimum (left-most).
99
*
100
* yMin ::
101
* The vertical minimum (bottom-most).
102
*
103
* xMax ::
104
* The horizontal maximum (right-most).
105
*
106
* yMax ::
107
* The vertical maximum (top-most).
108
*
109
* @note:
110
* The bounding box is specified with the coordinates of the lower left
111
* and the upper right corner. In PostScript, those values are often
112
* called (llx,lly) and (urx,ury), respectively.
113
*
114
* If `yMin` is negative, this value gives the glyph's descender.
115
* Otherwise, the glyph doesn't descend below the baseline. Similarly,
116
* if `ymax` is positive, this value gives the glyph's ascender.
117
*
118
* `xMin` gives the horizontal distance from the glyph's origin to the
119
* left edge of the glyph's bounding box. If `xMin` is negative, the
120
* glyph extends to the left of the origin.
121
*/
122
typedef
struct
FT_BBox_
123
{
124
FT_Pos xMin, yMin;
125
FT_Pos xMax, yMax;
126
127
} FT_BBox;
128
129
130
/**************************************************************************
131
*
132
* @enum:
133
* FT_Pixel_Mode
134
*
135
* @description:
136
* An enumeration type used to describe the format of pixels in a given
137
* bitmap. Note that additional formats may be added in the future.
138
*
139
* @values:
140
* FT_PIXEL_MODE_NONE ::
141
* Value~0 is reserved.
142
*
143
* FT_PIXEL_MODE_MONO ::
144
* A monochrome bitmap, using 1~bit per pixel. Note that pixels are
145
* stored in most-significant order (MSB), which means that the
146
* left-most pixel in a byte has value 128.
147
*
148
* FT_PIXEL_MODE_GRAY ::
149
* An 8-bit bitmap, generally used to represent anti-aliased glyph
150
* images. Each pixel is stored in one byte. Note that the number of
151
* 'gray' levels is stored in the `num_grays` field of the @FT_Bitmap
152
* structure (it generally is 256).
153
*
154
* FT_PIXEL_MODE_GRAY2 ::
155
* A 2-bit per pixel bitmap, used to represent embedded anti-aliased
156
* bitmaps in font files according to the OpenType specification. We
157
* haven't found a single font using this format, however.
158
*
159
* FT_PIXEL_MODE_GRAY4 ::
160
* A 4-bit per pixel bitmap, representing embedded anti-aliased bitmaps
161
* in font files according to the OpenType specification. We haven't
162
* found a single font using this format, however.
163
*
164
* FT_PIXEL_MODE_LCD ::
165
* An 8-bit bitmap, representing RGB or BGR decimated glyph images used
166
* for display on LCD displays; the bitmap is three times wider than
167
* the original glyph image. See also @FT_RENDER_MODE_LCD.
168
*
169
* FT_PIXEL_MODE_LCD_V ::
170
* An 8-bit bitmap, representing RGB or BGR decimated glyph images used
171
* for display on rotated LCD displays; the bitmap is three times
172
* taller than the original glyph image. See also
173
* @FT_RENDER_MODE_LCD_V.
174
*
175
* FT_PIXEL_MODE_BGRA ::
176
* [Since 2.5] An image with four 8-bit channels per pixel,
177
* representing a color image (such as emoticons) with alpha channel.
178
* For each pixel, the format is BGRA, which means, the blue channel
179
* comes first in memory. The color channels are pre-multiplied and in
180
* the sRGB colorspace. For example, full red at half-translucent
181
* opacity will be represented as '00,00,80,80', not '00,00,FF,80'.
182
* See also @FT_LOAD_COLOR.
183
*/
184
typedef
enum
FT_Pixel_Mode_
185
{
186
FT_PIXEL_MODE_NONE = 0,
187
FT_PIXEL_MODE_MONO,
188
FT_PIXEL_MODE_GRAY,
189
FT_PIXEL_MODE_GRAY2,
190
FT_PIXEL_MODE_GRAY4,
191
FT_PIXEL_MODE_LCD,
192
FT_PIXEL_MODE_LCD_V,
193
FT_PIXEL_MODE_BGRA,
194
195
FT_PIXEL_MODE_MAX
/* do not remove */
196
197
} FT_Pixel_Mode;
198
199
200
/* these constants are deprecated; use the corresponding `FT_Pixel_Mode` */
201
/* values instead. */
202
#define ft_pixel_mode_none FT_PIXEL_MODE_NONE
203
#define ft_pixel_mode_mono FT_PIXEL_MODE_MONO
204
#define ft_pixel_mode_grays FT_PIXEL_MODE_GRAY
205
#define ft_pixel_mode_pal2 FT_PIXEL_MODE_GRAY2
206
#define ft_pixel_mode_pal4 FT_PIXEL_MODE_GRAY4
207
208
/* */
209
210
/* For debugging, the @FT_Pixel_Mode enumeration must stay in sync */
211
/* with the `pixel_modes` array in file `ftobjs.c`. */
212
213
214
/**************************************************************************
215
*
216
* @struct:
217
* FT_Bitmap
218
*
219
* @description:
220
* A structure used to describe a bitmap or pixmap to the raster. Note
221
* that we now manage pixmaps of various depths through the `pixel_mode`
222
* field.
223
*
224
* @fields:
225
* rows ::
226
* The number of bitmap rows.
227
*
228
* width ::
229
* The number of pixels in bitmap row.
230
*
231
* pitch ::
232
* The pitch's absolute value is the number of bytes taken by one
233
* bitmap row, including padding. However, the pitch is positive when
234
* the bitmap has a 'down' flow, and negative when it has an 'up' flow.
235
* In all cases, the pitch is an offset to add to a bitmap pointer in
236
* order to go down one row.
237
*
238
* Note that 'padding' means the alignment of a bitmap to a byte
239
* border, and FreeType functions normally align to the smallest
240
* possible integer value.
241
*
242
* For the B/W rasterizer, `pitch` is always an even number.
243
*
244
* To change the pitch of a bitmap (say, to make it a multiple of 4),
245
* use @FT_Bitmap_Convert. Alternatively, you might use callback
246
* functions to directly render to the application's surface; see the
247
* file `example2.cpp` in the tutorial for a demonstration.
248
*
249
* buffer ::
250
* A typeless pointer to the bitmap buffer. This value should be
251
* aligned on 32-bit boundaries in most cases.
252
*
253
* num_grays ::
254
* This field is only used with @FT_PIXEL_MODE_GRAY; it gives the
255
* number of gray levels used in the bitmap.
256
*
257
* pixel_mode ::
258
* The pixel mode, i.e., how pixel bits are stored. See @FT_Pixel_Mode
259
* for possible values.
260
*
261
* palette_mode ::
262
* This field is intended for paletted pixel modes; it indicates how
263
* the palette is stored. Not used currently.
264
*
265
* palette ::
266
* A typeless pointer to the bitmap palette; this field is intended for
267
* paletted pixel modes. Not used currently.
268
*
269
* @note:
270
* `width` and `rows` refer to the *physical* size of the bitmap, not the
271
* *logical* one. For example, if @FT_Pixel_Mode is set to
272
* `FT_PIXEL_MODE_LCD`, the logical width is a just a third of the
273
* physical one.
274
*
275
* An empty bitmap with a NULL `buffer` is valid, with `rows` and/or
276
* `pitch` also set to 0. Such bitmaps might be produced while rendering
277
* empty or degenerate outlines.
278
*/
279
typedef
struct
FT_Bitmap_
280
{
281
unsigned
int
rows;
282
unsigned
int
width;
283
int
pitch;
284
unsigned
char
* buffer;
285
unsigned
short
num_grays;
286
unsigned
char
pixel_mode;
287
unsigned
char
palette_mode;
288
void
* palette;
289
290
} FT_Bitmap;
291
292
293
/**************************************************************************
294
*
295
* @section:
296
* outline_processing
297
*
298
*/
299
300
301
/**************************************************************************
302
*
303
* @struct:
304
* FT_Outline
305
*
306
* @description:
307
* This structure is used to describe an outline to the scan-line
308
* converter.
309
*
310
* @fields:
311
* n_contours ::
312
* The number of contours in the outline.
313
*
314
* n_points ::
315
* The number of points in the outline.
316
*
317
* points ::
318
* A pointer to an array of `n_points` @FT_Vector elements, giving the
319
* outline's point coordinates.
320
*
321
* tags ::
322
* A pointer to an array of `n_points` chars, giving each outline
323
* point's type.
324
*
325
* If bit~0 is unset, the point is 'off' the curve, i.e., a Bezier
326
* control point, while it is 'on' if set.
327
*
328
* Bit~1 is meaningful for 'off' points only. If set, it indicates a
329
* third-order Bezier arc control point; and a second-order control
330
* point if unset.
331
*
332
* If bit~2 is set, bits 5-7 contain the drop-out mode (as defined in
333
* the OpenType specification; the value is the same as the argument to
334
* the 'SCANTYPE' instruction).
335
*
336
* Bits 3 and~4 are reserved for internal purposes.
337
*
338
* contours ::
339
* An array of `n_contours` shorts, giving the end point of each
340
* contour within the outline. For example, the first contour is
341
* defined by the points '0' to `contours[0]`, the second one is
342
* defined by the points `contours[0]+1` to `contours[1]`, etc.
343
*
344
* flags ::
345
* A set of bit flags used to characterize the outline and give hints
346
* to the scan-converter and hinter on how to convert/grid-fit it. See
347
* @FT_OUTLINE_XXX.
348
*
349
* @note:
350
* The B/W rasterizer only checks bit~2 in the `tags` array for the first
351
* point of each contour. The drop-out mode as given with
352
* @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, and
353
* @FT_OUTLINE_INCLUDE_STUBS in `flags` is then overridden.
354
*/
355
typedef
struct
FT_Outline_
356
{
357
unsigned
short
n_contours;
/* number of contours in glyph */
358
unsigned
short
n_points;
/* number of points in the glyph */
359
360
FT_Vector* points;
/* the outline's points */
361
unsigned
char
* tags;
/* the points flags */
362
unsigned
short
* contours;
/* the contour end points */
363
364
int
flags;
/* outline masks */
365
366
} FT_Outline;
367
368
/* */
369
370
/* Following limits must be consistent with */
371
/* FT_Outline.{n_contours,n_points} */
372
#define FT_OUTLINE_CONTOURS_MAX USHRT_MAX
373
#define FT_OUTLINE_POINTS_MAX USHRT_MAX
374
375
376
/**************************************************************************
377
*
378
* @enum:
379
* FT_OUTLINE_XXX
380
*
381
* @description:
382
* A list of bit-field constants used for the flags in an outline's
383
* `flags` field.
384
*
385
* @values:
386
* FT_OUTLINE_NONE ::
387
* Value~0 is reserved.
388
*
389
* FT_OUTLINE_OWNER ::
390
* If set, this flag indicates that the outline's field arrays (i.e.,
391
* `points`, `flags`, and `contours`) are 'owned' by the outline
392
* object, and should thus be freed when it is destroyed.
393
*
394
* FT_OUTLINE_EVEN_ODD_FILL ::
395
* By default, outlines are filled using the non-zero winding rule. If
396
* set to 1, the outline will be filled using the even-odd fill rule
397
* (only works with the smooth rasterizer).
398
*
399
* FT_OUTLINE_REVERSE_FILL ::
400
* By default, outside contours of an outline are oriented in
401
* clock-wise direction, as defined in the TrueType specification.
402
* This flag is set if the outline uses the opposite direction
403
* (typically for Type~1 fonts). This flag is ignored by the scan
404
* converter.
405
*
406
* FT_OUTLINE_IGNORE_DROPOUTS ::
407
* By default, the scan converter will try to detect drop-outs in an
408
* outline and correct the glyph bitmap to ensure consistent shape
409
* continuity. If set, this flag hints the scan-line converter to
410
* ignore such cases. See below for more information.
411
*
412
* FT_OUTLINE_SMART_DROPOUTS ::
413
* Select smart dropout control. If unset, use simple dropout control.
414
* Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. See below for more
415
* information.
416
*
417
* FT_OUTLINE_INCLUDE_STUBS ::
418
* If set, turn pixels on for 'stubs', otherwise exclude them. Ignored
419
* if @FT_OUTLINE_IGNORE_DROPOUTS is set. See below for more
420
* information.
421
*
422
* FT_OUTLINE_OVERLAP ::
423
* [Since 2.10.3] This flag indicates that this outline contains
424
* overlapping contours and the anti-aliased renderer should perform
425
* oversampling to mitigate possible artifacts. This flag should _not_
426
* be set for well designed glyphs without overlaps because it quadruples
427
* the rendering time.
428
*
429
* FT_OUTLINE_HIGH_PRECISION ::
430
* This flag indicates that the scan-line converter should try to
431
* convert this outline to bitmaps with the highest possible quality.
432
* It is typically set for small character sizes. Note that this is
433
* only a hint that might be completely ignored by a given
434
* scan-converter.
435
*
436
* FT_OUTLINE_SINGLE_PASS ::
437
* This flag is set to force a given scan-converter to only use a
438
* single pass over the outline to render a bitmap glyph image.
439
* Normally, it is set for very large character sizes. It is only a
440
* hint that might be completely ignored by a given scan-converter.
441
*
442
* @note:
443
* The flags @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, and
444
* @FT_OUTLINE_INCLUDE_STUBS are ignored by the smooth rasterizer.
445
*
446
* There exists a second mechanism to pass the drop-out mode to the B/W
447
* rasterizer; see the `tags` field in @FT_Outline.
448
*
449
* Please refer to the description of the 'SCANTYPE' instruction in the
450
* [OpenType specification](https://learn.microsoft.com/typography/opentype/spec/tt_instructions#scantype)
451
* how simple drop-outs, smart drop-outs, and stubs are defined.
452
*/
453
#define FT_OUTLINE_NONE 0x0
454
#define FT_OUTLINE_OWNER 0x1
455
#define FT_OUTLINE_EVEN_ODD_FILL 0x2
456
#define FT_OUTLINE_REVERSE_FILL 0x4
457
#define FT_OUTLINE_IGNORE_DROPOUTS 0x8
458
#define FT_OUTLINE_SMART_DROPOUTS 0x10
459
#define FT_OUTLINE_INCLUDE_STUBS 0x20
460
#define FT_OUTLINE_OVERLAP 0x40
461
462
#define FT_OUTLINE_HIGH_PRECISION 0x100
463
#define FT_OUTLINE_SINGLE_PASS 0x200
464
465
466
/* these constants are deprecated; use the corresponding */
467
/* `FT_OUTLINE_XXX` values instead */
468
#define ft_outline_none FT_OUTLINE_NONE
469
#define ft_outline_owner FT_OUTLINE_OWNER
470
#define ft_outline_even_odd_fill FT_OUTLINE_EVEN_ODD_FILL
471
#define ft_outline_reverse_fill FT_OUTLINE_REVERSE_FILL
472
#define ft_outline_ignore_dropouts FT_OUTLINE_IGNORE_DROPOUTS
473
#define ft_outline_high_precision FT_OUTLINE_HIGH_PRECISION
474
#define ft_outline_single_pass FT_OUTLINE_SINGLE_PASS
475
476
/* */
477
478
#define FT_CURVE_TAG( flag ) ( flag & 0x03 )
479
480
/* see the `tags` field in `FT_Outline` for a description of the values */
481
#define FT_CURVE_TAG_ON 0x01
482
#define FT_CURVE_TAG_CONIC 0x00
483
#define FT_CURVE_TAG_CUBIC 0x02
484
485
#define FT_CURVE_TAG_HAS_SCANMODE 0x04
486
487
#define FT_CURVE_TAG_TOUCH_X 0x08
/* reserved for TrueType hinter */
488
#define FT_CURVE_TAG_TOUCH_Y 0x10
/* reserved for TrueType hinter */
489
490
#define FT_CURVE_TAG_TOUCH_BOTH ( FT_CURVE_TAG_TOUCH_X | \
491
FT_CURVE_TAG_TOUCH_Y )
492
/* values 0x20, 0x40, and 0x80 are reserved */
493
494
495
/* these constants are deprecated; use the corresponding */
496
/* `FT_CURVE_TAG_XXX` values instead */
497
#define FT_Curve_Tag_On FT_CURVE_TAG_ON
498
#define FT_Curve_Tag_Conic FT_CURVE_TAG_CONIC
499
#define FT_Curve_Tag_Cubic FT_CURVE_TAG_CUBIC
500
#define FT_Curve_Tag_Touch_X FT_CURVE_TAG_TOUCH_X
501
#define FT_Curve_Tag_Touch_Y FT_CURVE_TAG_TOUCH_Y
502
503
504
/**************************************************************************
505
*
506
* @functype:
507
* FT_Outline_MoveToFunc
508
*
509
* @description:
510
* A function pointer type used to describe the signature of a 'move to'
511
* function during outline walking/decomposition.
512
*
513
* A 'move to' is emitted to start a new contour in an outline.
514
*
515
* @input:
516
* to ::
517
* A pointer to the target point of the 'move to'.
518
*
519
* user ::
520
* A typeless pointer, which is passed from the caller of the
521
* decomposition function.
522
*
523
* @return:
524
* Error code. 0~means success.
525
*/
526
typedef
int
527
(*FT_Outline_MoveToFunc)(
const
FT_Vector* to,
528
void
* user );
529
530
#define FT_Outline_MoveTo_Func FT_Outline_MoveToFunc
531
532
533
/**************************************************************************
534
*
535
* @functype:
536
* FT_Outline_LineToFunc
537
*
538
* @description:
539
* A function pointer type used to describe the signature of a 'line to'
540
* function during outline walking/decomposition.
541
*
542
* A 'line to' is emitted to indicate a segment in the outline.
543
*
544
* @input:
545
* to ::
546
* A pointer to the target point of the 'line to'.
547
*
548
* user ::
549
* A typeless pointer, which is passed from the caller of the
550
* decomposition function.
551
*
552
* @return:
553
* Error code. 0~means success.
554
*/
555
typedef
int
556
(*FT_Outline_LineToFunc)(
const
FT_Vector* to,
557
void
* user );
558
559
#define FT_Outline_LineTo_Func FT_Outline_LineToFunc
560
561
562
/**************************************************************************
563
*
564
* @functype:
565
* FT_Outline_ConicToFunc
566
*
567
* @description:
568
* A function pointer type used to describe the signature of a 'conic to'
569
* function during outline walking or decomposition.
570
*
571
* A 'conic to' is emitted to indicate a second-order Bezier arc in the
572
* outline.
573
*
574
* @input:
575
* control ::
576
* An intermediate control point between the last position and the new
577
* target in `to`.
578
*
579
* to ::
580
* A pointer to the target end point of the conic arc.
581
*
582
* user ::
583
* A typeless pointer, which is passed from the caller of the
584
* decomposition function.
585
*
586
* @return:
587
* Error code. 0~means success.
588
*/
589
typedef
int
590
(*FT_Outline_ConicToFunc)(
const
FT_Vector* control,
591
const
FT_Vector* to,
592
void
* user );
593
594
#define FT_Outline_ConicTo_Func FT_Outline_ConicToFunc
595
596
597
/**************************************************************************
598
*
599
* @functype:
600
* FT_Outline_CubicToFunc
601
*
602
* @description:
603
* A function pointer type used to describe the signature of a 'cubic to'
604
* function during outline walking or decomposition.
605
*
606
* A 'cubic to' is emitted to indicate a third-order Bezier arc.
607
*
608
* @input:
609
* control1 ::
610
* A pointer to the first Bezier control point.
611
*
612
* control2 ::
613
* A pointer to the second Bezier control point.
614
*
615
* to ::
616
* A pointer to the target end point.
617
*
618
* user ::
619
* A typeless pointer, which is passed from the caller of the
620
* decomposition function.
621
*
622
* @return:
623
* Error code. 0~means success.
624
*/
625
typedef
int
626
(*FT_Outline_CubicToFunc)(
const
FT_Vector* control1,
627
const
FT_Vector* control2,
628
const
FT_Vector* to,
629
void
* user );
630
631
#define FT_Outline_CubicTo_Func FT_Outline_CubicToFunc
632
633
634
/**************************************************************************
635
*
636
* @struct:
637
* FT_Outline_Funcs
638
*
639
* @description:
640
* A structure to hold various function pointers used during outline
641
* decomposition in order to emit segments, conic, and cubic Beziers.
642
*
643
* @fields:
644
* move_to ::
645
* The 'move to' emitter.
646
*
647
* line_to ::
648
* The segment emitter.
649
*
650
* conic_to ::
651
* The second-order Bezier arc emitter.
652
*
653
* cubic_to ::
654
* The third-order Bezier arc emitter.
655
*
656
* shift ::
657
* The shift that is applied to coordinates before they are sent to the
658
* emitter.
659
*
660
* delta ::
661
* The delta that is applied to coordinates before they are sent to the
662
* emitter, but after the shift.
663
*
664
* @note:
665
* The point coordinates sent to the emitters are the transformed version
666
* of the original coordinates (this is important for high accuracy
667
* during scan-conversion). The transformation is simple:
668
*
669
* ```
670
* x' = (x << shift) - delta
671
* y' = (y << shift) - delta
672
* ```
673
*
674
* Set the values of `shift` and `delta` to~0 to get the original point
675
* coordinates.
676
*/
677
typedef
struct
FT_Outline_Funcs_
678
{
679
FT_Outline_MoveToFunc move_to;
680
FT_Outline_LineToFunc line_to;
681
FT_Outline_ConicToFunc conic_to;
682
FT_Outline_CubicToFunc cubic_to;
683
684
int
shift;
685
FT_Pos delta;
686
687
} FT_Outline_Funcs;
688
689
690
/**************************************************************************
691
*
692
* @section:
693
* basic_types
694
*
695
*/
696
697
698
/**************************************************************************
699
*
700
* @macro:
701
* FT_IMAGE_TAG
702
*
703
* @description:
704
* This macro converts four-letter tags to an unsigned long type.
705
*
706
* @note:
707
* Since many 16-bit compilers don't like 32-bit enumerations, you should
708
* redefine this macro in case of problems to something like this:
709
*
710
* ```
711
* #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) value
712
* ```
713
*
714
* to get a simple enumeration without assigning special numbers.
715
*/
716
#ifndef FT_IMAGE_TAG
717
718
#define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \
719
value = ( ( FT_STATIC_BYTE_CAST( unsigned long, _x1 ) << 24 ) | \
720
( FT_STATIC_BYTE_CAST( unsigned long, _x2 ) << 16 ) | \
721
( FT_STATIC_BYTE_CAST( unsigned long, _x3 ) << 8 ) | \
722
FT_STATIC_BYTE_CAST( unsigned long, _x4 ) )
723
724
#endif
/* FT_IMAGE_TAG */
725
726
727
/**************************************************************************
728
*
729
* @enum:
730
* FT_Glyph_Format
731
*
732
* @description:
733
* An enumeration type used to describe the format of a given glyph
734
* image. Note that this version of FreeType only supports two image
735
* formats, even though future font drivers will be able to register
736
* their own format.
737
*
738
* @values:
739
* FT_GLYPH_FORMAT_NONE ::
740
* The value~0 is reserved.
741
*
742
* FT_GLYPH_FORMAT_COMPOSITE ::
743
* The glyph image is a composite of several other images. This format
744
* is _only_ used with @FT_LOAD_NO_RECURSE, and is used to report
745
* compound glyphs (like accented characters).
746
*
747
* FT_GLYPH_FORMAT_BITMAP ::
748
* The glyph image is a bitmap, and can be described as an @FT_Bitmap.
749
* You generally need to access the `bitmap` field of the
750
* @FT_GlyphSlotRec structure to read it.
751
*
752
* FT_GLYPH_FORMAT_OUTLINE ::
753
* The glyph image is a vectorial outline made of line segments and
754
* Bezier arcs; it can be described as an @FT_Outline; you generally
755
* want to access the `outline` field of the @FT_GlyphSlotRec structure
756
* to read it.
757
*
758
* FT_GLYPH_FORMAT_PLOTTER ::
759
* The glyph image is a vectorial path with no inside and outside
760
* contours. Some Type~1 fonts, like those in the Hershey family,
761
* contain glyphs in this format. These are described as @FT_Outline,
762
* but FreeType isn't currently capable of rendering them correctly.
763
*
764
* FT_GLYPH_FORMAT_SVG ::
765
* [Since 2.12] The glyph is represented by an SVG document in the
766
* 'SVG~' table.
767
*/
768
typedef
enum
FT_Glyph_Format_
769
{
770
FT_IMAGE_TAG( FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0 ),
771
772
FT_IMAGE_TAG( FT_GLYPH_FORMAT_COMPOSITE,
'c'
,
'o'
,
'm'
,
'p'
),
773
FT_IMAGE_TAG( FT_GLYPH_FORMAT_BITMAP,
'b'
,
'i'
,
't'
,
's'
),
774
FT_IMAGE_TAG( FT_GLYPH_FORMAT_OUTLINE,
'o'
,
'u'
,
't'
,
'l'
),
775
FT_IMAGE_TAG( FT_GLYPH_FORMAT_PLOTTER,
'p'
,
'l'
,
'o'
,
't'
),
776
FT_IMAGE_TAG( FT_GLYPH_FORMAT_SVG,
'S'
,
'V'
,
'G'
,
' '
)
777
778
} FT_Glyph_Format;
779
780
781
/* these constants are deprecated; use the corresponding */
782
/* `FT_Glyph_Format` values instead. */
783
#define ft_glyph_format_none FT_GLYPH_FORMAT_NONE
784
#define ft_glyph_format_composite FT_GLYPH_FORMAT_COMPOSITE
785
#define ft_glyph_format_bitmap FT_GLYPH_FORMAT_BITMAP
786
#define ft_glyph_format_outline FT_GLYPH_FORMAT_OUTLINE
787
#define ft_glyph_format_plotter FT_GLYPH_FORMAT_PLOTTER
788
789
790
/*************************************************************************/
791
/*************************************************************************/
792
/*************************************************************************/
793
/***** *****/
794
/***** R A S T E R D E F I N I T I O N S *****/
795
/***** *****/
796
/*************************************************************************/
797
/*************************************************************************/
798
/*************************************************************************/
799
800
801
802
/**************************************************************************
803
*
804
* @section:
805
* raster
806
*
807
* @title:
808
* Scanline Converter
809
*
810
* @abstract:
811
* How vectorial outlines are converted into bitmaps and pixmaps.
812
*
813
* @description:
814
* A raster or a rasterizer is a scan converter in charge of producing a
815
* pixel coverage bitmap that can be used as an alpha channel when
816
* compositing a glyph with a background. FreeType comes with two
817
* rasterizers: bilevel `raster1` and anti-aliased `smooth` are two
818
* separate modules. They are usually called from the high-level
819
* @FT_Load_Glyph or @FT_Render_Glyph functions and produce the entire
820
* coverage bitmap at once, while staying largely invisible to users.
821
*
822
* Instead of working with complete coverage bitmaps, it is also possible
823
* to intercept consecutive pixel runs on the same scanline with the same
824
* coverage, called _spans_, and process them individually. Only the
825
* `smooth` rasterizer permits this when calling @FT_Outline_Render with
826
* @FT_Raster_Params as described below.
827
*
828
* Working with either complete bitmaps or spans it is important to think
829
* of them as colorless coverage objects suitable as alpha channels to
830
* blend arbitrary colors with a background. For best results, it is
831
* recommended to use gamma correction, too.
832
*
833
* This section also describes the public API needed to set up alternative
834
* @FT_Renderer modules.
835
*
836
* @order:
837
* FT_Span
838
* FT_SpanFunc
839
* FT_Raster_Params
840
* FT_RASTER_FLAG_XXX
841
*
842
* FT_Raster
843
* FT_Raster_NewFunc
844
* FT_Raster_DoneFunc
845
* FT_Raster_ResetFunc
846
* FT_Raster_SetModeFunc
847
* FT_Raster_RenderFunc
848
* FT_Raster_Funcs
849
*
850
*/
851
852
853
/**************************************************************************
854
*
855
* @struct:
856
* FT_Span
857
*
858
* @description:
859
* A structure to model a single span of consecutive pixels when
860
* rendering an anti-aliased bitmap.
861
*
862
* @fields:
863
* x ::
864
* The span's horizontal start position.
865
*
866
* len ::
867
* The span's length in pixels.
868
*
869
* coverage ::
870
* The span color/coverage, ranging from 0 (background) to 255
871
* (foreground).
872
*
873
* @note:
874
* This structure is used by the span drawing callback type named
875
* @FT_SpanFunc that takes the y~coordinate of the span as a parameter.
876
*
877
* The anti-aliased rasterizer produces coverage values from 0 to 255,
878
* that is, from completely transparent to completely opaque.
879
*/
880
typedef
struct
FT_Span_
881
{
882
short
x;
883
unsigned
short
len;
884
unsigned
char
coverage;
885
886
} FT_Span;
887
888
889
/**************************************************************************
890
*
891
* @functype:
892
* FT_SpanFunc
893
*
894
* @description:
895
* A function used as a call-back by the anti-aliased renderer in order
896
* to let client applications draw themselves the pixel spans on each
897
* scan line.
898
*
899
* @input:
900
* y ::
901
* The scanline's upward y~coordinate.
902
*
903
* count ::
904
* The number of spans to draw on this scanline.
905
*
906
* spans ::
907
* A table of `count` spans to draw on the scanline.
908
*
909
* user ::
910
* User-supplied data that is passed to the callback.
911
*
912
* @note:
913
* This callback allows client applications to directly render the spans
914
* of the anti-aliased bitmap to any kind of surfaces.
915
*
916
* This can be used to write anti-aliased outlines directly to a given
917
* background bitmap using alpha compositing. It can also be used for
918
* oversampling and averaging.
919
*/
920
typedef
void
921
(*FT_SpanFunc)(
int
y,
922
int
count,
923
const
FT_Span* spans,
924
void
* user );
925
926
#define FT_Raster_Span_Func FT_SpanFunc
927
928
929
/**************************************************************************
930
*
931
* @functype:
932
* FT_Raster_BitTest_Func
933
*
934
* @description:
935
* Deprecated, unimplemented.
936
*/
937
typedef
int
938
(*FT_Raster_BitTest_Func)(
int
y,
939
int
x,
940
void
* user );
941
942
943
/**************************************************************************
944
*
945
* @functype:
946
* FT_Raster_BitSet_Func
947
*
948
* @description:
949
* Deprecated, unimplemented.
950
*/
951
typedef
void
952
(*FT_Raster_BitSet_Func)(
int
y,
953
int
x,
954
void
* user );
955
956
957
/**************************************************************************
958
*
959
* @enum:
960
* FT_RASTER_FLAG_XXX
961
*
962
* @description:
963
* A list of bit flag constants as used in the `flags` field of a
964
* @FT_Raster_Params structure.
965
*
966
* @values:
967
* FT_RASTER_FLAG_DEFAULT ::
968
* This value is 0.
969
*
970
* FT_RASTER_FLAG_AA ::
971
* This flag is set to indicate that an anti-aliased glyph image should
972
* be generated. Otherwise, it will be monochrome (1-bit).
973
*
974
* FT_RASTER_FLAG_DIRECT ::
975
* This flag is set to indicate direct rendering. In this mode, client
976
* applications must provide their own span callback. This lets them
977
* directly draw or compose over an existing bitmap. If this bit is
978
* _not_ set, the target pixmap's buffer _must_ be zeroed before
979
* rendering and the output will be clipped to its size.
980
*
981
* Direct rendering is only possible with anti-aliased glyphs.
982
*
983
* FT_RASTER_FLAG_CLIP ::
984
* This flag is only used in direct rendering mode. If set, the output
985
* will be clipped to a box specified in the `clip_box` field of the
986
* @FT_Raster_Params structure. Otherwise, the `clip_box` is
987
* effectively set to the bounding box and all spans are generated.
988
*
989
* FT_RASTER_FLAG_SDF ::
990
* This flag is set to indicate that a signed distance field glyph
991
* image should be generated. This is only used while rendering with
992
* the @FT_RENDER_MODE_SDF render mode.
993
*/
994
#define FT_RASTER_FLAG_DEFAULT 0x0
995
#define FT_RASTER_FLAG_AA 0x1
996
#define FT_RASTER_FLAG_DIRECT 0x2
997
#define FT_RASTER_FLAG_CLIP 0x4
998
#define FT_RASTER_FLAG_SDF 0x8
999
1000
/* these constants are deprecated; use the corresponding */
1001
/* `FT_RASTER_FLAG_XXX` values instead */
1002
#define ft_raster_flag_default FT_RASTER_FLAG_DEFAULT
1003
#define ft_raster_flag_aa FT_RASTER_FLAG_AA
1004
#define ft_raster_flag_direct FT_RASTER_FLAG_DIRECT
1005
#define ft_raster_flag_clip FT_RASTER_FLAG_CLIP
1006
1007
1008
/**************************************************************************
1009
*
1010
* @struct:
1011
* FT_Raster_Params
1012
*
1013
* @description:
1014
* A structure to hold the parameters used by a raster's render function,
1015
* passed as an argument to @FT_Outline_Render.
1016
*
1017
* @fields:
1018
* target ::
1019
* The target bitmap.
1020
*
1021
* source ::
1022
* A pointer to the source glyph image (e.g., an @FT_Outline).
1023
*
1024
* flags ::
1025
* The rendering flags.
1026
*
1027
* gray_spans ::
1028
* The gray span drawing callback.
1029
*
1030
* black_spans ::
1031
* Unused.
1032
*
1033
* bit_test ::
1034
* Unused.
1035
*
1036
* bit_set ::
1037
* Unused.
1038
*
1039
* user ::
1040
* User-supplied data that is passed to each drawing callback.
1041
*
1042
* clip_box ::
1043
* An optional span clipping box expressed in _integer_ pixels
1044
* (not in 26.6 fixed-point units).
1045
*
1046
* @note:
1047
* The @FT_RASTER_FLAG_AA bit flag must be set in the `flags` to
1048
* generate an anti-aliased glyph bitmap, otherwise a monochrome bitmap
1049
* is generated. The `target` should have appropriate pixel mode and its
1050
* dimensions define the clipping region.
1051
*
1052
* If both @FT_RASTER_FLAG_AA and @FT_RASTER_FLAG_DIRECT bit flags
1053
* are set in `flags`, the raster calls an @FT_SpanFunc callback
1054
* `gray_spans` with `user` data as an argument ignoring `target`. This
1055
* allows direct composition over a pre-existing user surface to perform
1056
* the span drawing and composition. To optionally clip the spans, set
1057
* the @FT_RASTER_FLAG_CLIP flag and `clip_box`. The monochrome raster
1058
* does not support the direct mode.
1059
*
1060
* The gray-level rasterizer always uses 256 gray levels. If you want
1061
* fewer gray levels, you have to use @FT_RASTER_FLAG_DIRECT and reduce
1062
* the levels in the callback function.
1063
*/
1064
typedef
struct
FT_Raster_Params_
1065
{
1066
const
FT_Bitmap* target;
1067
const
void
* source;
1068
int
flags;
1069
FT_SpanFunc gray_spans;
1070
FT_SpanFunc black_spans;
/* unused */
1071
FT_Raster_BitTest_Func bit_test;
/* unused */
1072
FT_Raster_BitSet_Func bit_set;
/* unused */
1073
void
* user;
1074
FT_BBox clip_box;
1075
1076
} FT_Raster_Params;
1077
1078
1079
/**************************************************************************
1080
*
1081
* @type:
1082
* FT_Raster
1083
*
1084
* @description:
1085
* An opaque handle (pointer) to a raster object. Each object can be
1086
* used independently to convert an outline into a bitmap or pixmap.
1087
*
1088
* @note:
1089
* In FreeType 2, all rasters are now encapsulated within specific
1090
* @FT_Renderer modules and only used in their context.
1091
*
1092
*/
1093
typedef
struct
FT_RasterRec_* FT_Raster;
1094
1095
1096
/**************************************************************************
1097
*
1098
* @functype:
1099
* FT_Raster_NewFunc
1100
*
1101
* @description:
1102
* A function used to create a new raster object.
1103
*
1104
* @input:
1105
* memory ::
1106
* A handle to the memory allocator.
1107
*
1108
* @output:
1109
* raster ::
1110
* A handle to the new raster object.
1111
*
1112
* @return:
1113
* Error code. 0~means success.
1114
*
1115
* @note:
1116
* The `memory` parameter is a typeless pointer in order to avoid
1117
* un-wanted dependencies on the rest of the FreeType code. In practice,
1118
* it is an @FT_Memory object, i.e., a handle to the standard FreeType
1119
* memory allocator. However, this field can be completely ignored by a
1120
* given raster implementation.
1121
*/
1122
typedef
int
1123
(*FT_Raster_NewFunc)(
void
* memory,
1124
FT_Raster* raster );
1125
1126
#define FT_Raster_New_Func FT_Raster_NewFunc
1127
1128
1129
/**************************************************************************
1130
*
1131
* @functype:
1132
* FT_Raster_DoneFunc
1133
*
1134
* @description:
1135
* A function used to destroy a given raster object.
1136
*
1137
* @input:
1138
* raster ::
1139
* A handle to the raster object.
1140
*/
1141
typedef
void
1142
(*FT_Raster_DoneFunc)( FT_Raster raster );
1143
1144
#define FT_Raster_Done_Func FT_Raster_DoneFunc
1145
1146
1147
/**************************************************************************
1148
*
1149
* @functype:
1150
* FT_Raster_ResetFunc
1151
*
1152
* @description:
1153
* FreeType used to provide an area of memory called the 'render pool'
1154
* available to all registered rasterizers. This was not thread safe,
1155
* however, and now FreeType never allocates this pool.
1156
*
1157
* This function is called after a new raster object is created.
1158
*
1159
* @input:
1160
* raster ::
1161
* A handle to the new raster object.
1162
*
1163
* pool_base ::
1164
* Previously, the address in memory of the render pool. Set this to
1165
* `NULL`.
1166
*
1167
* pool_size ::
1168
* Previously, the size in bytes of the render pool. Set this to 0.
1169
*
1170
* @note:
1171
* Rasterizers should rely on dynamic or stack allocation if they want to
1172
* (a handle to the memory allocator is passed to the rasterizer
1173
* constructor).
1174
*/
1175
typedef
void
1176
(*FT_Raster_ResetFunc)( FT_Raster raster,
1177
unsigned
char
* pool_base,
1178
unsigned
long
pool_size );
1179
1180
#define FT_Raster_Reset_Func FT_Raster_ResetFunc
1181
1182
1183
/**************************************************************************
1184
*
1185
* @functype:
1186
* FT_Raster_SetModeFunc
1187
*
1188
* @description:
1189
* This function is a generic facility to change modes or attributes in a
1190
* given raster. This can be used for debugging purposes, or simply to
1191
* allow implementation-specific 'features' in a given raster module.
1192
*
1193
* @input:
1194
* raster ::
1195
* A handle to the new raster object.
1196
*
1197
* mode ::
1198
* A 4-byte tag used to name the mode or property.
1199
*
1200
* args ::
1201
* A pointer to the new mode/property to use.
1202
*/
1203
typedef
int
1204
(*FT_Raster_SetModeFunc)( FT_Raster raster,
1205
unsigned
long
mode,
1206
void
* args );
1207
1208
#define FT_Raster_Set_Mode_Func FT_Raster_SetModeFunc
1209
1210
1211
/**************************************************************************
1212
*
1213
* @functype:
1214
* FT_Raster_RenderFunc
1215
*
1216
* @description:
1217
* Invoke a given raster to scan-convert a given glyph image into a
1218
* target bitmap.
1219
*
1220
* @input:
1221
* raster ::
1222
* A handle to the raster object.
1223
*
1224
* params ::
1225
* A pointer to an @FT_Raster_Params structure used to store the
1226
* rendering parameters.
1227
*
1228
* @return:
1229
* Error code. 0~means success.
1230
*
1231
* @note:
1232
* The exact format of the source image depends on the raster's glyph
1233
* format defined in its @FT_Raster_Funcs structure. It can be an
1234
* @FT_Outline or anything else in order to support a large array of
1235
* glyph formats.
1236
*
1237
* Note also that the render function can fail and return a
1238
* `FT_Err_Unimplemented_Feature` error code if the raster used does not
1239
* support direct composition.
1240
*/
1241
typedef
int
1242
(*FT_Raster_RenderFunc)( FT_Raster raster,
1243
const
FT_Raster_Params* params );
1244
1245
#define FT_Raster_Render_Func FT_Raster_RenderFunc
1246
1247
1248
/**************************************************************************
1249
*
1250
* @struct:
1251
* FT_Raster_Funcs
1252
*
1253
* @description:
1254
* A structure used to describe a given raster class to the library.
1255
*
1256
* @fields:
1257
* glyph_format ::
1258
* The supported glyph format for this raster.
1259
*
1260
* raster_new ::
1261
* The raster constructor.
1262
*
1263
* raster_reset ::
1264
* Used to reset the render pool within the raster.
1265
*
1266
* raster_render ::
1267
* A function to render a glyph into a given bitmap.
1268
*
1269
* raster_done ::
1270
* The raster destructor.
1271
*/
1272
typedef
struct
FT_Raster_Funcs_
1273
{
1274
FT_Glyph_Format glyph_format;
1275
1276
FT_Raster_NewFunc raster_new;
1277
FT_Raster_ResetFunc raster_reset;
1278
FT_Raster_SetModeFunc raster_set_mode;
1279
FT_Raster_RenderFunc raster_render;
1280
FT_Raster_DoneFunc raster_done;
1281
1282
} FT_Raster_Funcs;
1283
1284
/* */
1285
1286
1287
FT_END_HEADER
1288
1289
#endif
/* FTIMAGE_H_ */
1290
1291
1292
/* END */
1293
1294
1295
/* Local Variables: */
1296
/* coding: utf-8 */
1297
/* End: */
FT_BBox_
Definition
ftimage.h:123
FT_Bitmap_
Definition
ftimage.h:280
FT_Outline_Funcs_
Definition
ftimage.h:678
FT_Outline_
Definition
ftimage.h:356
FT_Raster_Funcs_
Definition
ftimage.h:1273
FT_Raster_Params_
Definition
ftimage.h:1065
FT_Span_
Definition
ftimage.h:881
FT_Vector_
Definition
ftimage.h:80
freetype
include
freetype
ftimage.h
Generated by
1.18.0