From 3d4c1f6a41022ec99adefa2bdd2489622e2f9a66 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Sun, 28 Oct 2018 21:38:56 +0330 Subject: [PATCH] [ot-color] Apply Behdad reviews --- docs/harfbuzz-sections.txt | 4 ++-- src/hb-ot-color-cbdt-table.hh | 15 ++++----------- src/hb-ot-color-sbix-table.hh | 6 ++---- src/hb-ot-color.cc | 8 ++++---- src/hb-ot-color.h | 4 ++-- test/api/test-ot-color.c | 14 +++++++------- 6 files changed, 21 insertions(+), 30 deletions(-) diff --git a/docs/harfbuzz-sections.txt b/docs/harfbuzz-sections.txt index ecce3c77f..c33a1c125 100644 --- a/docs/harfbuzz-sections.txt +++ b/docs/harfbuzz-sections.txt @@ -459,8 +459,8 @@ 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_glyph_reference_png +hb_ot_color_glyph_reference_svg hb_ot_color_has_layers hb_ot_color_has_palettes hb_ot_color_has_png diff --git a/src/hb-ot-color-cbdt-table.hh b/src/hb-ot-color-cbdt-table.hh index 572fcec48..d07c73dbd 100644 --- a/src/hb-ot-color-cbdt-table.hh +++ b/src/hb-ot-color-cbdt-table.hh @@ -505,15 +505,14 @@ 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) const + unsigned int x_ppem, + unsigned int y_ppem) const { if (!cblc) return hb_blob_get_empty (); // Not a color bitmap font. - if (requested_x_ppem == 0) requested_x_ppem = upem; - if (requested_y_ppem == 0) requested_y_ppem = upem; - unsigned int x_ppem = requested_x_ppem, y_ppem = requested_y_ppem; + if (x_ppem == 0) x_ppem = upem; + if (y_ppem == 0) y_ppem = upem; const void *base; const IndexSubtableRecord *subtable_record = this->cblc->find_table (glyph_id, &x_ppem, &y_ppem, &base); @@ -527,8 +526,6 @@ 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; const GlyphBitmapDataFormat17& glyphFormat17 = StructAtOffset (this->cbdt, image_offset); return hb_blob_create_sub_blob (cbdt_blob, @@ -536,8 +533,6 @@ 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; const GlyphBitmapDataFormat18& glyphFormat18 = StructAtOffset (this->cbdt, image_offset); return hb_blob_create_sub_blob (cbdt_blob, @@ -545,8 +540,6 @@ 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; 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 6dfc29d40..a5bfa281e 100644 --- a/src/hb-ot-color-sbix-table.hh +++ b/src/hb-ot-color-sbix-table.hh @@ -84,7 +84,7 @@ struct SBIXStrike hb_blob_t *sbix_blob, unsigned int sbix_len, unsigned int strike_offset, - hb_tag_t requested_file_type, + hb_tag_t file_type, unsigned int num_glyphs) const { if (imageOffsetsZ[glyph_id + 1] - imageOffsetsZ[glyph_id] == 0) @@ -106,10 +106,8 @@ struct SBIXStrike return hb_blob_get_empty (); } } - if (unlikely (requested_file_type != glyph->graphicType)) + if (unlikely (file_type != glyph->graphicType)) return hb_blob_get_empty (); - // 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)); diff --git a/src/hb-ot-color.cc b/src/hb-ot-color.cc index 4a460c8bd..ed41a3b2b 100644 --- a/src/hb-ot-color.cc +++ b/src/hb-ot-color.cc @@ -268,7 +268,7 @@ hb_ot_color_has_svg (hb_face_t *face) } /** - * hb_ot_color_glyph_reference_blob_svg: + * hb_ot_color_glyph_reference_svg: * @face: a font face. * @glyph: a svg glyph index. * @@ -277,7 +277,7 @@ hb_ot_color_has_svg (hb_face_t *face) * Since: REPLACEME */ hb_blob_t * -hb_ot_color_glyph_reference_blob_svg (hb_face_t *face, hb_codepoint_t glyph) +hb_ot_color_glyph_reference_svg (hb_face_t *face, hb_codepoint_t glyph) { return _get_svg (face).reference_blob_for_glyph (glyph); } @@ -302,7 +302,7 @@ hb_ot_color_has_png (hb_face_t *face) } /** - * hb_ot_color_glyph_reference_blob_png: + * hb_ot_color_glyph_reference_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 @@ -313,7 +313,7 @@ hb_ot_color_has_png (hb_face_t *face) * Since: REPLACEME */ hb_blob_t * -hb_ot_color_glyph_reference_blob_png (hb_font_t *font, hb_codepoint_t glyph) +hb_ot_color_glyph_reference_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 */ diff --git a/src/hb-ot-color.h b/src/hb-ot-color.h index 4b0d5b53f..89935143e 100644 --- a/src/hb-ot-color.h +++ b/src/hb-ot-color.h @@ -119,7 +119,7 @@ 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); +hb_ot_color_glyph_reference_svg (hb_face_t *face, hb_codepoint_t glyph); /* * PNG: CBDT or sbix @@ -129,7 +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); +hb_ot_color_glyph_reference_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 c4c5610e2..f825c83ad 100644 --- a/test/api/test-ot-color.c +++ b/test/api/test-ot-color.c @@ -385,10 +385,10 @@ test_hb_ot_color_svg (void) { hb_blob_t *blob; - blob = hb_ot_color_glyph_reference_blob_svg (svg, 0); + blob = hb_ot_color_glyph_reference_svg (svg, 0); g_assert (hb_blob_get_length (blob) == 0); - blob = hb_ot_color_glyph_reference_blob_svg (svg, 1); + blob = hb_ot_color_glyph_reference_svg (svg, 1); unsigned int length; const char *data = hb_blob_get_data (blob, &length); g_assert_cmpuint (length, ==, 146); @@ -396,7 +396,7 @@ test_hb_ot_color_svg (void) g_assert (strncmp (data + 140, "", 5) == 0); hb_blob_destroy (blob); - blob = hb_ot_color_glyph_reference_blob_svg (empty, 0); + blob = hb_ot_color_glyph_reference_svg (empty, 0); g_assert (hb_blob_get_length (blob) == 0); } @@ -411,10 +411,10 @@ test_hb_ot_color_png (void) /* sbix */ hb_font_t *sbix_font; sbix_font = hb_font_create (sbix); - blob = hb_ot_color_glyph_reference_blob_png (sbix_font, 0); + blob = hb_ot_color_glyph_reference_png (sbix_font, 0); g_assert (hb_blob_get_length (blob) == 0); - blob = hb_ot_color_glyph_reference_blob_png (sbix_font, 1); + blob = hb_ot_color_glyph_reference_png (sbix_font, 1); data = hb_blob_get_data (blob, &length); g_assert_cmpuint (length, ==, 224); g_assert (strncmp (data + 1, "PNG", 3) == 0); @@ -424,10 +424,10 @@ 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); + blob = hb_ot_color_glyph_reference_png (cbdt_font, 0); g_assert (hb_blob_get_length (blob) == 0); - blob = hb_ot_color_glyph_reference_blob_png (cbdt_font, 1); + blob = hb_ot_color_glyph_reference_png (cbdt_font, 1); data = hb_blob_get_data (blob, &length); g_assert_cmpuint (length, ==, 88); g_assert (strncmp (data + 1, "PNG", 3) == 0);