1 /*
   2  * Copyright © 2016  Google, Inc.
   3  * Copyright © 2018  Khaled Hosny
   4  * Copyright © 2018  Ebrahim Byagowi
   5  *
   6  *  This is part of HarfBuzz, a text shaping library.
   7  *
   8  * Permission is hereby granted, without written agreement and without
   9  * license or royalty fees, to use, copy, modify, and distribute this
  10  * software and its documentation for any purpose, provided that the
  11  * above copyright notice and the following two paragraphs appear in
  12  * all copies of this software.
  13  *
  14  * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
  15  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
  16  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
  17  * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
  18  * DAMAGE.
  19  *
  20  * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
  21  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  22  * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  23  * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
  24  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  25  *
  26  * Google Author(s): Sascha Brawer, Behdad Esfahbod
  27  */
  28 
  29 #ifndef HB_OT_H_IN
  30 #error "Include <hb-ot.h> instead."
  31 #endif
  32 
  33 #ifndef HB_OT_COLOR_H
  34 #define HB_OT_COLOR_H
  35 
  36 #include "hb.h"
  37 #include "hb-ot-name.h"
  38 
  39 HB_BEGIN_DECLS
  40 
  41 
  42 /*
  43  * Color palettes.
  44  */
  45 
  46 HB_EXTERN hb_bool_t
  47 hb_ot_color_has_palettes (hb_face_t *face);
  48 
  49 HB_EXTERN unsigned int
  50 hb_ot_color_palette_get_count (hb_face_t *face);
  51 
  52 HB_EXTERN hb_ot_name_id_t
  53 hb_ot_color_palette_get_name_id (hb_face_t *face,
  54                                  unsigned int palette_index);
  55 
  56 HB_EXTERN hb_ot_name_id_t
  57 hb_ot_color_palette_color_get_name_id (hb_face_t *face,
  58                                        unsigned int color_index);
  59 
  60 /**
  61  * hb_ot_color_palette_flags_t:
  62  * @HB_OT_COLOR_PALETTE_FLAG_DEFAULT: default indicating that there is nothing special
  63  *   to note about a color palette.
  64  * @HB_OT_COLOR_PALETTE_FLAG_USABLE_WITH_LIGHT_BACKGROUND: flag indicating that the color
  65  *   palette is appropriate to use when displaying the font on a light background such as white.
  66  * @HB_OT_COLOR_PALETTE_FLAG_USABLE_WITH_DARK_BACKGROUND: flag indicating that the color
  67  *   palette is appropriate to use when displaying the font on a dark background such as black.
  68  *
  69  * Since: 2.1.0
  70  */
  71 typedef enum { /*< flags >*/
  72   HB_OT_COLOR_PALETTE_FLAG_DEFAULT                      = 0x00000000u,
  73   HB_OT_COLOR_PALETTE_FLAG_USABLE_WITH_LIGHT_BACKGROUND = 0x00000001u,
  74   HB_OT_COLOR_PALETTE_FLAG_USABLE_WITH_DARK_BACKGROUND  = 0x00000002u
  75 } hb_ot_color_palette_flags_t;
  76 
  77 HB_EXTERN hb_ot_color_palette_flags_t
  78 hb_ot_color_palette_get_flags (hb_face_t *face,
  79                                unsigned int palette_index);
  80 
  81 HB_EXTERN unsigned int
  82 hb_ot_color_palette_get_colors (hb_face_t    *face,
  83                                 unsigned int  palette_index,
  84                                 unsigned int  start_offset,
  85                                 unsigned int *color_count,  /* IN/OUT.  May be NULL. */
  86                                 hb_color_t   *colors        /* OUT.     May be NULL. */);
  87 
  88 
  89 /*
  90  * Color layers.
  91  */
  92 
  93 HB_EXTERN hb_bool_t
  94 hb_ot_color_has_layers (hb_face_t *face);
  95 
  96 /**
  97  * hb_ot_color_layer_t:
  98  *
  99  * Pairs of glyph and color index.
 100  *
 101  * Since: 2.1.0
 102  **/
 103 typedef struct hb_ot_color_layer_t
 104 {
 105   hb_codepoint_t glyph;
 106   unsigned int   color_index;
 107 } hb_ot_color_layer_t;
 108 
 109 HB_EXTERN unsigned int
 110 hb_ot_color_glyph_get_layers (hb_face_t           *face,
 111                               hb_codepoint_t       glyph,
 112                               unsigned int         start_offset,
 113                               unsigned int        *count, /* IN/OUT.  May be NULL. */
 114                               hb_ot_color_layer_t *layers /* OUT.     May be NULL. */);
 115 
 116 /*
 117  * SVG
 118  */
 119 
 120 HB_EXTERN hb_bool_t
 121 hb_ot_color_has_svg (hb_face_t *face);
 122 
 123 HB_EXTERN hb_blob_t *
 124 hb_ot_color_glyph_reference_svg (hb_face_t *face, hb_codepoint_t glyph);
 125 
 126 /*
 127  * PNG: CBDT or sbix
 128  */
 129 
 130 HB_EXTERN hb_bool_t
 131 hb_ot_color_has_png (hb_face_t *face);
 132 
 133 HB_EXTERN hb_blob_t *
 134 hb_ot_color_glyph_reference_png (hb_font_t *font, hb_codepoint_t glyph);
 135 
 136 
 137 HB_END_DECLS
 138 
 139 #endif /* HB_OT_COLOR_H */