提交 0ac8c0c1 编写于 作者: R Rod Sheeter

[subset] zero glyf and loca memory before writing so pads are clean. Test just...

[subset] zero glyf and loca memory before writing so pads are clean. Test just the part of maxp we care about
上级 9bd6d252
......@@ -286,7 +286,7 @@ struct glyf
static const int FLAG_Y_SAME = 0x20;
if (*end_offset - start_offset < GlyphHeader::static_size)
return false;
return true;
const char *glyph = ((const char *) glyf_table) + start_offset;
const char * const glyph_end = glyph + (*end_offset - start_offset);
......@@ -313,7 +313,7 @@ struct glyf
while (glyph < glyph_end)
{
uint8_t flag = (uint8_t) *glyph;
glyph++; i++;
glyph++;
unsigned int repeat = 1;
if (flag & FLAG_REPEAT)
......@@ -324,7 +324,7 @@ struct glyf
return false;
}
repeat = ((uint8_t) *glyph) + 1;
glyph++; i++;
glyph++;
}
unsigned int xBytes, yBytes;
......
......@@ -230,8 +230,8 @@ _hb_subset_glyf_and_loca (const OT::glyf::accelerator_t &glyf,
return false;
}
char *glyf_prime_data = (char *) malloc (glyf_prime_size);
char *loca_prime_data = (char *) malloc (loca_prime_size);
char *glyf_prime_data = (char *) calloc (1, glyf_prime_size);
char *loca_prime_data = (char *) calloc (1, loca_prime_size);
if (unlikely (!_write_glyf_and_loca_prime (plan, glyf, glyf_data,
*use_short_loca,
instruction_ranges,
......
......@@ -31,6 +31,18 @@
/* Unit tests for hb-subset-glyf.h */
static void check_maxp_num_glyphs (hb_face_t *face, uint16_t expected_num_glyphs)
{
hb_blob_t *maxp_blob = hb_face_reference_table (face, HB_TAG ('m','a','x', 'p'));
unsigned int maxp_len;
uint8_t *raw_maxp = (uint8_t *) hb_blob_get_data(maxp_blob, &maxp_len);
uint16_t num_glyphs = (raw_maxp[4] << 8) + raw_maxp[5];
g_assert_cmpuint(expected_num_glyphs, ==, num_glyphs);
hb_blob_destroy (maxp_blob);
}
static void
test_subset_glyf (void)
{
......@@ -45,7 +57,7 @@ test_subset_glyf (void)
hb_subset_test_check (face_ac, face_abc_subset, HB_TAG ('g','l','y','f'));
hb_subset_test_check (face_ac, face_abc_subset, HB_TAG ('l','o','c', 'a'));
hb_subset_test_check (face_ac, face_abc_subset, HB_TAG ('m','a','x', 'p'));
check_maxp_num_glyphs(face_abc_subset, 3);
hb_face_destroy (face_abc_subset);
hb_face_destroy (face_abc);
......@@ -65,7 +77,7 @@ test_subset_glyf_with_components (void)
hb_subset_test_check (face_subset, face_generated_subset, HB_TAG ('g','l','y','f'));
hb_subset_test_check (face_subset, face_generated_subset, HB_TAG ('l','o','c', 'a'));
hb_subset_test_check (face_subset, face_generated_subset, HB_TAG ('m','a','x', 'p'));
check_maxp_num_glyphs(face_generated_subset, 4);
hb_face_destroy (face_generated_subset);
hb_face_destroy (face_subset);
......@@ -86,6 +98,7 @@ test_subset_glyf_noop (void)
hb_subset_test_check (face_abc, face_abc_subset, HB_TAG ('g','l','y','f'));
hb_subset_test_check (face_abc, face_abc_subset, HB_TAG ('l','o','c', 'a'));
check_maxp_num_glyphs(face_abc_subset, 4);
hb_face_destroy (face_abc_subset);
hb_face_destroy (face_abc);
......@@ -107,7 +120,7 @@ test_subset_glyf_strip_hints (void)
hb_subset_test_check (face_ac, face_abc_subset, HB_TAG ('l','o','c', 'a'));
hb_subset_test_check (face_ac, face_abc_subset, HB_TAG ('g','l','y','f'));
hb_subset_test_check (face_ac, face_abc_subset, HB_TAG ('m','a','x', 'p'));
check_maxp_num_glyphs(face_abc_subset, 3);
hb_face_destroy (face_abc_subset);
hb_face_destroy (face_abc);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册