/src/skia/third_party/externals/freetype/src/base/ftcolor.c
Line | Count | Source (jump to first uncovered line) |
1 | | /**************************************************************************** |
2 | | * |
3 | | * ftcolor.c |
4 | | * |
5 | | * FreeType's glyph color management (body). |
6 | | * |
7 | | * Copyright (C) 2018-2021 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 | | |
19 | | #include <freetype/internal/ftdebug.h> |
20 | | #include <freetype/internal/sfnt.h> |
21 | | #include <freetype/internal/tttypes.h> |
22 | | #include <freetype/ftcolor.h> |
23 | | |
24 | | |
25 | | #ifdef TT_CONFIG_OPTION_COLOR_LAYERS |
26 | | |
27 | | static |
28 | | const FT_Palette_Data null_palette_data = { 0, NULL, NULL, 0, NULL }; |
29 | | |
30 | | |
31 | | /* documentation is in ftcolor.h */ |
32 | | |
33 | | FT_EXPORT_DEF( FT_Error ) |
34 | | FT_Palette_Data_Get( FT_Face face, |
35 | | FT_Palette_Data *apalette_data ) |
36 | 0 | { |
37 | 0 | if ( !face ) |
38 | 0 | return FT_THROW( Invalid_Face_Handle ); |
39 | 0 | if ( !apalette_data) |
40 | 0 | return FT_THROW( Invalid_Argument ); |
41 | | |
42 | 0 | if ( FT_IS_SFNT( face ) ) |
43 | 0 | *apalette_data = ( (TT_Face)face )->palette_data; |
44 | 0 | else |
45 | 0 | *apalette_data = null_palette_data; |
46 | |
|
47 | 0 | return FT_Err_Ok; |
48 | 0 | } |
49 | | |
50 | | |
51 | | /* documentation is in ftcolor.h */ |
52 | | |
53 | | FT_EXPORT_DEF( FT_Error ) |
54 | | FT_Palette_Select( FT_Face face, |
55 | | FT_UShort palette_index, |
56 | | FT_Color* *apalette ) |
57 | 0 | { |
58 | 0 | FT_Error error; |
59 | |
|
60 | 0 | TT_Face ttface; |
61 | 0 | SFNT_Service sfnt; |
62 | | |
63 | |
|
64 | 0 | if ( !face ) |
65 | 0 | return FT_THROW( Invalid_Face_Handle ); |
66 | | |
67 | 0 | if ( !FT_IS_SFNT( face ) ) |
68 | 0 | { |
69 | 0 | if ( apalette ) |
70 | 0 | *apalette = NULL; |
71 | |
|
72 | 0 | return FT_Err_Ok; |
73 | 0 | } |
74 | | |
75 | 0 | ttface = (TT_Face)face; |
76 | 0 | sfnt = (SFNT_Service)ttface->sfnt; |
77 | |
|
78 | 0 | error = sfnt->set_palette( ttface, palette_index ); |
79 | 0 | if ( error ) |
80 | 0 | return error; |
81 | | |
82 | 0 | ttface->palette_index = palette_index; |
83 | |
|
84 | 0 | if ( apalette ) |
85 | 0 | *apalette = ttface->palette; |
86 | |
|
87 | 0 | return FT_Err_Ok; |
88 | 0 | } |
89 | | |
90 | | |
91 | | /* documentation is in ftcolor.h */ |
92 | | |
93 | | FT_EXPORT_DEF( FT_Error ) |
94 | | FT_Palette_Set_Foreground_Color( FT_Face face, |
95 | | FT_Color foreground_color ) |
96 | 0 | { |
97 | 0 | TT_Face ttface; |
98 | | |
99 | |
|
100 | 0 | if ( !face ) |
101 | 0 | return FT_THROW( Invalid_Face_Handle ); |
102 | | |
103 | 0 | if ( !FT_IS_SFNT( face ) ) |
104 | 0 | return FT_Err_Ok; |
105 | | |
106 | 0 | ttface = (TT_Face)face; |
107 | |
|
108 | 0 | ttface->foreground_color = foreground_color; |
109 | 0 | ttface->have_foreground_color = 1; |
110 | |
|
111 | 0 | return FT_Err_Ok; |
112 | 0 | } |
113 | | |
114 | | #else /* !TT_CONFIG_OPTION_COLOR_LAYERS */ |
115 | | |
116 | | FT_EXPORT_DEF( FT_Error ) |
117 | | FT_Palette_Data_Get( FT_Face face, |
118 | | FT_Palette_Data *apalette_data ) |
119 | | { |
120 | | FT_UNUSED( face ); |
121 | | FT_UNUSED( apalette_data ); |
122 | | |
123 | | |
124 | | return FT_THROW( Unimplemented_Feature ); |
125 | | } |
126 | | |
127 | | |
128 | | FT_EXPORT_DEF( FT_Error ) |
129 | | FT_Palette_Select( FT_Face face, |
130 | | FT_UShort palette_index, |
131 | | FT_Color* *apalette ) |
132 | | { |
133 | | FT_UNUSED( face ); |
134 | | FT_UNUSED( palette_index ); |
135 | | FT_UNUSED( apalette ); |
136 | | |
137 | | |
138 | | return FT_THROW( Unimplemented_Feature ); |
139 | | } |
140 | | |
141 | | |
142 | | FT_EXPORT_DEF( FT_Error ) |
143 | | FT_Palette_Set_Foreground_Color( FT_Face face, |
144 | | FT_Color foreground_color ) |
145 | | { |
146 | | FT_UNUSED( face ); |
147 | | FT_UNUSED( foreground_color ); |
148 | | |
149 | | |
150 | | return FT_THROW( Unimplemented_Feature ); |
151 | | } |
152 | | |
153 | | #endif /* !TT_CONFIG_OPTION_COLOR_LAYERS */ |
154 | | |
155 | | |
156 | | /* END */ |