From 8ef0d2ef928ac47278d7c6db8c8040a47f076e85 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Sun, 28 Oct 2018 20:09:40 +0330 Subject: [PATCH] [ot-color] Apply Behdad comment --- src/dump-emoji.cc | 2 +- src/hb-ot-color-cbdt-table.hh | 16 +++++++--------- src/hb-ot-color-sbix-table.hh | 14 ++++---------- src/hb-ot-color.cc | 22 +++++++--------------- src/hb-ot-color.h | 5 +---- test/api/test-ot-color.c | 15 ++++----------- 6 files changed, 24 insertions(+), 50 deletions(-) diff --git a/src/dump-emoji.cc b/src/dump-emoji.cc index b622da897..5cbf31abe 100644 --- a/src/dump-emoji.cc +++ b/src/dump-emoji.cc @@ -70,7 +70,7 @@ sbix_dump (hb_face_t *face) { hb_blob_t *blob; blob = sbix.reference_blob_for_glyph (glyph_id, 0, available_ppems[group], - HB_TAG('p','n','g',' '), NULL, NULL); + HB_TAG('p','n','g',' ')); if (hb_blob_get_length (blob) == 0) continue; char output_path[255]; diff --git a/src/hb-ot-color-cbdt-table.hh b/src/hb-ot-color-cbdt-table.hh index 5aa66ccb1..572fcec48 100644 --- a/src/hb-ot-color-cbdt-table.hh +++ b/src/hb-ot-color-cbdt-table.hh @@ -506,9 +506,7 @@ struct CBDT inline hb_blob_t* reference_blob_for_glyph (hb_codepoint_t glyph_id, unsigned int requested_x_ppem, - unsigned int requested_y_ppem, - unsigned int *strike_x_ppem, - unsigned int *strike_y_ppem) const + unsigned int requested_y_ppem) const { if (!cblc) return hb_blob_get_empty (); // Not a color bitmap font. @@ -529,8 +527,8 @@ struct CBDT switch (image_format) { case 17: { - if (strike_x_ppem) *strike_x_ppem = x_ppem; - if (strike_x_ppem) *strike_y_ppem = y_ppem; + // if (strike_x_ppem) *strike_x_ppem = x_ppem; + // if (strike_x_ppem) *strike_y_ppem = y_ppem; const GlyphBitmapDataFormat17& glyphFormat17 = StructAtOffset (this->cbdt, image_offset); return hb_blob_create_sub_blob (cbdt_blob, @@ -538,8 +536,8 @@ struct CBDT glyphFormat17.data.len); } case 18: { - if (strike_x_ppem) *strike_x_ppem = x_ppem; - if (strike_x_ppem) *strike_y_ppem = y_ppem; + // if (strike_x_ppem) *strike_x_ppem = x_ppem; + // if (strike_x_ppem) *strike_y_ppem = y_ppem; const GlyphBitmapDataFormat18& glyphFormat18 = StructAtOffset (this->cbdt, image_offset); return hb_blob_create_sub_blob (cbdt_blob, @@ -547,8 +545,8 @@ struct CBDT glyphFormat18.data.len); } case 19: { - if (strike_x_ppem) *strike_x_ppem = x_ppem; - if (strike_x_ppem) *strike_y_ppem = y_ppem; + // if (strike_x_ppem) *strike_x_ppem = x_ppem; + // if (strike_x_ppem) *strike_y_ppem = y_ppem; const GlyphBitmapDataFormat19& glyphFormat19 = StructAtOffset (this->cbdt, image_offset); return hb_blob_create_sub_blob (cbdt_blob, diff --git a/src/hb-ot-color-sbix-table.hh b/src/hb-ot-color-sbix-table.hh index b48ea1715..6dfc29d40 100644 --- a/src/hb-ot-color-sbix-table.hh +++ b/src/hb-ot-color-sbix-table.hh @@ -84,8 +84,6 @@ struct SBIXStrike hb_blob_t *sbix_blob, unsigned int sbix_len, unsigned int strike_offset, - unsigned int *x_offset, - unsigned int *y_offset, hb_tag_t requested_file_type, unsigned int num_glyphs) const { @@ -110,8 +108,8 @@ struct SBIXStrike } if (unlikely (requested_file_type != glyph->graphicType)) return hb_blob_get_empty (); - if (likely (x_offset)) *x_offset = glyph->xOffset; - if (likely (y_offset)) *y_offset = glyph->yOffset; + // if (x_offset) *x_offset = glyph->xOffset; + // if (y_offset) *y_offset = glyph->yOffset; unsigned int offset = strike_offset + SBIXGlyph::min_size; offset += imageOffsetsZ[glyph_id]; return hb_blob_create_sub_blob (sbix_blob, offset, blob_size (glyph_id)); @@ -169,9 +167,7 @@ struct sbix inline hb_blob_t *reference_blob_for_glyph (hb_codepoint_t glyph_id, unsigned int ptem HB_UNUSED, unsigned int requested_ppem, - unsigned int requested_file_type, - unsigned int *available_x_ppem, - unsigned int *available_y_ppem) const + unsigned int requested_file_type) const { if (unlikely (sbix_len == 0 || sbix_table->strikes.len == 0)) return hb_blob_get_empty (); @@ -185,11 +181,9 @@ struct sbix break; const SBIXStrike &strike = sbix_table+sbix_table->strikes[group]; - if (available_x_ppem) *available_x_ppem = strike.get_ppem (); - if (available_y_ppem) *available_y_ppem = strike.get_ppem (); return strike.get_glyph_blob (glyph_id, sbix_blob, sbix_len, sbix_table->strikes[group], - nullptr, nullptr, requested_file_type, num_glyphs); + requested_file_type, num_glyphs); } inline bool has_data () const diff --git a/src/hb-ot-color.cc b/src/hb-ot-color.cc index fb6ca8660..4a460c8bd 100644 --- a/src/hb-ot-color.cc +++ b/src/hb-ot-color.cc @@ -272,7 +272,7 @@ hb_ot_color_has_svg (hb_face_t *face) * @face: a font face. * @glyph: a svg glyph index. * - * Returns: respective svg blob of the glyph, if available. + * Returns: (transfer full): respective svg blob of the glyph, if available. * * Since: REPLACEME */ @@ -302,39 +302,31 @@ hb_ot_color_has_png (hb_face_t *face) } /** - * hb_ot_color_glyph_reference_blob_svg: + * hb_ot_color_glyph_reference_blob_png: * @font: a font object, not face. upem should be set on * that font object if one wants to get optimal png blob, otherwise * return the biggest one * @glyph: a glyph index. - * @strike_x_ppem: (out): - * @strike_y_ppem: (out): * - * Returns: respective png blob of the glyph, if available. + * Returns: (transfer full): respective png blob of the glyph, if available. * * Since: REPLACEME */ hb_blob_t * -hb_ot_color_glyph_reference_blob_png (hb_font_t *font, - hb_codepoint_t glyph, - unsigned int *strike_x_ppem /* OUT */, - unsigned int *strike_y_ppem /* OUT */) +hb_ot_color_glyph_reference_blob_png (hb_font_t *font, hb_codepoint_t glyph) { hb_blob_t *blob = hb_blob_get_empty (); /* don't run cbdt first if aat is set */ if (!hb_options ().aat && _get_cbdt (font->face).has_data ()) - blob = _get_cbdt (font->face).reference_blob_for_glyph (glyph, font->x_ppem, font->y_ppem, - strike_x_ppem, strike_y_ppem); + blob = _get_cbdt (font->face).reference_blob_for_glyph (glyph, font->x_ppem, font->y_ppem); if (_get_sbix (font->face).has_data () && !hb_blob_get_length (blob)) blob = _get_sbix (font->face).reference_blob_for_glyph (glyph, font->ptem, MAX (font->x_ppem, font->y_ppem), - HB_TAG('p','n','g',' '), - strike_x_ppem, strike_y_ppem); + HB_TAG('p','n','g',' ')); if (hb_options ().aat && _get_cbdt (font->face).has_data () && !hb_blob_get_length (blob)) - blob = _get_cbdt (font->face).reference_blob_for_glyph (glyph, font->x_ppem, font->y_ppem, - strike_x_ppem, strike_y_ppem); + blob = _get_cbdt (font->face).reference_blob_for_glyph (glyph, font->x_ppem, font->y_ppem); return blob; } diff --git a/src/hb-ot-color.h b/src/hb-ot-color.h index a8eae8618..4b0d5b53f 100644 --- a/src/hb-ot-color.h +++ b/src/hb-ot-color.h @@ -129,10 +129,7 @@ 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_ot_color_glyph_reference_blob_png (hb_font_t *font, hb_codepoint_t glyph); HB_END_DECLS diff --git a/test/api/test-ot-color.c b/test/api/test-ot-color.c index 51b901d25..c4c5610e2 100644 --- a/test/api/test-ot-color.c +++ b/test/api/test-ot-color.c @@ -407,20 +407,16 @@ test_hb_ot_color_png (void) hb_blob_t *blob; unsigned int length; const char *data; - unsigned int strike_x_ppem, strike_y_ppem; /* sbix */ hb_font_t *sbix_font; sbix_font = hb_font_create (sbix); - blob = hb_ot_color_glyph_reference_blob_png (sbix_font, 0, NULL, NULL); + blob = hb_ot_color_glyph_reference_blob_png (sbix_font, 0); g_assert (hb_blob_get_length (blob) == 0); - blob = hb_ot_color_glyph_reference_blob_png (sbix_font, 1, - &strike_x_ppem, &strike_y_ppem); + blob = hb_ot_color_glyph_reference_blob_png (sbix_font, 1); data = hb_blob_get_data (blob, &length); g_assert_cmpuint (length, ==, 224); - g_assert_cmpuint (strike_x_ppem, ==, 300); - g_assert_cmpuint (strike_y_ppem, ==, 300); g_assert (strncmp (data + 1, "PNG", 3) == 0); hb_blob_destroy (blob); hb_font_destroy (sbix_font); @@ -428,15 +424,12 @@ test_hb_ot_color_png (void) /* cbdt */ hb_font_t *cbdt_font; cbdt_font = hb_font_create (cbdt); - blob = hb_ot_color_glyph_reference_blob_png (cbdt_font, 0, NULL, NULL); + blob = hb_ot_color_glyph_reference_blob_png (cbdt_font, 0); g_assert (hb_blob_get_length (blob) == 0); - blob = hb_ot_color_glyph_reference_blob_png (cbdt_font, 1, - &strike_x_ppem, &strike_y_ppem); + blob = hb_ot_color_glyph_reference_blob_png (cbdt_font, 1); data = hb_blob_get_data (blob, &length); g_assert_cmpuint (length, ==, 88); - g_assert_cmpuint (strike_x_ppem, ==, 80); - g_assert_cmpuint (strike_y_ppem, ==, 80); g_assert (strncmp (data + 1, "PNG", 3) == 0); hb_blob_destroy (blob); hb_font_destroy (cbdt_font);