[ot-color] Add public API for CBDT/sbix/SVG color Emojis

This commit is contained in:
Ebrahim Byagowi 2018-10-27 15:15:24 +03:30 committed by Behdad Esfahbod
parent 6ce49a921a
commit dbd419bede
5 changed files with 36 additions and 43 deletions

View File

@ -459,8 +459,12 @@ hb_color_get_blue
hb_color_get_green
hb_color_get_red
hb_ot_color_glyph_get_layers
hb_ot_color_glyph_reference_blob_png
hb_ot_color_glyph_reference_blob_svg
hb_ot_color_has_layers
hb_ot_color_has_palettes
hb_ot_color_has_png
hb_ot_color_has_svg
hb_ot_color_layer_t
hb_ot_color_palette_color_get_name_id
hb_ot_color_palette_flags_t

View File

@ -295,7 +295,7 @@ main (int argc, char **argv)
sbix_dump (face);
// if (hb_ot_color_has_svg (face))
if (hb_ot_color_has_svg (face))
svg_dump (face);
cairo_font_face_t *cairo_face;

View File

@ -57,14 +57,12 @@ _get_colr (hb_face_t *face)
return *(hb_ot_face_data (face)->COLR.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 ());
}
#endif
static inline const OT::CPAL&
_get_cpal (hb_face_t *face)
@ -73,7 +71,6 @@ _get_cpal (hb_face_t *face)
return *(hb_ot_face_data (face)->CPAL.get ());
}
#if 0
static inline const OT::sbix_accelerator_t&
_get_sbix (hb_face_t *face)
{
@ -87,7 +84,6 @@ _get_svg (hb_face_t *face)
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::SVG_accelerator_t);
return *(hb_ot_face_data (face)->SVG.get ());
}
#endif
/*
@ -253,7 +249,6 @@ hb_ot_color_glyph_get_layers (hb_face_t *face,
}
#if 0
/*
* SVG
*/
@ -264,7 +259,7 @@ hb_ot_color_glyph_get_layers (hb_face_t *face,
*
* Returns: whether SVG table is available.
*
* Since: DONTREPLACEME
* Since: REPLACEME
*/
hb_bool_t
hb_ot_color_has_svg (hb_face_t *face)
@ -279,7 +274,7 @@ hb_ot_color_has_svg (hb_face_t *face)
*
* Returns: respective svg blob of the glyph, if available.
*
* Since: DONTREPLACEME
* Since: REPLACEME
*/
hb_blob_t *
hb_ot_color_glyph_reference_blob_svg (hb_face_t *face, hb_codepoint_t glyph)
@ -298,7 +293,7 @@ hb_ot_color_glyph_reference_blob_svg (hb_face_t *face, hb_codepoint_t glyph)
*
* Returns: whether either of CBDT or sbix tables is available.
*
* Since: DONTREPLACEME
* Since: REPLACEME
*/
hb_bool_t
hb_ot_color_has_png (hb_face_t *face)
@ -317,7 +312,7 @@ hb_ot_color_has_png (hb_face_t *face)
*
* Returns: respective png blob of the glyph, if available.
*
* Since: DONTREPLACEME
* Since: REPLACEME
*/
hb_blob_t *
hb_ot_color_glyph_reference_blob_png (hb_font_t *font,
@ -343,29 +338,3 @@ hb_ot_color_glyph_reference_blob_png (hb_font_t *font,
return blob;
}
/* To be moved to public header */
/*
* SVG
*/
HB_EXTERN hb_bool_t
hb_ot_color_has_svg (hb_face_t *face);
HB_EXTERN hb_blob_t *
hb_ot_color_glyph_reference_blob_svg (hb_face_t *face, hb_codepoint_t glyph);
/*
* PNG: CBDT or sbix
*/
HB_EXTERN hb_bool_t
hb_ot_color_has_png (hb_face_t *face);
HB_EXTERN hb_blob_t *
hb_ot_color_glyph_reference_blob_png (hb_font_t *font,
hb_codepoint_t glyph,
unsigned int *strike_x_ppem,
unsigned int *strike_y_ppem);
#endif

View File

@ -111,6 +111,30 @@ hb_ot_color_glyph_get_layers (hb_face_t *face,
unsigned int *count, /* IN/OUT. May be NULL. */
hb_ot_color_layer_t *layers /* OUT. May be NULL. */);
/*
* SVG
*/
HB_EXTERN hb_bool_t
hb_ot_color_has_svg (hb_face_t *face);
HB_EXTERN hb_blob_t *
hb_ot_color_glyph_reference_blob_svg (hb_face_t *face, hb_codepoint_t glyph);
/*
* PNG: CBDT or sbix
*/
HB_EXTERN hb_bool_t
hb_ot_color_has_png (hb_face_t *face);
HB_EXTERN hb_blob_t *
hb_ot_color_glyph_reference_blob_png (hb_font_t *font,
hb_codepoint_t glyph,
unsigned int *strike_x_ppem,
unsigned int *strike_y_ppem);
HB_END_DECLS
#endif /* HB_OT_COLOR_H */

View File

@ -363,7 +363,6 @@ test_hb_ot_color_has_data (void)
g_assert (hb_ot_color_has_palettes (sbix) == FALSE);
g_assert (hb_ot_color_has_palettes (svg) == FALSE);
#if 0
g_assert (hb_ot_color_has_svg (empty) == FALSE);
g_assert (hb_ot_color_has_svg (cpal_v0) == FALSE);
g_assert (hb_ot_color_has_svg (cpal_v1) == FALSE);
@ -379,10 +378,8 @@ test_hb_ot_color_has_data (void)
g_assert (hb_ot_color_has_png (cbdt) == TRUE);
g_assert (hb_ot_color_has_png (sbix) == TRUE);
g_assert (hb_ot_color_has_png (svg) == FALSE);
#endif
}
#if 0
static void
test_hb_ot_color_svg (void)
{
@ -444,7 +441,6 @@ test_hb_ot_color_png (void)
hb_blob_destroy (blob);
hb_font_destroy (cbdt_font);
}
#endif
int
main (int argc, char **argv)
@ -472,8 +468,8 @@ main (int argc, char **argv)
hb_test_add (test_hb_ot_color_palette_color_get_name_id);
hb_test_add (test_hb_ot_color_glyph_get_layers);
hb_test_add (test_hb_ot_color_has_data);
// hb_test_add (test_hb_ot_color_png);
// hb_test_add (test_hb_ot_color_svg);
hb_test_add (test_hb_ot_color_png);
hb_test_add (test_hb_ot_color_svg);
status = hb_test_run();
hb_face_destroy (cpal_v0);
hb_face_destroy (cpal_v1);