diff --git a/src/hb-ot-color.cc b/src/hb-ot-color.cc index e47b325d8..42ced5284 100644 --- a/src/hb-ot-color.cc +++ b/src/hb-ot-color.cc @@ -26,8 +26,11 @@ */ #include "hb-open-type.hh" +#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" @@ -51,6 +54,29 @@ _get_cpal (hb_face_t *face) return *(hb_ot_face_data (face)->CPAL.get ()); } +#if 0 +static inline const OT::CBDT_accelerator_t& +_get_cbdt (hb_face_t *face) +{ + if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::CBDT_accelerator_t); + return *(hb_ot_face_data (face)->CBDT.get ()); +} + +static inline const OT::sbix& +_get_sbix (hb_face_t *face) +{ + if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::sbix); + return *(hb_ot_face_data (face)->sbix.get ()); +} + +static inline const OT::SVG& +_get_svg (hb_face_t *face) +{ + if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::SVG); + return *(hb_ot_face_data (face)->SVG.get ()); +} +#endif + /** * hb_ot_color_has_cpal_data: * @face: a font face. diff --git a/src/hb-ot-face.hh b/src/hb-ot-face.hh index 05aab5775..ba210f64a 100644 --- a/src/hb-ot-face.hh +++ b/src/hb-ot-face.hh @@ -47,9 +47,6 @@ /* OpenType shaping. */ \ HB_OT_TABLE(OT, JSTF) \ HB_OT_TABLE(OT, BASE) \ - /* OpenType color */ \ - HB_OT_TABLE(OT, COLR) \ - HB_OT_TABLE(OT, CPAL) \ /* AAT shaping. */ \ HB_OT_TABLE(AAT, morx) \ HB_OT_TABLE(AAT, kerx) \ @@ -73,7 +70,12 @@ HB_OT_ACCELERATOR(OT, glyf) \ HB_OT_ACCELERATOR(OT, cff1) \ HB_OT_ACCELERATOR(OT, cff2) \ + /* OpenType color fonts. */ \ + HB_OT_TABLE(OT, COLR) \ + HB_OT_TABLE(OT, CPAL) \ HB_OT_ACCELERATOR(OT, CBDT) \ + HB_OT_TABLE(OT, sbix) \ + HB_OT_TABLE(OT, SVG) \ /* */ /* Declare tables. */ diff --git a/test/api/fonts/README b/test/api/fonts/README index 7e7783c24..4830c47bb 100644 --- a/test/api/fonts/README +++ b/test/api/fonts/README @@ -1,3 +1,5 @@ cmap-format12-only files created by ttx & remove all other cmap entries Inconsolata-Regular.abc.widerc.ttf has the hmtx width of "c" set to 600; everything else is 500. Subsetting out c should reduce numberOfHMetrics to 1. + +chromacheck-* fonts are from https://github.com/RoelN/ChromaCheck/tree/master/fonts and licensed under MIT by Roel Nieskens and Google. diff --git a/test/api/fonts/chromacheck-cbdt.ttf b/test/api/fonts/chromacheck-cbdt.ttf new file mode 100644 index 000000000..100c01a97 Binary files /dev/null and b/test/api/fonts/chromacheck-cbdt.ttf differ diff --git a/test/api/fonts/chromacheck-colr.ttf b/test/api/fonts/chromacheck-colr.ttf new file mode 100644 index 000000000..626809cb7 Binary files /dev/null and b/test/api/fonts/chromacheck-colr.ttf differ diff --git a/test/api/fonts/chromacheck-sbix.ttf b/test/api/fonts/chromacheck-sbix.ttf new file mode 100644 index 000000000..b6f1fe9d6 Binary files /dev/null and b/test/api/fonts/chromacheck-sbix.ttf differ diff --git a/test/api/fonts/chromacheck-svg.ttf b/test/api/fonts/chromacheck-svg.ttf new file mode 100644 index 000000000..d39cc56bc Binary files /dev/null and b/test/api/fonts/chromacheck-svg.ttf differ diff --git a/test/api/hb-test.h b/test/api/hb-test.h index 5c074c1f6..3f8d08b96 100644 --- a/test/api/hb-test.h +++ b/test/api/hb-test.h @@ -288,7 +288,7 @@ hb_test_open_font_file (const char *font_path) hb_blob_t *blob = hb_blob_create_from_file (path); if (hb_blob_get_length (blob) == 0) - g_error ("Font not found."); + g_error ("Font %s not found.", path); hb_face_t *face = hb_face_create (blob, 0); hb_blob_destroy (blob); diff --git a/test/api/test-ot-color.c b/test/api/test-ot-color.c index 4e358203d..0eb0d681e 100644 --- a/test/api/test-ot-color.c +++ b/test/api/test-ot-color.c @@ -99,6 +99,11 @@ static hb_face_t *cpal_v0 = NULL; */ static hb_face_t *cpal_v1 = NULL; +static hb_face_t *cpal = NULL; +static hb_face_t *cbdt = NULL; +static hb_face_t *sbix = NULL; +static hb_face_t *svg = NULL; + #define assert_color_rgba(colors, i, r, g, b, a) G_STMT_START { \ const hb_color_t *_colors = (colors); \ const size_t _i = (i); \ @@ -352,10 +357,18 @@ test_hb_ot_color_has_data (void) g_assert (hb_ot_color_has_colr_data (empty) == FALSE); g_assert (hb_ot_color_has_colr_data (cpal_v0) == TRUE); g_assert (hb_ot_color_has_colr_data (cpal_v1) == TRUE); + g_assert (hb_ot_color_has_colr_data (cpal) == TRUE); + g_assert (hb_ot_color_has_colr_data (cbdt) == FALSE); + g_assert (hb_ot_color_has_colr_data (sbix) == FALSE); + g_assert (hb_ot_color_has_colr_data (svg) == FALSE); g_assert (hb_ot_color_has_cpal_data (empty) == FALSE); g_assert (hb_ot_color_has_cpal_data (cpal_v0) == TRUE); g_assert (hb_ot_color_has_cpal_data (cpal_v1) == TRUE); + g_assert (hb_ot_color_has_cpal_data (cpal) == TRUE); + g_assert (hb_ot_color_has_cpal_data (cbdt) == FALSE); + g_assert (hb_ot_color_has_cpal_data (sbix) == FALSE); + g_assert (hb_ot_color_has_cpal_data (svg) == FALSE); } int @@ -366,6 +379,10 @@ main (int argc, char **argv) hb_test_init (&argc, &argv); cpal_v0 = hb_test_open_font_file ("fonts/cpal-v0.ttf"); cpal_v1 = hb_test_open_font_file ("fonts/cpal-v1.ttf"); + cpal = hb_test_open_font_file ("fonts/chromacheck-colr.ttf"); + cbdt = hb_test_open_font_file ("fonts/chromacheck-cbdt.ttf"); + sbix = hb_test_open_font_file ("fonts/chromacheck-sbix.ttf"); + svg = hb_test_open_font_file ("fonts/chromacheck-svg.ttf"); hb_test_add (test_hb_ot_color_get_palette_count); hb_test_add (test_hb_ot_color_get_palette_name_id_empty); hb_test_add (test_hb_ot_color_get_palette_name_id_v0); @@ -382,5 +399,9 @@ main (int argc, char **argv) status = hb_test_run(); hb_face_destroy (cpal_v0); hb_face_destroy (cpal_v1); + hb_face_destroy (cpal); + hb_face_destroy (cbdt); + hb_face_destroy (sbix); + hb_face_destroy (svg); return status; }