ReactOS 0.4.16-dev-1078-g21d3e29
ftcolor.c
Go to the documentation of this file.
1/****************************************************************************
2 *
3 * ftcolor.c
4 *
5 * FreeType's glyph color management (body).
6 *
7 * Copyright (C) 2018-2019 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 <ft2build.h>
20#include FT_INTERNAL_DEBUG_H
21#include FT_INTERNAL_SFNT_H
22#include FT_INTERNAL_TRUETYPE_TYPES_H
23#include FT_COLOR_H
24
25
26#ifdef TT_CONFIG_OPTION_COLOR_LAYERS
27
28 static
29 const FT_Palette_Data null_palette_data = { 0, NULL, NULL, 0, NULL };
30
31
32 /* documentation is in ftcolor.h */
33
36 FT_Palette_Data *apalette_data )
37 {
38 if ( !face )
39 return FT_THROW( Invalid_Face_Handle );
40 if ( !apalette_data)
41 return FT_THROW( Invalid_Argument );
42
43 if ( FT_IS_SFNT( face ) )
44 *apalette_data = ( (TT_Face)face )->palette_data;
45 else
46 *apalette_data = null_palette_data;
47
48 return FT_Err_Ok;
49 }
50
51
52 /* documentation is in ftcolor.h */
53
56 FT_UShort palette_index,
57 FT_Color* *apalette )
58 {
60
61 TT_Face ttface;
63
64
65 if ( !face )
66 return FT_THROW( Invalid_Face_Handle );
67
68 if ( !FT_IS_SFNT( face ) )
69 {
70 if ( apalette )
71 *apalette = NULL;
72
73 return FT_Err_Ok;
74 }
75
76 ttface = (TT_Face)face;
77 sfnt = (SFNT_Service)ttface->sfnt;
78
79 error = sfnt->set_palette( ttface, palette_index );
80 if ( error )
81 return error;
82
83 ttface->palette_index = palette_index;
84
85 if ( apalette )
86 *apalette = ttface->palette;
87
88 return FT_Err_Ok;
89 }
90
91
92 /* documentation is in ftcolor.h */
93
96 FT_Color foreground_color )
97 {
98 TT_Face ttface;
99
100
101 if ( !face )
102 return FT_THROW( Invalid_Face_Handle );
103
104 if ( !FT_IS_SFNT( face ) )
105 return FT_Err_Ok;
106
107 ttface = (TT_Face)face;
108
109 ttface->foreground_color = foreground_color;
110 ttface->have_foreground_color = 1;
111
112 return FT_Err_Ok;
113 }
114
115#else /* !TT_CONFIG_OPTION_COLOR_LAYERS */
116
119 FT_Palette_Data *apalette_data )
120 {
121 FT_UNUSED( face );
122 FT_UNUSED( apalette_data );
123
124
125 return FT_THROW( Unimplemented_Feature );
126 }
127
128
131 FT_UShort palette_index,
132 FT_Color* *apalette )
133 {
134 FT_UNUSED( face );
135 FT_UNUSED( palette_index );
136 FT_UNUSED( apalette );
137
138
139 return FT_THROW( Unimplemented_Feature );
140 }
141
142
145 FT_Color foreground_color )
146 {
147 FT_UNUSED( face );
148 FT_UNUSED( foreground_color );
149
150
151 return FT_THROW( Unimplemented_Feature );
152 }
153
154#endif /* !TT_CONFIG_OPTION_COLOR_LAYERS */
155
156
157/* END */
#define NULL
Definition: types.h:112
#define FT_IS_SFNT(face)
Definition: freetype.h:1303
return FT_Err_Ok
Definition: ftbbox.c:527
FT_Palette_Set_Foreground_Color(FT_Face face, FT_Color foreground_color)
Definition: ftcolor.c:144
FT_Palette_Select(FT_Face face, FT_UShort palette_index, FT_Color **apalette)
Definition: ftcolor.c:130
FT_Palette_Data_Get(FT_Face face, FT_Palette_Data *apalette_data)
Definition: ftcolor.c:118
FT_BEGIN_HEADER struct FT_Color_ FT_Color
#define FT_UNUSED(arg)
Definition: ftconfig.h:100
#define FT_EXPORT_DEF(x)
Definition: ftconfig.h:494
#define FT_THROW(e)
Definition: ftdebug.h:241
int FT_Error
Definition: fttypes.h:299
unsigned short FT_UShort
Definition: fttypes.h:209
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
#define error(str)
Definition: mkdosfs.c:1605
SFNT_Interface * SFNT_Service
Definition: sfnt.h:784
TT_Set_Palette_Func set_palette
Definition: sfnt.h:771
FT_UShort palette_index
Definition: tttypes.h:1614
void * sfnt
Definition: tttypes.h:1573
FT_Color foreground_color
Definition: tttypes.h:1617
FT_Bool have_foreground_color
Definition: tttypes.h:1616
FT_Color * palette
Definition: tttypes.h:1615
SFNT_Service sfnt
Definition: ttdriver.c:209
struct TT_FaceRec_ * TT_Face
Definition: tttypes.h:1064