From 83de3a60ab7383cf3ee25c1f8c33a45a7778d003 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 18 Jun 2019 13:18:15 -0700 Subject: [PATCH] [config] Don't compile color API if HB_NO_COLOR Part of https://github.com/harfbuzz/harfbuzz/issues/1652 --- src/hb-ot-color.cc | 55 +++++++++------------------------------------------- src/test-ot-color.cc | 9 ++++++++- 2 files changed, 17 insertions(+), 47 deletions(-) diff --git a/src/hb-ot-color.cc b/src/hb-ot-color.cc index 20c602c..0e7203a 100644 --- a/src/hb-ot-color.cc +++ b/src/hb-ot-color.cc @@ -25,20 +25,21 @@ * Google Author(s): Sascha Brawer, Behdad Esfahbod */ -#include "hb-open-type.hh" +#include "hb.hh" + +#ifndef HB_NO_COLOR + +#include "hb-ot.h" + #include "hb-ot-color-cbdt-table.hh" #include "hb-ot-color-colr-table.hh" #include "hb-ot-color-cpal-table.hh" #include "hb-ot-color-sbix-table.hh" #include "hb-ot-color-svg-table.hh" -#include "hb-ot-face.hh" -#include "hb-ot.h" #include #include -#include "hb-ot-layout.hh" - /** * SECTION:hb-ot-color @@ -70,9 +71,6 @@ hb_bool_t hb_ot_color_has_palettes (hb_face_t *face) { -#ifdef HB_NO_COLOR - return false; -#endif return face->table.CPAL->has_data (); } @@ -89,9 +87,6 @@ hb_ot_color_has_palettes (hb_face_t *face) unsigned int hb_ot_color_palette_get_count (hb_face_t *face) { -#ifdef HB_NO_COLOR - return 0; -#endif return face->table.CPAL->get_palette_count (); } @@ -115,9 +110,6 @@ hb_ot_name_id_t hb_ot_color_palette_get_name_id (hb_face_t *face, unsigned int palette_index) { -#ifdef HB_NO_COLOR - return HB_OT_NAME_ID_INVALID; -#endif return face->table.CPAL->get_palette_name_id (palette_index); } @@ -140,9 +132,6 @@ hb_ot_name_id_t hb_ot_color_palette_color_get_name_id (hb_face_t *face, unsigned int color_index) { -#ifdef HB_NO_COLOR - return HB_OT_NAME_ID_INVALID; -#endif return face->table.CPAL->get_color_name_id (color_index); } @@ -161,9 +150,6 @@ hb_ot_color_palette_flags_t hb_ot_color_palette_get_flags (hb_face_t *face, unsigned int palette_index) { -#ifdef HB_NO_COLOR - return HB_OT_COLOR_PALETTE_FLAG_DEFAULT; -#endif return face->table.CPAL->get_palette_flags (palette_index); } @@ -195,11 +181,6 @@ hb_ot_color_palette_get_colors (hb_face_t *face, unsigned int *colors_count /* IN/OUT. May be NULL. */, hb_color_t *colors /* OUT. May be NULL. */) { -#ifdef HB_NO_COLOR - if (colors_count) - *colors_count = 0; - return 0; -#endif return face->table.CPAL->get_palette_colors (palette_index, start_offset, colors_count, colors); } @@ -221,9 +202,6 @@ hb_ot_color_palette_get_colors (hb_face_t *face, hb_bool_t hb_ot_color_has_layers (hb_face_t *face) { -#ifdef HB_NO_COLOR - return false; -#endif return face->table.COLR->has_data (); } @@ -250,11 +228,6 @@ hb_ot_color_glyph_get_layers (hb_face_t *face, unsigned int *layer_count, /* IN/OUT. May be NULL. */ hb_ot_color_layer_t *layers /* OUT. May be NULL. */) { -#ifdef HB_NO_COLOR - if (layer_count) - *layer_count = 0; - return 0; -#endif return face->table.COLR->get_glyph_layers (glyph, start_offset, layer_count, layers); } @@ -276,9 +249,6 @@ hb_ot_color_glyph_get_layers (hb_face_t *face, hb_bool_t hb_ot_color_has_svg (hb_face_t *face) { -#ifdef HB_NO_COLOR - return false; -#endif return face->table.SVG->has_data (); } @@ -296,9 +266,6 @@ hb_ot_color_has_svg (hb_face_t *face) hb_blob_t * hb_ot_color_glyph_reference_svg (hb_face_t *face, hb_codepoint_t glyph) { -#ifdef HB_NO_COLOR - return hb_blob_get_empty (); -#endif return face->table.SVG->reference_blob_for_glyph (glyph); } @@ -320,9 +287,6 @@ hb_ot_color_glyph_reference_svg (hb_face_t *face, hb_codepoint_t glyph) hb_bool_t hb_ot_color_has_png (hb_face_t *face) { -#ifdef HB_NO_COLOR - return false; -#endif return face->table.CBDT->has_data () || face->table.sbix->has_data (); } @@ -342,10 +306,6 @@ hb_ot_color_has_png (hb_face_t *face) hb_blob_t * hb_ot_color_glyph_reference_png (hb_font_t *font, hb_codepoint_t glyph) { -#ifdef HB_NO_COLOR - return hb_blob_get_empty (); -#endif - hb_blob_t *blob = hb_blob_get_empty (); if (font->face->table.sbix->has_data ()) @@ -356,3 +316,6 @@ hb_ot_color_glyph_reference_png (hb_font_t *font, hb_codepoint_t glyph) return blob; } + + +#endif diff --git a/src/test-ot-color.cc b/src/test-ot-color.cc index 26931fe..44bd2eb 100644 --- a/src/test-ot-color.cc +++ b/src/test-ot-color.cc @@ -23,7 +23,10 @@ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. */ -#include "hb.h" +#include "hb.hh" + +#ifndef HB_NO_COLOR + #include "hb-ot.h" #include "hb-ft.h" @@ -334,3 +337,7 @@ main (int argc, char **argv) return 0; } + +#else +int main (int argc, char **argv) { return 0; } +#endif -- 2.7.4