|
|
|
@ -16,20 +16,30 @@ template<typename IteratorIn, typename IteratorOut, |
|
|
|
|
hb_requires (hb_is_source_of (IteratorIn, unsigned int)), |
|
|
|
|
hb_requires (hb_is_sink_of (IteratorOut, unsigned))> |
|
|
|
|
static void |
|
|
|
|
_write_loca (IteratorIn&& it, bool short_offsets, IteratorOut&& dest) |
|
|
|
|
_write_loca (IteratorIn&& it, |
|
|
|
|
const hb_sorted_vector_t<hb_pair_t<hb_codepoint_t, hb_codepoint_t>> new_to_old_gid_list, |
|
|
|
|
bool short_offsets, |
|
|
|
|
IteratorOut&& dest) |
|
|
|
|
{ |
|
|
|
|
unsigned num_glyphs = hb_len (dest) - 1; |
|
|
|
|
unsigned right_shift = short_offsets ? 1 : 0; |
|
|
|
|
unsigned int offset = 0; |
|
|
|
|
dest << 0; |
|
|
|
|
+ it |
|
|
|
|
| hb_map ([=, &offset] (unsigned int padded_size) |
|
|
|
|
{ |
|
|
|
|
offset += padded_size; |
|
|
|
|
DEBUG_MSG (SUBSET, nullptr, "loca entry offset %u", offset); |
|
|
|
|
return offset >> right_shift; |
|
|
|
|
}) |
|
|
|
|
| hb_sink (dest) |
|
|
|
|
; |
|
|
|
|
unsigned offset = 0; |
|
|
|
|
*dest++ = 0; |
|
|
|
|
for (hb_codepoint_t i = 0, j = 0; i < num_glyphs; i++) |
|
|
|
|
{ |
|
|
|
|
if (i != new_to_old_gid_list[j].first) |
|
|
|
|
{ |
|
|
|
|
DEBUG_MSG (SUBSET, nullptr, "loca entry empty offset %u", offset); |
|
|
|
|
*dest++ = offset >> right_shift; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
j++; |
|
|
|
|
unsigned padded_size = *it++; |
|
|
|
|
offset += padded_size; |
|
|
|
|
DEBUG_MSG (SUBSET, nullptr, "loca entry offset %u padded-size %u", offset, padded_size); |
|
|
|
|
*dest++ = offset >> right_shift; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static bool |
|
|
|
@ -67,9 +77,13 @@ _add_head_and_set_loca_version (hb_subset_plan_t *plan, bool use_short_loca) |
|
|
|
|
template<typename Iterator, |
|
|
|
|
hb_requires (hb_is_source_of (Iterator, unsigned int))> |
|
|
|
|
static bool |
|
|
|
|
_add_loca_and_head (hb_subset_plan_t * plan, Iterator padded_offsets, bool use_short_loca) |
|
|
|
|
_add_loca_and_head (hb_subset_plan_t * plan, |
|
|
|
|
Iterator padded_offsets, |
|
|
|
|
const hb_sorted_vector_t<hb_pair_t<hb_codepoint_t, hb_codepoint_t>> new_to_old_gid_list, |
|
|
|
|
unsigned num_glyphs, |
|
|
|
|
bool use_short_loca) |
|
|
|
|
{ |
|
|
|
|
unsigned num_offsets = padded_offsets.len () + 1; |
|
|
|
|
unsigned num_offsets = num_glyphs + 1; |
|
|
|
|
unsigned entry_size = use_short_loca ? 2 : 4; |
|
|
|
|
char *loca_prime_data = (char *) hb_malloc (entry_size * num_offsets); |
|
|
|
|
|
|
|
|
@ -79,9 +93,9 @@ _add_loca_and_head (hb_subset_plan_t * plan, Iterator padded_offsets, bool use_s |
|
|
|
|
entry_size, num_offsets, entry_size * num_offsets); |
|
|
|
|
|
|
|
|
|
if (use_short_loca) |
|
|
|
|
_write_loca (padded_offsets, true, hb_array ((HBUINT16 *) loca_prime_data, num_offsets)); |
|
|
|
|
_write_loca (padded_offsets, new_to_old_gid_list, true, hb_array ((HBUINT16 *) loca_prime_data, num_offsets)); |
|
|
|
|
else |
|
|
|
|
_write_loca (padded_offsets, false, hb_array ((HBUINT32 *) loca_prime_data, num_offsets)); |
|
|
|
|
_write_loca (padded_offsets, new_to_old_gid_list, false, hb_array ((HBUINT32 *) loca_prime_data, num_offsets)); |
|
|
|
|
|
|
|
|
|
hb_blob_t *loca_blob = hb_blob_create (loca_prime_data, |
|
|
|
|
entry_size * num_offsets, |
|
|
|
|