[subset] Cmap table: remove encodingRecord entry for empty cmap4 subtable

This commit is contained in:
Qunxin Liu 2020-01-22 11:36:15 -08:00 committed by Garret Rieger
parent d3fff622b3
commit c370da45ff
6 changed files with 28 additions and 4 deletions

View File

@ -238,16 +238,18 @@ struct CmapSubtableFormat4
void serialize (hb_serialize_context_t *c,
Iterator it)
{
unsigned table_initpos = c->length ();
if (unlikely (!c->extend_min (*this))) return;
this->format = 4;
auto format4_iter =
+ it
| hb_filter ([&] (const hb_pair_t<hb_codepoint_t, hb_codepoint_t> _)
{ return _.first <= 0xFFFF; })
;
if (format4_iter.len () == 0) return;
unsigned table_initpos = c->length ();
if (unlikely (!c->extend_min (*this))) return;
this->format = 4;
//serialize endCode[]
HBUINT16 *endCode = serialize_endcode_array (c, format4_iter);
if (unlikely (!endCode)) return;

Binary file not shown.

View File

@ -113,6 +113,26 @@ test_subset_cmap4_no_exceeding_maximum_codepoint (void)
hb_face_destroy (face_origin);
}
static void
test_subset_cmap_empty_tables (void)
{
hb_face_t *face_abc = hb_test_open_font_file ("fonts/Roboto-Regular.abc.ttf");
hb_face_t *face_empty = hb_test_open_font_file ("fonts/Roboto-Regular.empty.ttf");
hb_set_t *codepoints = hb_set_create ();
hb_face_t *face_abc_subset;
hb_set_add (codepoints, 100);
hb_set_add (codepoints, 101);
face_abc_subset = hb_subset_test_create_subset (face_abc, hb_subset_test_create_input (codepoints));
hb_set_destroy (codepoints);
hb_subset_test_check (face_empty, face_abc_subset, HB_TAG ('c','m','a','p'));
hb_face_destroy (face_abc_subset);
hb_face_destroy (face_abc);
hb_face_destroy (face_empty);
}
// TODO(rsheeter) test cmap to no codepoints
int
@ -124,6 +144,7 @@ main (int argc, char **argv)
hb_test_add (test_subset_cmap_noop);
hb_test_add (test_subset_cmap_non_consecutive_glyphs);
hb_test_add (test_subset_cmap4_no_exceeding_maximum_codepoint);
hb_test_add (test_subset_cmap_empty_tables);
return hb_test_run();
}

View File

@ -12,5 +12,6 @@ acek
あいうえおか
あいう珠度輸
𝜕𝟘AB
𥝱