sdk-world v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Loading...
Searching...
No Matches
ftcolor.h
Go to the documentation of this file.
1/****************************************************************************
2 *
3 * ftcolor.h
4 *
5 * FreeType's glyph color management (specification).
6 *
7 * Copyright (C) 2018-2025 by
8 * David Turner, Robert Wilhelm, and Werner Lemberg.
9 *
10 * This file is part of the FreeType project, and may only be used,
11 * modified, and distributed under the terms of the FreeType project
12 * license, LICENSE.TXT. By continuing to use, modify, or distribute
13 * this file you indicate that you have read the license and
14 * understand and accept it fully.
15 *
16 */
17
18
23#ifndef FTCOLOR_H_
24#define FTCOLOR_H_
25
26#include <freetype/freetype.h>
27
28#ifdef FREETYPE_H
29#error "freetype.h of FreeType 1 has been loaded!"
30#error "Please fix the directory search order for header files"
31#error "so that freetype.h of FreeType 2 is found first."
32#endif
33
34
35FT_BEGIN_HEADER
36
37
38 /**************************************************************************
39 *
40 * @section:
41 * color_management
42 *
43 * @title:
44 * Glyph Color Management
45 *
46 * @abstract:
47 * Retrieving and manipulating OpenType's 'CPAL' table data.
48 *
49 * @description:
50 * The functions described here allow access and manipulation of color
51 * palette entries in OpenType's 'CPAL' tables.
52 */
53
54
55 /**************************************************************************
56 *
57 * @struct:
58 * FT_Color
59 *
60 * @description:
61 * This structure models a BGRA color value of a 'CPAL' palette entry.
62 *
63 * The used color space is sRGB; the colors are not pre-multiplied, and
64 * alpha values must be explicitly set.
65 *
66 * @fields:
67 * blue ::
68 * Blue value.
69 *
70 * green ::
71 * Green value.
72 *
73 * red ::
74 * Red value.
75 *
76 * alpha ::
77 * Alpha value, giving the red, green, and blue color's opacity.
78 *
79 * @since:
80 * 2.10
81 */
82 typedef struct FT_Color_
83 {
84 FT_Byte blue;
85 FT_Byte green;
86 FT_Byte red;
87 FT_Byte alpha;
88
89 } FT_Color;
90
91
92 /**************************************************************************
93 *
94 * @enum:
95 * FT_PALETTE_XXX
96 *
97 * @description:
98 * A list of bit field constants used in the `palette_flags` array of the
99 * @FT_Palette_Data structure to indicate for which background a palette
100 * with a given index is usable.
101 *
102 * @values:
103 * FT_PALETTE_FOR_LIGHT_BACKGROUND ::
104 * The palette is appropriate to use when displaying the font on a
105 * light background such as white.
106 *
107 * FT_PALETTE_FOR_DARK_BACKGROUND ::
108 * The palette is appropriate to use when displaying the font on a dark
109 * background such as black.
110 *
111 * @since:
112 * 2.10
113 */
114#define FT_PALETTE_FOR_LIGHT_BACKGROUND 0x01
115#define FT_PALETTE_FOR_DARK_BACKGROUND 0x02
116
117
118 /**************************************************************************
119 *
120 * @struct:
121 * FT_Palette_Data
122 *
123 * @description:
124 * This structure holds the data of the 'CPAL' table.
125 *
126 * @fields:
127 * num_palettes ::
128 * The number of palettes.
129 *
130 * palette_name_ids ::
131 * An optional read-only array of palette name IDs with `num_palettes`
132 * elements, corresponding to entries like 'dark' or 'light' in the
133 * font's 'name' table.
134 *
135 * An empty name ID in the 'CPAL' table gets represented as value
136 * 0xFFFF.
137 *
138 * `NULL` if the font's 'CPAL' table doesn't contain appropriate data.
139 *
140 * palette_flags ::
141 * An optional read-only array of palette flags with `num_palettes`
142 * elements. Possible values are an ORed combination of
143 * @FT_PALETTE_FOR_LIGHT_BACKGROUND and
144 * @FT_PALETTE_FOR_DARK_BACKGROUND.
145 *
146 * `NULL` if the font's 'CPAL' table doesn't contain appropriate data.
147 *
148 * num_palette_entries ::
149 * The number of entries in a single palette. All palettes have the
150 * same size.
151 *
152 * palette_entry_name_ids ::
153 * An optional read-only array of palette entry name IDs with
154 * `num_palette_entries`. In each palette, entries with the same index
155 * have the same function. For example, index~0 might correspond to
156 * string 'outline' in the font's 'name' table to indicate that this
157 * palette entry is used for outlines, index~1 might correspond to
158 * 'fill' to indicate the filling color palette entry, etc.
159 *
160 * An empty entry name ID in the 'CPAL' table gets represented as value
161 * 0xFFFF.
162 *
163 * `NULL` if the font's 'CPAL' table doesn't contain appropriate data.
164 *
165 * @note:
166 * Use function @FT_Get_Sfnt_Name to map name IDs and entry name IDs to
167 * name strings.
168 *
169 * Use function @FT_Palette_Select to get the colors associated with a
170 * palette entry.
171 *
172 * @since:
173 * 2.10
174 */
175 typedef struct FT_Palette_Data_ {
176 FT_UShort num_palettes;
177 const FT_UShort* palette_name_ids;
178 const FT_UShort* palette_flags;
179
180 FT_UShort num_palette_entries;
181 const FT_UShort* palette_entry_name_ids;
182
183 } FT_Palette_Data;
184
185
186 /**************************************************************************
187 *
188 * @function:
189 * FT_Palette_Data_Get
190 *
191 * @description:
192 * Retrieve the face's color palette data.
193 *
194 * @input:
195 * face ::
196 * The source face handle.
197 *
198 * @output:
199 * apalette ::
200 * A pointer to an @FT_Palette_Data structure.
201 *
202 * @return:
203 * FreeType error code. 0~means success.
204 *
205 * @note:
206 * All arrays in the returned @FT_Palette_Data structure are read-only.
207 *
208 * This function always returns an error if the config macro
209 * `TT_CONFIG_OPTION_COLOR_LAYERS` is not defined in `ftoption.h`.
210 *
211 * @since:
212 * 2.10
213 */
214 FT_EXPORT( FT_Error )
215 FT_Palette_Data_Get( FT_Face face,
216 FT_Palette_Data *apalette );
217
218
219 /**************************************************************************
220 *
221 * @function:
222 * FT_Palette_Select
223 *
224 * @description:
225 * This function has two purposes.
226 *
227 * (1) It activates a palette for rendering color glyphs, and
228 *
229 * (2) it retrieves all (unmodified) color entries of this palette. This
230 * function returns a read-write array, which means that a calling
231 * application can modify the palette entries on demand.
232 *
233 * A corollary of (2) is that calling the function, then modifying some
234 * values, then calling the function again with the same arguments resets
235 * all color entries to the original 'CPAL' values; all user modifications
236 * are lost.
237 *
238 * @input:
239 * face ::
240 * The source face handle.
241 *
242 * palette_index ::
243 * The palette index.
244 *
245 * @output:
246 * apalette ::
247 * An array of color entries for a palette with index `palette_index`,
248 * having `num_palette_entries` elements (as found in the
249 * `FT_Palette_Data` structure). If `apalette` is set to `NULL`, no
250 * array gets returned (and no color entries can be modified).
251 *
252 * In case the font doesn't support color palettes, `NULL` is returned.
253 *
254 * @return:
255 * FreeType error code. 0~means success.
256 *
257 * @note:
258 * The array pointed to by `apalette_entries` is owned and managed by
259 * FreeType.
260 *
261 * This function always returns an error if the config macro
262 * `TT_CONFIG_OPTION_COLOR_LAYERS` is not defined in `ftoption.h`.
263 *
264 * @since:
265 * 2.10
266 */
267 FT_EXPORT( FT_Error )
268 FT_Palette_Select( FT_Face face,
269 FT_UShort palette_index,
270 FT_Color* *apalette );
271
272
273 /**************************************************************************
274 *
275 * @function:
276 * FT_Palette_Set_Foreground_Color
277 *
278 * @description:
279 * 'COLR' uses palette index 0xFFFF to indicate a 'text foreground
280 * color'. This function sets this value.
281 *
282 * @input:
283 * face ::
284 * The source face handle.
285 *
286 * foreground_color ::
287 * An `FT_Color` structure to define the text foreground color.
288 *
289 * @return:
290 * FreeType error code. 0~means success.
291 *
292 * @note:
293 * If this function isn't called, the text foreground color is set to
294 * white opaque (BGRA value 0xFFFFFFFF) if
295 * @FT_PALETTE_FOR_DARK_BACKGROUND is present for the current palette,
296 * and black opaque (BGRA value 0x000000FF) otherwise, including the case
297 * that no palette types are available in the 'CPAL' table.
298 *
299 * This function always returns an error if the config macro
300 * `TT_CONFIG_OPTION_COLOR_LAYERS` is not defined in `ftoption.h`.
301 *
302 * @since:
303 * 2.10
304 */
305 FT_EXPORT( FT_Error )
306 FT_Palette_Set_Foreground_Color( FT_Face face,
307 FT_Color foreground_color );
308
309
310 /**************************************************************************
311 *
312 * @section:
313 * layer_management
314 *
315 * @title:
316 * Glyph Layer Management
317 *
318 * @abstract:
319 * Retrieving and manipulating OpenType's 'COLR' table data.
320 *
321 * @description:
322 * The functions described here allow access of colored glyph layer data
323 * in OpenType's 'COLR' tables.
324 *
325 * Note that FreeType does *not* provide rendering in general of glyphs
326 * that use a 'COLR' table! While FreeType has very limited rendering
327 * support for 'COLR' v0 tables (without a possibility to change the
328 * color palette) via @FT_Render_Glyph, there is no such convenience
329 * code for 'COLR' v1 tables -- while it appears that v1 is simply an
330 * 'improved' version of v0, this is not the case: it is a completely
331 * different color font format, and you need a dedicated graphics
332 * library like Skia or Cairo to handle a v1 table's drawing commands.
333 */
334
335
336 /**************************************************************************
337 *
338 * @struct:
339 * FT_LayerIterator
340 *
341 * @description:
342 * This iterator object is needed for @FT_Get_Color_Glyph_Layer.
343 *
344 * @fields:
345 * num_layers ::
346 * The number of glyph layers for the requested glyph index. Will be
347 * set by @FT_Get_Color_Glyph_Layer.
348 *
349 * layer ::
350 * The current layer. Will be set by @FT_Get_Color_Glyph_Layer.
351 *
352 * p ::
353 * An opaque pointer into 'COLR' table data. The caller must set this
354 * to `NULL` before the first call of @FT_Get_Color_Glyph_Layer.
355 */
356 typedef struct FT_LayerIterator_
357 {
358 FT_UInt num_layers;
359 FT_UInt layer;
360 FT_Byte* p;
361
362 } FT_LayerIterator;
363
364
365 /**************************************************************************
366 *
367 * @function:
368 * FT_Get_Color_Glyph_Layer
369 *
370 * @description:
371 * This is an interface to the 'COLR' table in OpenType fonts to
372 * iteratively retrieve the colored glyph layers associated with the
373 * current glyph slot.
374 *
375 * https://learn.microsoft.com/typography/opentype/spec/colr
376 *
377 * The glyph layer data for a given glyph index, if present, provides an
378 * alternative, multi-color glyph representation: Instead of rendering
379 * the outline or bitmap with the given glyph index, glyphs with the
380 * indices and colors returned by this function are rendered layer by
381 * layer.
382 *
383 * The returned elements are ordered in the z~direction from bottom to
384 * top; the 'n'th element should be rendered with the associated palette
385 * color and blended on top of the already rendered layers (elements 0,
386 * 1, ..., n-1).
387 *
388 * @input:
389 * face ::
390 * A handle to the parent face object.
391 *
392 * base_glyph ::
393 * The glyph index the colored glyph layers are associated with.
394 *
395 * @inout:
396 * iterator ::
397 * An @FT_LayerIterator object. For the first call you should set
398 * `iterator->p` to `NULL`. For all following calls, simply use the
399 * same object again.
400 *
401 * @output:
402 * aglyph_index ::
403 * The glyph index of the current layer.
404 *
405 * acolor_index ::
406 * The color index into the font face's color palette of the current
407 * layer. The value 0xFFFF is special; it doesn't reference a palette
408 * entry but indicates that the text foreground color should be used
409 * instead (to be set up by the application outside of FreeType).
410 *
411 * The color palette can be retrieved with @FT_Palette_Select.
412 *
413 * @return:
414 * Value~1 if everything is OK. If there are no more layers (or if there
415 * are no layers at all), value~0 gets returned. In case of an error,
416 * value~0 is returned also.
417 *
418 * @note:
419 * This function is necessary if you want to handle glyph layers by
420 * yourself. In particular, functions that operate with @FT_GlyphRec
421 * objects (like @FT_Get_Glyph or @FT_Glyph_To_Bitmap) don't have access
422 * to this information.
423 *
424 * Note that @FT_Render_Glyph is able to handle colored glyph layers
425 * automatically if the @FT_LOAD_COLOR flag is passed to a previous call
426 * to @FT_Load_Glyph. [This is an experimental feature.]
427 *
428 * @example:
429 * ```
430 * FT_Color* palette;
431 * FT_LayerIterator iterator;
432 *
433 * FT_Bool have_layers;
434 * FT_UInt layer_glyph_index;
435 * FT_UInt layer_color_index;
436 *
437 *
438 * error = FT_Palette_Select( face, palette_index, &palette );
439 * if ( error )
440 * palette = NULL;
441 *
442 * iterator.p = NULL;
443 * have_layers = FT_Get_Color_Glyph_Layer( face,
444 * glyph_index,
445 * &layer_glyph_index,
446 * &layer_color_index,
447 * &iterator );
448 *
449 * if ( palette && have_layers )
450 * {
451 * do
452 * {
453 * FT_Color layer_color;
454 *
455 *
456 * if ( layer_color_index == 0xFFFF )
457 * layer_color = text_foreground_color;
458 * else
459 * layer_color = palette[layer_color_index];
460 *
461 * // Load and render glyph `layer_glyph_index', then
462 * // blend resulting pixmap (using color `layer_color')
463 * // with previously created pixmaps.
464 *
465 * } while ( FT_Get_Color_Glyph_Layer( face,
466 * glyph_index,
467 * &layer_glyph_index,
468 * &layer_color_index,
469 * &iterator ) );
470 * }
471 * ```
472 *
473 * @since:
474 * 2.10
475 */
476 FT_EXPORT( FT_Bool )
477 FT_Get_Color_Glyph_Layer( FT_Face face,
478 FT_UInt base_glyph,
479 FT_UInt *aglyph_index,
480 FT_UInt *acolor_index,
481 FT_LayerIterator* iterator );
482
483
484 /**************************************************************************
485 *
486 * @enum:
487 * FT_PaintFormat
488 *
489 * @description:
490 * Enumeration describing the different paint format types of the v1
491 * extensions to the 'COLR' table, see
492 * 'https://github.com/googlefonts/colr-gradients-spec'.
493 *
494 * The enumeration values loosely correspond with the format numbers of
495 * the specification: FreeType always returns a fully specified 'Paint'
496 * structure for the 'Transform', 'Translate', 'Scale', 'Rotate', and
497 * 'Skew' table types even though the specification has different formats
498 * depending on whether or not a center is specified, whether the scale
499 * is uniform in x and y~direction or not, etc. Also, only non-variable
500 * format identifiers are listed in this enumeration; as soon as support
501 * for variable 'COLR' v1 fonts is implemented, interpolation is
502 * performed dependent on axis coordinates, which are configured on the
503 * @FT_Face through @FT_Set_Var_Design_Coordinates. This implies that
504 * always static, readily interpolated values are returned in the 'Paint'
505 * structures.
506 *
507 * @since:
508 * 2.13
509 */
510 typedef enum FT_PaintFormat_
511 {
512 FT_COLR_PAINTFORMAT_COLR_LAYERS = 1,
513 FT_COLR_PAINTFORMAT_SOLID = 2,
514 FT_COLR_PAINTFORMAT_LINEAR_GRADIENT = 4,
515 FT_COLR_PAINTFORMAT_RADIAL_GRADIENT = 6,
516 FT_COLR_PAINTFORMAT_SWEEP_GRADIENT = 8,
517 FT_COLR_PAINTFORMAT_GLYPH = 10,
518 FT_COLR_PAINTFORMAT_COLR_GLYPH = 11,
519 FT_COLR_PAINTFORMAT_TRANSFORM = 12,
520 FT_COLR_PAINTFORMAT_TRANSLATE = 14,
521 FT_COLR_PAINTFORMAT_SCALE = 16,
522 FT_COLR_PAINTFORMAT_ROTATE = 24,
523 FT_COLR_PAINTFORMAT_SKEW = 28,
524 FT_COLR_PAINTFORMAT_COMPOSITE = 32,
525 FT_COLR_PAINT_FORMAT_MAX = 33,
526 FT_COLR_PAINTFORMAT_UNSUPPORTED = 255
527
528 } FT_PaintFormat;
529
530
531 /**************************************************************************
532 *
533 * @struct:
534 * FT_ColorStopIterator
535 *
536 * @description:
537 * This iterator object is needed for @FT_Get_Colorline_Stops. It keeps
538 * state while iterating over the stops of an @FT_ColorLine, representing
539 * the `ColorLine` struct of the v1 extensions to 'COLR', see
540 * 'https://github.com/googlefonts/colr-gradients-spec'. Do not manually
541 * modify fields of this iterator.
542 *
543 * @fields:
544 * num_color_stops ::
545 * The number of color stops for the requested glyph index. Set by
546 * @FT_Get_Paint.
547 *
548 * current_color_stop ::
549 * The current color stop. Set by @FT_Get_Colorline_Stops.
550 *
551 * p ::
552 * An opaque pointer into 'COLR' table data. Set by @FT_Get_Paint.
553 * Updated by @FT_Get_Colorline_Stops.
554 *
555 * read_variable ::
556 * A boolean keeping track of whether variable color lines are to be
557 * read. Set by @FT_Get_Paint.
558 *
559 * @since:
560 * 2.13
561 */
563 {
564 FT_UInt num_color_stops;
565 FT_UInt current_color_stop;
566
567 FT_Byte* p;
568
569 FT_Bool read_variable;
570
571 } FT_ColorStopIterator;
572
573
574 /**************************************************************************
575 *
576 * @struct:
577 * FT_ColorIndex
578 *
579 * @description:
580 * A structure representing a `ColorIndex` value of the 'COLR' v1
581 * extensions, see 'https://github.com/googlefonts/colr-gradients-spec'.
582 *
583 * @fields:
584 * palette_index ::
585 * The palette index into a 'CPAL' palette.
586 *
587 * alpha ::
588 * Alpha transparency value multiplied with the value from 'CPAL'.
589 *
590 * @since:
591 * 2.13
592 */
593 typedef struct FT_ColorIndex_
594 {
595 FT_UInt16 palette_index;
596 FT_F2Dot14 alpha;
597
598 } FT_ColorIndex;
599
600
601 /**************************************************************************
602 *
603 * @struct:
604 * FT_ColorStop
605 *
606 * @description:
607 * A structure representing a `ColorStop` value of the 'COLR' v1
608 * extensions, see 'https://github.com/googlefonts/colr-gradients-spec'.
609 *
610 * @fields:
611 * stop_offset ::
612 * The stop offset along the gradient, expressed as a 16.16 fixed-point
613 * coordinate.
614 *
615 * color ::
616 * The color information for this stop, see @FT_ColorIndex.
617 *
618 * @since:
619 * 2.13
620 */
621 typedef struct FT_ColorStop_
622 {
623 FT_Fixed stop_offset;
624 FT_ColorIndex color;
625
626 } FT_ColorStop;
627
628
629 /**************************************************************************
630 *
631 * @enum:
632 * FT_PaintExtend
633 *
634 * @description:
635 * An enumeration representing the 'Extend' mode of the 'COLR' v1
636 * extensions, see 'https://github.com/googlefonts/colr-gradients-spec'.
637 * It describes how the gradient fill continues at the other boundaries.
638 *
639 * @since:
640 * 2.13
641 */
642 typedef enum FT_PaintExtend_
643 {
644 FT_COLR_PAINT_EXTEND_PAD = 0,
645 FT_COLR_PAINT_EXTEND_REPEAT = 1,
646 FT_COLR_PAINT_EXTEND_REFLECT = 2
647
648 } FT_PaintExtend;
649
650
651 /**************************************************************************
652 *
653 * @struct:
654 * FT_ColorLine
655 *
656 * @description:
657 * A structure representing a `ColorLine` value of the 'COLR' v1
658 * extensions, see 'https://github.com/googlefonts/colr-gradients-spec'.
659 * It describes a list of color stops along the defined gradient.
660 *
661 * @fields:
662 * extend ::
663 * The extend mode at the outer boundaries, see @FT_PaintExtend.
664 *
665 * color_stop_iterator ::
666 * The @FT_ColorStopIterator used to enumerate and retrieve the
667 * actual @FT_ColorStop's.
668 *
669 * @since:
670 * 2.13
671 */
672 typedef struct FT_ColorLine_
673 {
674 FT_PaintExtend extend;
675 FT_ColorStopIterator color_stop_iterator;
676
677 } FT_ColorLine;
678
679
680 /**************************************************************************
681 *
682 * @struct:
683 * FT_Affine23
684 *
685 * @description:
686 * A structure used to store a 2x3 matrix. Coefficients are in
687 * 16.16 fixed-point format. The computation performed is
688 *
689 * ```
690 * x' = x*xx + y*xy + dx
691 * y' = x*yx + y*yy + dy
692 * ```
693 *
694 * @fields:
695 * xx ::
696 * Matrix coefficient.
697 *
698 * xy ::
699 * Matrix coefficient.
700 *
701 * dx ::
702 * x translation.
703 *
704 * yx ::
705 * Matrix coefficient.
706 *
707 * yy ::
708 * Matrix coefficient.
709 *
710 * dy ::
711 * y translation.
712 *
713 * @since:
714 * 2.13
715 */
716 typedef struct FT_Affine_23_
717 {
718 FT_Fixed xx, xy, dx;
719 FT_Fixed yx, yy, dy;
720
721 } FT_Affine23;
722
723
724 /**************************************************************************
725 *
726 * @enum:
727 * FT_Composite_Mode
728 *
729 * @description:
730 * An enumeration listing the 'COLR' v1 composite modes used in
731 * @FT_PaintComposite. For more details on each paint mode, see
732 * 'https://www.w3.org/TR/compositing-1/#porterduffcompositingoperators'.
733 *
734 * @since:
735 * 2.13
736 */
737 typedef enum FT_Composite_Mode_
738 {
739 FT_COLR_COMPOSITE_CLEAR = 0,
740 FT_COLR_COMPOSITE_SRC = 1,
741 FT_COLR_COMPOSITE_DEST = 2,
742 FT_COLR_COMPOSITE_SRC_OVER = 3,
743 FT_COLR_COMPOSITE_DEST_OVER = 4,
744 FT_COLR_COMPOSITE_SRC_IN = 5,
745 FT_COLR_COMPOSITE_DEST_IN = 6,
746 FT_COLR_COMPOSITE_SRC_OUT = 7,
747 FT_COLR_COMPOSITE_DEST_OUT = 8,
748 FT_COLR_COMPOSITE_SRC_ATOP = 9,
749 FT_COLR_COMPOSITE_DEST_ATOP = 10,
750 FT_COLR_COMPOSITE_XOR = 11,
751 FT_COLR_COMPOSITE_PLUS = 12,
752 FT_COLR_COMPOSITE_SCREEN = 13,
753 FT_COLR_COMPOSITE_OVERLAY = 14,
754 FT_COLR_COMPOSITE_DARKEN = 15,
755 FT_COLR_COMPOSITE_LIGHTEN = 16,
756 FT_COLR_COMPOSITE_COLOR_DODGE = 17,
757 FT_COLR_COMPOSITE_COLOR_BURN = 18,
758 FT_COLR_COMPOSITE_HARD_LIGHT = 19,
759 FT_COLR_COMPOSITE_SOFT_LIGHT = 20,
760 FT_COLR_COMPOSITE_DIFFERENCE = 21,
761 FT_COLR_COMPOSITE_EXCLUSION = 22,
762 FT_COLR_COMPOSITE_MULTIPLY = 23,
763 FT_COLR_COMPOSITE_HSL_HUE = 24,
764 FT_COLR_COMPOSITE_HSL_SATURATION = 25,
765 FT_COLR_COMPOSITE_HSL_COLOR = 26,
766 FT_COLR_COMPOSITE_HSL_LUMINOSITY = 27,
767 FT_COLR_COMPOSITE_MAX = 28
768
769 } FT_Composite_Mode;
770
771
772 /**************************************************************************
773 *
774 * @struct:
775 * FT_OpaquePaint
776 *
777 * @description:
778 * A structure representing an offset to a `Paint` value stored in any
779 * of the paint tables of a 'COLR' v1 font. Compare Offset<24> there.
780 * When 'COLR' v1 paint tables represented by FreeType objects such as
781 * @FT_PaintColrLayers, @FT_PaintComposite, or @FT_PaintTransform
782 * reference downstream nested paint tables, we do not immediately
783 * retrieve them but encapsulate their location in this type. Use
784 * @FT_Get_Paint to retrieve the actual @FT_COLR_Paint object that
785 * describes the details of the respective paint table.
786 *
787 * @fields:
788 * p ::
789 * An internal offset to a Paint table, needs to be set to NULL before
790 * passing this struct as an argument to @FT_Get_Paint.
791 *
792 * insert_root_transform ::
793 * An internal boolean to track whether an initial root transform is
794 * to be provided. Do not set this value.
795 *
796 * @since:
797 * 2.13
798 */
799 typedef struct FT_Opaque_Paint_
800 {
801 FT_Byte* p;
802 FT_Bool insert_root_transform;
803 } FT_OpaquePaint;
804
805
806 /**************************************************************************
807 *
808 * @struct:
809 * FT_PaintColrLayers
810 *
811 * @description:
812 * A structure representing a `PaintColrLayers` table of a 'COLR' v1
813 * font. This table describes a set of layers that are to be composited
814 * with composite mode `FT_COLR_COMPOSITE_SRC_OVER`. The return value
815 * of this function is an @FT_LayerIterator initialized so that it can
816 * be used with @FT_Get_Paint_Layers to retrieve the @FT_OpaquePaint
817 * objects as references to each layer.
818 *
819 * @fields:
820 * layer_iterator ::
821 * The layer iterator that describes the layers of this paint.
822 *
823 * @since:
824 * 2.13
825 */
826 typedef struct FT_PaintColrLayers_
827 {
828 FT_LayerIterator layer_iterator;
829
830 } FT_PaintColrLayers;
831
832
833 /**************************************************************************
834 *
835 * @struct:
836 * FT_PaintSolid
837 *
838 * @description:
839 * A structure representing a `PaintSolid` value of the 'COLR' v1
840 * extensions, see 'https://github.com/googlefonts/colr-gradients-spec'.
841 * Using a `PaintSolid` value means that the glyph layer filled with
842 * this paint is solid-colored and does not contain a gradient.
843 *
844 * @fields:
845 * color ::
846 * The color information for this solid paint, see @FT_ColorIndex.
847 *
848 * @since:
849 * 2.13
850 */
851 typedef struct FT_PaintSolid_
852 {
853 FT_ColorIndex color;
854
855 } FT_PaintSolid;
856
857
858 /**************************************************************************
859 *
860 * @struct:
861 * FT_PaintLinearGradient
862 *
863 * @description:
864 * A structure representing a `PaintLinearGradient` value of the 'COLR'
865 * v1 extensions, see
866 * 'https://github.com/googlefonts/colr-gradients-spec'. The glyph
867 * layer filled with this paint is drawn filled with a linear gradient.
868 *
869 * @fields:
870 * colorline ::
871 * The @FT_ColorLine information for this paint, i.e., the list of
872 * color stops along the gradient.
873 *
874 * p0 ::
875 * The starting point of the gradient definition in font units
876 * represented as a 16.16 fixed-point `FT_Vector`.
877 *
878 * p1 ::
879 * The end point of the gradient definition in font units
880 * represented as a 16.16 fixed-point `FT_Vector`.
881 *
882 * p2 ::
883 * Optional point~p2 to rotate the gradient in font units
884 * represented as a 16.16 fixed-point `FT_Vector`.
885 * Otherwise equal to~p0.
886 *
887 * @since:
888 * 2.13
889 */
891 {
892 FT_ColorLine colorline;
893
894 /* TODO: Potentially expose those as x0, y0 etc. */
895 FT_Vector p0;
896 FT_Vector p1;
897 FT_Vector p2;
898
899 } FT_PaintLinearGradient;
900
901
902 /**************************************************************************
903 *
904 * @struct:
905 * FT_PaintRadialGradient
906 *
907 * @description:
908 * A structure representing a `PaintRadialGradient` value of the 'COLR'
909 * v1 extensions, see
910 * 'https://github.com/googlefonts/colr-gradients-spec'. The glyph
911 * layer filled with this paint is drawn filled with a radial gradient.
912 *
913 * @fields:
914 * colorline ::
915 * The @FT_ColorLine information for this paint, i.e., the list of
916 * color stops along the gradient.
917 *
918 * c0 ::
919 * The center of the starting point of the radial gradient in font
920 * units represented as a 16.16 fixed-point `FT_Vector`.
921 *
922 * r0 ::
923 * The radius of the starting circle of the radial gradient in font
924 * units represented as a 16.16 fixed-point value.
925 *
926 * c1 ::
927 * The center of the end point of the radial gradient in font units
928 * represented as a 16.16 fixed-point `FT_Vector`.
929 *
930 * r1 ::
931 * The radius of the end circle of the radial gradient in font
932 * units represented as a 16.16 fixed-point value.
933 *
934 * @since:
935 * 2.13
936 */
938 {
939 FT_ColorLine colorline;
940
941 FT_Vector c0;
942 FT_Pos r0;
943 FT_Vector c1;
944 FT_Pos r1;
945
946 } FT_PaintRadialGradient;
947
948
949 /**************************************************************************
950 *
951 * @struct:
952 * FT_PaintSweepGradient
953 *
954 * @description:
955 * A structure representing a `PaintSweepGradient` value of the 'COLR'
956 * v1 extensions, see
957 * 'https://github.com/googlefonts/colr-gradients-spec'. The glyph
958 * layer filled with this paint is drawn filled with a sweep gradient
959 * from `start_angle` to `end_angle`.
960 *
961 * @fields:
962 * colorline ::
963 * The @FT_ColorLine information for this paint, i.e., the list of
964 * color stops along the gradient.
965 *
966 * center ::
967 * The center of the sweep gradient in font units represented as a
968 * vector of 16.16 fixed-point values.
969 *
970 * start_angle ::
971 * The start angle of the sweep gradient in 16.16 fixed-point
972 * format specifying degrees divided by 180.0 (as in the
973 * spec). Multiply by 180.0f to receive degrees value. Values are
974 * given counter-clockwise, starting from the (positive) y~axis.
975 *
976 * end_angle ::
977 * The end angle of the sweep gradient in 16.16 fixed-point
978 * format specifying degrees divided by 180.0 (as in the
979 * spec). Multiply by 180.0f to receive degrees value. Values are
980 * given counter-clockwise, starting from the (positive) y~axis.
981 *
982 * @since:
983 * 2.13
984 */
986 {
987 FT_ColorLine colorline;
988
989 FT_Vector center;
990 FT_Fixed start_angle;
991 FT_Fixed end_angle;
992
993 } FT_PaintSweepGradient;
994
995
996 /**************************************************************************
997 *
998 * @struct:
999 * FT_PaintGlyph
1000 *
1001 * @description:
1002 * A structure representing a 'COLR' v1 `PaintGlyph` paint table.
1003 *
1004 * @fields:
1005 * paint ::
1006 * An opaque paint object pointing to a `Paint` table that serves as
1007 * the fill for the glyph ID.
1008 *
1009 * glyphID ::
1010 * The glyph ID from the 'glyf' table, which serves as the contour
1011 * information that is filled with paint.
1012 *
1013 * @since:
1014 * 2.13
1015 */
1016 typedef struct FT_PaintGlyph_
1017 {
1018 FT_OpaquePaint paint;
1019 FT_UInt glyphID;
1020
1021 } FT_PaintGlyph;
1022
1023
1024 /**************************************************************************
1025 *
1026 * @struct:
1027 * FT_PaintColrGlyph
1028 *
1029 * @description:
1030 * A structure representing a 'COLR' v1 `PaintColorGlyph` paint table.
1031 *
1032 * @fields:
1033 * glyphID ::
1034 * The glyph ID from the `BaseGlyphV1List` table that is drawn for
1035 * this paint.
1036 *
1037 * @since:
1038 * 2.13
1039 */
1040 typedef struct FT_PaintColrGlyph_
1041 {
1042 FT_UInt glyphID;
1043
1044 } FT_PaintColrGlyph;
1045
1046
1047 /**************************************************************************
1048 *
1049 * @struct:
1050 * FT_PaintTransform
1051 *
1052 * @description:
1053 * A structure representing a 'COLR' v1 `PaintTransform` paint table.
1054 *
1055 * @fields:
1056 * paint ::
1057 * An opaque paint that is subject to being transformed.
1058 *
1059 * affine ::
1060 * A 2x3 transformation matrix in @FT_Affine23 format containing
1061 * 16.16 fixed-point values.
1062 *
1063 * @since:
1064 * 2.13
1065 */
1066 typedef struct FT_PaintTransform_
1067 {
1068 FT_OpaquePaint paint;
1069 FT_Affine23 affine;
1070
1071 } FT_PaintTransform;
1072
1073
1074 /**************************************************************************
1075 *
1076 * @struct:
1077 * FT_PaintTranslate
1078 *
1079 * @description:
1080 * A structure representing a 'COLR' v1 `PaintTranslate` paint table.
1081 * Used for translating downstream paints by a given x and y~delta.
1082 *
1083 * @fields:
1084 * paint ::
1085 * An @FT_OpaquePaint object referencing the paint that is to be
1086 * rotated.
1087 *
1088 * dx ::
1089 * Translation in x~direction in font units represented as a
1090 * 16.16 fixed-point value.
1091 *
1092 * dy ::
1093 * Translation in y~direction in font units represented as a
1094 * 16.16 fixed-point value.
1095 *
1096 * @since:
1097 * 2.13
1098 */
1099 typedef struct FT_PaintTranslate_
1100 {
1101 FT_OpaquePaint paint;
1102
1103 FT_Fixed dx;
1104 FT_Fixed dy;
1105
1106 } FT_PaintTranslate;
1107
1108
1109 /**************************************************************************
1110 *
1111 * @struct:
1112 * FT_PaintScale
1113 *
1114 * @description:
1115 * A structure representing all of the 'COLR' v1 'PaintScale*' paint
1116 * tables. Used for scaling downstream paints by a given x and y~scale,
1117 * with a given center. This structure is used for all 'PaintScale*'
1118 * types that are part of specification; fields of this structure are
1119 * filled accordingly. If there is a center, the center values are set,
1120 * otherwise they are set to the zero coordinate. If the source font
1121 * file has 'PaintScaleUniform*' set, the scale values are set
1122 * accordingly to the same value.
1123 *
1124 * @fields:
1125 * paint ::
1126 * An @FT_OpaquePaint object referencing the paint that is to be
1127 * scaled.
1128 *
1129 * scale_x ::
1130 * Scale factor in x~direction represented as a
1131 * 16.16 fixed-point value.
1132 *
1133 * scale_y ::
1134 * Scale factor in y~direction represented as a
1135 * 16.16 fixed-point value.
1136 *
1137 * center_x ::
1138 * x~coordinate of center point to scale from represented as a
1139 * 16.16 fixed-point value.
1140 *
1141 * center_y ::
1142 * y~coordinate of center point to scale from represented as a
1143 * 16.16 fixed-point value.
1144 *
1145 * @since:
1146 * 2.13
1147 */
1148 typedef struct FT_PaintScale_
1149 {
1150 FT_OpaquePaint paint;
1151
1152 FT_Fixed scale_x;
1153 FT_Fixed scale_y;
1154
1155 FT_Fixed center_x;
1156 FT_Fixed center_y;
1157
1158 } FT_PaintScale;
1159
1160
1161 /**************************************************************************
1162 *
1163 * @struct:
1164 * FT_PaintRotate
1165 *
1166 * @description:
1167 * A structure representing a 'COLR' v1 `PaintRotate` paint table. Used
1168 * for rotating downstream paints with a given center and angle.
1169 *
1170 * @fields:
1171 * paint ::
1172 * An @FT_OpaquePaint object referencing the paint that is to be
1173 * rotated.
1174 *
1175 * angle ::
1176 * The rotation angle that is to be applied in degrees divided by
1177 * 180.0 (as in the spec) represented as a 16.16 fixed-point
1178 * value. Multiply by 180.0f to receive degrees value.
1179 *
1180 * center_x ::
1181 * The x~coordinate of the pivot point of the rotation in font
1182 * units represented as a 16.16 fixed-point value.
1183 *
1184 * center_y ::
1185 * The y~coordinate of the pivot point of the rotation in font
1186 * units represented as a 16.16 fixed-point value.
1187 *
1188 * @since:
1189 * 2.13
1190 */
1191
1192 typedef struct FT_PaintRotate_
1193 {
1194 FT_OpaquePaint paint;
1195
1196 FT_Fixed angle;
1197
1198 FT_Fixed center_x;
1199 FT_Fixed center_y;
1200
1201 } FT_PaintRotate;
1202
1203
1204 /**************************************************************************
1205 *
1206 * @struct:
1207 * FT_PaintSkew
1208 *
1209 * @description:
1210 * A structure representing a 'COLR' v1 `PaintSkew` paint table. Used
1211 * for skewing or shearing downstream paints by a given center and
1212 * angle.
1213 *
1214 * @fields:
1215 * paint ::
1216 * An @FT_OpaquePaint object referencing the paint that is to be
1217 * skewed.
1218 *
1219 * x_skew_angle ::
1220 * The skewing angle in x~direction in degrees divided by 180.0
1221 * (as in the spec) represented as a 16.16 fixed-point
1222 * value. Multiply by 180.0f to receive degrees.
1223 *
1224 * y_skew_angle ::
1225 * The skewing angle in y~direction in degrees divided by 180.0
1226 * (as in the spec) represented as a 16.16 fixed-point
1227 * value. Multiply by 180.0f to receive degrees.
1228 *
1229 * center_x ::
1230 * The x~coordinate of the pivot point of the skew in font units
1231 * represented as a 16.16 fixed-point value.
1232 *
1233 * center_y ::
1234 * The y~coordinate of the pivot point of the skew in font units
1235 * represented as a 16.16 fixed-point value.
1236 *
1237 * @since:
1238 * 2.13
1239 */
1240 typedef struct FT_PaintSkew_
1241 {
1242 FT_OpaquePaint paint;
1243
1244 FT_Fixed x_skew_angle;
1245 FT_Fixed y_skew_angle;
1246
1247 FT_Fixed center_x;
1248 FT_Fixed center_y;
1249
1250 } FT_PaintSkew;
1251
1252
1253 /**************************************************************************
1254 *
1255 * @struct:
1256 * FT_PaintComposite
1257 *
1258 * @description:
1259 * A structure representing a 'COLR' v1 `PaintComposite` paint table.
1260 * Used for compositing two paints in a 'COLR' v1 directed acyclic graph.
1261 *
1262 * @fields:
1263 * source_paint ::
1264 * An @FT_OpaquePaint object referencing the source that is to be
1265 * composited.
1266 *
1267 * composite_mode ::
1268 * An @FT_Composite_Mode enum value determining the composition
1269 * operation.
1270 *
1271 * backdrop_paint ::
1272 * An @FT_OpaquePaint object referencing the backdrop paint that
1273 * `source_paint` is composited onto.
1274 *
1275 * @since:
1276 * 2.13
1277 */
1278 typedef struct FT_PaintComposite_
1279 {
1280 FT_OpaquePaint source_paint;
1281 FT_Composite_Mode composite_mode;
1282 FT_OpaquePaint backdrop_paint;
1283
1284 } FT_PaintComposite;
1285
1286
1287 /**************************************************************************
1288 *
1289 * @union:
1290 * FT_COLR_Paint
1291 *
1292 * @description:
1293 * A union object representing format and details of a paint table of a
1294 * 'COLR' v1 font, see
1295 * 'https://github.com/googlefonts/colr-gradients-spec'. Use
1296 * @FT_Get_Paint to retrieve a @FT_COLR_Paint for an @FT_OpaquePaint
1297 * object.
1298 *
1299 * @fields:
1300 * format ::
1301 * The gradient format for this Paint structure.
1302 *
1303 * u ::
1304 * Union of all paint table types:
1305 *
1306 * * @FT_PaintColrLayers
1307 * * @FT_PaintGlyph
1308 * * @FT_PaintSolid
1309 * * @FT_PaintLinearGradient
1310 * * @FT_PaintRadialGradient
1311 * * @FT_PaintSweepGradient
1312 * * @FT_PaintTransform
1313 * * @FT_PaintTranslate
1314 * * @FT_PaintRotate
1315 * * @FT_PaintSkew
1316 * * @FT_PaintComposite
1317 * * @FT_PaintColrGlyph
1318 *
1319 * @since:
1320 * 2.13
1321 */
1322 typedef struct FT_COLR_Paint_
1323 {
1324 FT_PaintFormat format;
1325
1326 union
1327 {
1328 FT_PaintColrLayers colr_layers;
1329 FT_PaintGlyph glyph;
1330 FT_PaintSolid solid;
1331 FT_PaintLinearGradient linear_gradient;
1332 FT_PaintRadialGradient radial_gradient;
1333 FT_PaintSweepGradient sweep_gradient;
1334 FT_PaintTransform transform;
1335 FT_PaintTranslate translate;
1336 FT_PaintScale scale;
1337 FT_PaintRotate rotate;
1338 FT_PaintSkew skew;
1339 FT_PaintComposite composite;
1340 FT_PaintColrGlyph colr_glyph;
1341
1342 } u;
1343
1344 } FT_COLR_Paint;
1345
1346
1347 /**************************************************************************
1348 *
1349 * @enum:
1350 * FT_Color_Root_Transform
1351 *
1352 * @description:
1353 * An enumeration to specify whether @FT_Get_Color_Glyph_Paint is to
1354 * return a root transform to configure the client's graphics context
1355 * matrix.
1356 *
1357 * @values:
1358 * FT_COLOR_INCLUDE_ROOT_TRANSFORM ::
1359 * Do include the root transform as the initial @FT_COLR_Paint object.
1360 *
1361 * FT_COLOR_NO_ROOT_TRANSFORM ::
1362 * Do not output an initial root transform.
1363 *
1364 * @since:
1365 * 2.13
1366 */
1367 typedef enum FT_Color_Root_Transform_
1368 {
1369 FT_COLOR_INCLUDE_ROOT_TRANSFORM,
1370 FT_COLOR_NO_ROOT_TRANSFORM,
1371
1372 FT_COLOR_ROOT_TRANSFORM_MAX
1373
1374 } FT_Color_Root_Transform;
1375
1376
1377 /**************************************************************************
1378 *
1379 * @struct:
1380 * FT_ClipBox
1381 *
1382 * @description:
1383 * A structure representing a 'COLR' v1 'ClipBox' table. 'COLR' v1
1384 * glyphs may optionally define a clip box for aiding allocation or
1385 * defining a maximum drawable region. Use @FT_Get_Color_Glyph_ClipBox
1386 * to retrieve it.
1387 *
1388 * @fields:
1389 * bottom_left ::
1390 * The bottom left corner of the clip box as an @FT_Vector with
1391 * fixed-point coordinates in 26.6 format.
1392 *
1393 * top_left ::
1394 * The top left corner of the clip box as an @FT_Vector with
1395 * fixed-point coordinates in 26.6 format.
1396 *
1397 * top_right ::
1398 * The top right corner of the clip box as an @FT_Vector with
1399 * fixed-point coordinates in 26.6 format.
1400 *
1401 * bottom_right ::
1402 * The bottom right corner of the clip box as an @FT_Vector with
1403 * fixed-point coordinates in 26.6 format.
1404 *
1405 * @since:
1406 * 2.13
1407 */
1408 typedef struct FT_ClipBox_
1409 {
1410 FT_Vector bottom_left;
1411 FT_Vector top_left;
1412 FT_Vector top_right;
1413 FT_Vector bottom_right;
1414
1415 } FT_ClipBox;
1416
1417
1418 /**************************************************************************
1419 *
1420 * @function:
1421 * FT_Get_Color_Glyph_Paint
1422 *
1423 * @description:
1424 * This is the starting point and interface to color gradient
1425 * information in a 'COLR' v1 table in OpenType fonts to recursively
1426 * retrieve the paint tables for the directed acyclic graph of a colored
1427 * glyph, given a glyph ID.
1428 *
1429 * https://github.com/googlefonts/colr-gradients-spec
1430 *
1431 * In a 'COLR' v1 font, each color glyph defines a directed acyclic
1432 * graph of nested paint tables, such as `PaintGlyph`, `PaintSolid`,
1433 * `PaintLinearGradient`, `PaintRadialGradient`, and so on. Using this
1434 * function and specifying a glyph ID, one retrieves the root paint
1435 * table for this glyph ID.
1436 *
1437 * This function allows control whether an initial root transform is
1438 * returned to configure scaling, transform, and translation correctly
1439 * on the client's graphics context. The initial root transform is
1440 * computed and returned according to the values configured for @FT_Size
1441 * and @FT_Set_Transform on the @FT_Face object, see below for details
1442 * of the `root_transform` parameter. This has implications for a
1443 * client 'COLR' v1 implementation: When this function returns an
1444 * initially computed root transform, at the time of executing the
1445 * @FT_PaintGlyph operation, the contours should be retrieved using
1446 * @FT_Load_Glyph at unscaled, untransformed size. This is because the
1447 * root transform applied to the graphics context will take care of
1448 * correct scaling.
1449 *
1450 * Alternatively, to allow hinting of contours, at the time of executing
1451 * @FT_Load_Glyph, the current graphics context transformation matrix
1452 * can be decomposed into a scaling matrix and a remainder, and
1453 * @FT_Load_Glyph can be used to retrieve the contours at scaled size.
1454 * Care must then be taken to blit or clip to the graphics context with
1455 * taking this remainder transformation into account.
1456 *
1457 * @input:
1458 * face ::
1459 * A handle to the parent face object.
1460 *
1461 * base_glyph ::
1462 * The glyph index for which to retrieve the root paint table.
1463 *
1464 * root_transform ::
1465 * Specifies whether an initially computed root is returned by the
1466 * @FT_PaintTransform operation to account for the activated size
1467 * (see @FT_Activate_Size) and the configured transform and translate
1468 * (see @FT_Set_Transform).
1469 *
1470 * This root transform is returned before nodes of the glyph graph of
1471 * the font are returned. Subsequent @FT_COLR_Paint structures
1472 * contain unscaled and untransformed values. The inserted root
1473 * transform enables the client application to apply an initial
1474 * transform to its graphics context. When executing subsequent
1475 * FT_COLR_Paint operations, values from @FT_COLR_Paint operations
1476 * will ultimately be correctly scaled because of the root transform
1477 * applied to the graphics context. Use
1478 * @FT_COLOR_INCLUDE_ROOT_TRANSFORM to include the root transform, use
1479 * @FT_COLOR_NO_ROOT_TRANSFORM to not include it. The latter may be
1480 * useful when traversing the 'COLR' v1 glyph graph and reaching a
1481 * @FT_PaintColrGlyph. When recursing into @FT_PaintColrGlyph and
1482 * painting that inline, no additional root transform is needed as it
1483 * has already been applied to the graphics context at the beginning
1484 * of drawing this glyph.
1485 *
1486 * @output:
1487 * paint ::
1488 * The @FT_OpaquePaint object that references the actual paint table.
1489 *
1490 * The respective actual @FT_COLR_Paint object is retrieved via
1491 * @FT_Get_Paint.
1492 *
1493 * @return:
1494 * Value~1 if everything is OK. If no color glyph is found, or the root
1495 * paint could not be retrieved, value~0 gets returned. In case of an
1496 * error, value~0 is returned also.
1497 *
1498 * @since:
1499 * 2.13
1500 */
1501 FT_EXPORT( FT_Bool )
1502 FT_Get_Color_Glyph_Paint( FT_Face face,
1503 FT_UInt base_glyph,
1504 FT_Color_Root_Transform root_transform,
1505 FT_OpaquePaint* paint );
1506
1507
1508 /**************************************************************************
1509 *
1510 * @function:
1511 * FT_Get_Color_Glyph_ClipBox
1512 *
1513 * @description:
1514 * Search for a 'COLR' v1 clip box for the specified `base_glyph` and
1515 * fill the `clip_box` parameter with the 'COLR' v1 'ClipBox' information
1516 * if one is found.
1517 *
1518 * @input:
1519 * face ::
1520 * A handle to the parent face object.
1521 *
1522 * base_glyph ::
1523 * The glyph index for which to retrieve the clip box.
1524 *
1525 * @output:
1526 * clip_box ::
1527 * The clip box for the requested `base_glyph` if one is found. The
1528 * clip box is computed taking scale and transformations configured on
1529 * the @FT_Face into account. @FT_ClipBox contains @FT_Vector values
1530 * in 26.6 format.
1531 *
1532 * @return:
1533 * Value~1 if a clip box is found. If no clip box is found or an error
1534 * occurred, value~0 is returned.
1535 *
1536 * @note:
1537 * To retrieve the clip box in font units, reset scale to units-per-em
1538 * and remove transforms configured using @FT_Set_Transform.
1539 *
1540 * @since:
1541 * 2.13
1542 */
1543 FT_EXPORT( FT_Bool )
1544 FT_Get_Color_Glyph_ClipBox( FT_Face face,
1545 FT_UInt base_glyph,
1546 FT_ClipBox* clip_box );
1547
1548
1549 /**************************************************************************
1550 *
1551 * @function:
1552 * FT_Get_Paint_Layers
1553 *
1554 * @description:
1555 * Access the layers of a `PaintColrLayers` table.
1556 *
1557 * If the root paint of a color glyph, or a nested paint of a 'COLR'
1558 * glyph is a `PaintColrLayers` table, this function retrieves the
1559 * layers of the `PaintColrLayers` table.
1560 *
1561 * The @FT_PaintColrLayers object contains an @FT_LayerIterator, which
1562 * is used here to iterate over the layers. Each layer is returned as
1563 * an @FT_OpaquePaint object, which then can be used with @FT_Get_Paint
1564 * to retrieve the actual paint object.
1565 *
1566 * @input:
1567 * face ::
1568 * A handle to the parent face object.
1569 *
1570 * @inout:
1571 * iterator ::
1572 * The @FT_LayerIterator from an @FT_PaintColrLayers object, for which
1573 * the layers are to be retrieved. The internal state of the iterator
1574 * is incremented after one call to this function for retrieving one
1575 * layer.
1576 *
1577 * @output:
1578 * paint ::
1579 * The @FT_OpaquePaint object that references the actual paint table.
1580 * The respective actual @FT_COLR_Paint object is retrieved via
1581 * @FT_Get_Paint.
1582 *
1583 * @return:
1584 * Value~1 if everything is OK. Value~0 gets returned when the paint
1585 * object can not be retrieved or any other error occurs.
1586 *
1587 * @since:
1588 * 2.13
1589 */
1590 FT_EXPORT( FT_Bool )
1591 FT_Get_Paint_Layers( FT_Face face,
1592 FT_LayerIterator* iterator,
1593 FT_OpaquePaint* paint );
1594
1595
1596 /**************************************************************************
1597 *
1598 * @function:
1599 * FT_Get_Colorline_Stops
1600 *
1601 * @description:
1602 * This is an interface to color gradient information in a 'COLR' v1
1603 * table in OpenType fonts to iteratively retrieve the gradient and
1604 * solid fill information for colored glyph layers for a specified glyph
1605 * ID.
1606 *
1607 * https://github.com/googlefonts/colr-gradients-spec
1608 *
1609 * @input:
1610 * face ::
1611 * A handle to the parent face object.
1612 *
1613 * @inout:
1614 * iterator ::
1615 * The retrieved @FT_ColorStopIterator, configured on an @FT_ColorLine,
1616 * which in turn got retrieved via paint information in
1617 * @FT_PaintLinearGradient or @FT_PaintRadialGradient.
1618 *
1619 * @output:
1620 * color_stop ::
1621 * Color index and alpha value for the retrieved color stop.
1622 *
1623 * @return:
1624 * Value~1 if everything is OK. If there are no more color stops,
1625 * value~0 gets returned. In case of an error, value~0 is returned
1626 * also.
1627 *
1628 * @since:
1629 * 2.13
1630 */
1631 FT_EXPORT( FT_Bool )
1632 FT_Get_Colorline_Stops( FT_Face face,
1633 FT_ColorStop* color_stop,
1634 FT_ColorStopIterator* iterator );
1635
1636
1637 /**************************************************************************
1638 *
1639 * @function:
1640 * FT_Get_Paint
1641 *
1642 * @description:
1643 * Access the details of a paint using an @FT_OpaquePaint opaque paint
1644 * object, which internally stores the offset to the respective `Paint`
1645 * object in the 'COLR' table.
1646 *
1647 * @input:
1648 * face ::
1649 * A handle to the parent face object.
1650 *
1651 * opaque_paint ::
1652 * The opaque paint object for which the underlying @FT_COLR_Paint
1653 * data is to be retrieved.
1654 *
1655 * @output:
1656 * paint ::
1657 * The specific @FT_COLR_Paint object containing information coming
1658 * from one of the font's `Paint*` tables.
1659 *
1660 * @return:
1661 * Value~1 if everything is OK. Value~0 if no details can be found for
1662 * this paint or any other error occurred.
1663 *
1664 * @since:
1665 * 2.13
1666 */
1667 FT_EXPORT( FT_Bool )
1668 FT_Get_Paint( FT_Face face,
1669 FT_OpaquePaint opaque_paint,
1670 FT_COLR_Paint* paint );
1671
1672 /* */
1673
1674
1675FT_END_HEADER
1676
1677#endif /* FTCOLOR_H_ */
1678
1679
1680/* END */