QtBase  v6.3.1
hb-ot-color.cc
Go to the documentation of this file.
1 /*
2  * Copyright © 2016 Google, Inc.
3  * Copyright © 2018 Ebrahim Byagowi
4  *
5  * This is part of HarfBuzz, a text shaping library.
6  *
7  * Permission is hereby granted, without written agreement and without
8  * license or royalty fees, to use, copy, modify, and distribute this
9  * software and its documentation for any purpose, provided that the
10  * above copyright notice and the following two paragraphs appear in
11  * all copies of this software.
12  *
13  * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
14  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
15  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
16  * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
17  * DAMAGE.
18  *
19  * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
20  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
22  * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
23  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24  *
25  * Google Author(s): Sascha Brawer, Behdad Esfahbod
26  */
27 
28 #include "hb.hh"
29 
30 #ifndef HB_NO_COLOR
31 
32 #include "hb-ot.h"
33 
38 #include "hb-ot-color-svg-table.hh"
39 
40 
53 /*
54  * CPAL
55  */
56 
57 
70 {
71  return face->table.CPAL->has_data ();
72 }
73 
84 unsigned int
86 {
87  return face->table.CPAL->get_palette_count ();
88 }
89 
108  unsigned int palette_index)
109 {
110  return face->table.CPAL->get_palette_name_id (palette_index);
111 }
112 
130  unsigned int color_index)
131 {
132  return face->table.CPAL->get_color_name_id (color_index);
133 }
134 
148  unsigned int palette_index)
149 {
150  return face->table.CPAL->get_palette_flags (palette_index);
151 }
152 
174 unsigned int
176  unsigned int palette_index,
177  unsigned int start_offset,
178  unsigned int *colors_count /* IN/OUT. May be NULL. */,
179  hb_color_t *colors /* OUT. May be NULL. */)
180 {
181  return face->table.CPAL->get_palette_colors (palette_index, start_offset, colors_count, colors);
182 }
183 
184 
185 /*
186  * COLR
187  */
188 
199 hb_bool_t
201 {
202  return face->table.COLR->has_data ();
203 }
204 
221 unsigned int
223  hb_codepoint_t glyph,
224  unsigned int start_offset,
225  unsigned int *layer_count, /* IN/OUT. May be NULL. */
226  hb_ot_color_layer_t *layers /* OUT. May be NULL. */)
227 {
228  return face->table.COLR->get_glyph_layers (glyph, start_offset, layer_count, layers);
229 }
230 
231 
232 /*
233  * SVG
234  */
235 
246 hb_bool_t
248 {
249  return face->table.SVG->has_data ();
250 }
251 
265 hb_blob_t *
267 {
268  return face->table.SVG->reference_blob_for_glyph (glyph);
269 }
270 
271 
272 /*
273  * PNG: CBDT or sbix
274  */
275 
286 hb_bool_t
288 {
289  return face->table.CBDT->has_data () || face->table.sbix->has_data ();
290 }
291 
307 hb_blob_t *
309 {
310  hb_blob_t *blob = hb_blob_get_empty ();
311 
312  if (font->face->table.sbix->has_data ())
313  blob = font->face->table.sbix->reference_png (font, glyph, nullptr, nullptr, nullptr);
314 
315  if (!blob->length && font->face->table.CBDT->has_data ())
316  blob = font->face->table.CBDT->reference_png (font, glyph);
317 
318  return blob;
319 }
320 
321 
322 #endif
hb_blob_t * hb_blob_get_empty()
Definition: hb-blob.cc:226
unsigned int hb_ot_color_palette_get_count(hb_face_t *face)
Definition: hb-ot-color.cc:85
hb_ot_color_palette_flags_t hb_ot_color_palette_get_flags(hb_face_t *face, unsigned int palette_index)
Definition: hb-ot-color.cc:147
hb_bool_t hb_ot_color_has_layers(hb_face_t *face)
Definition: hb-ot-color.cc:200
unsigned int hb_ot_color_glyph_get_layers(hb_face_t *face, hb_codepoint_t glyph, unsigned int start_offset, unsigned int *layer_count, hb_ot_color_layer_t *layers)
Definition: hb-ot-color.cc:222
unsigned int hb_ot_color_palette_get_colors(hb_face_t *face, unsigned int palette_index, unsigned int start_offset, unsigned int *colors_count, hb_color_t *colors)
Definition: hb-ot-color.cc:175
hb_bool_t hb_ot_color_has_svg(hb_face_t *face)
Definition: hb-ot-color.cc:247
hb_bool_t hb_ot_color_has_png(hb_face_t *face)
Definition: hb-ot-color.cc:287
hb_ot_name_id_t hb_ot_color_palette_color_get_name_id(hb_face_t *face, unsigned int color_index)
Definition: hb-ot-color.cc:129
hb_ot_name_id_t hb_ot_color_palette_get_name_id(hb_face_t *face, unsigned int palette_index)
Definition: hb-ot-color.cc:107
hb_blob_t * hb_ot_color_glyph_reference_svg(hb_face_t *face, hb_codepoint_t glyph)
Definition: hb-ot-color.cc:266
hb_bool_t hb_ot_color_has_palettes(hb_face_t *face)
Definition: hb-ot-color.cc:69
hb_blob_t * hb_ot_color_glyph_reference_png(hb_font_t *font, hb_codepoint_t glyph)
Definition: hb-ot-color.cc:308
hb_ot_color_palette_flags_t
Definition: hb-ot-color.h:73
HB_EXTERN unsigned int start_offset
unsigned int hb_ot_name_id_t
Definition: hb-ot-name.h:109
const EGLAttrib EGLOutputLayerEXT * layers
GLenum face
HB_BEGIN_DECLS typedef int hb_bool_t
Definition: hb-common.h:97
uint32_t hb_codepoint_t
Definition: hb-common.h:106
uint32_t hb_color_t
Definition: hb-common.h:858
unsigned int length
Definition: hb-blob.hh:65