提交 fd0bde63 编写于 作者: B Behdad Esfahbod

[subset] Fix loca offsets

Was writing source font's offsets. Ouch.
上级 aeed082e
...@@ -38,14 +38,12 @@ _calculate_glyf_and_loca_prime_size (const OT::glyf::accelerator_t &glyf, ...@@ -38,14 +38,12 @@ _calculate_glyf_and_loca_prime_size (const OT::glyf::accelerator_t &glyf,
{ {
unsigned int total = 0; unsigned int total = 0;
unsigned int count = 0; unsigned int count = 0;
for (unsigned int i = 0; i < glyph_ids.len; i++) { for (unsigned int i = 0; i < glyph_ids.len; i++)
{
hb_codepoint_t next_glyph = glyph_ids[i]; hb_codepoint_t next_glyph = glyph_ids[i];
unsigned int start_offset, end_offset; unsigned int start_offset, end_offset;
if (unlikely (!glyf.get_offsets (next_glyph, &start_offset, &end_offset))) { if (unlikely (!glyf.get_offsets (next_glyph, &start_offset, &end_offset)))
*glyf_size = 0; end_offset = start_offset = 0;
*loca_size = sizeof(OT::HBUINT32);
return false;
}
total += end_offset - start_offset; total += end_offset - start_offset;
count++; count++;
...@@ -84,27 +82,21 @@ _write_glyf_and_loca_prime (const OT::glyf::accelerator_t &glyf, ...@@ -84,27 +82,21 @@ _write_glyf_and_loca_prime (const OT::glyf::accelerator_t &glyf,
{ {
char *glyf_prime_data_next = glyf_prime_data; char *glyf_prime_data_next = glyf_prime_data;
hb_codepoint_t new_glyph_id = 0; for (unsigned int i = 0; i < glyph_ids.len; i++)
{
unsigned int end_offset = 0; unsigned int start_offset, end_offset;
for (unsigned int i = 0; i < glyph_ids.len; i++) { if (unlikely (!glyf.get_offsets (glyph_ids[i], &start_offset, &end_offset)))
unsigned int start_offset; end_offset = start_offset = 0;
if (unlikely (!glyf.get_offsets (glyph_ids[i], &start_offset, &end_offset))) {
return false;
}
int length = end_offset - start_offset; int length = end_offset - start_offset;
memcpy (glyf_prime_data_next, glyf_data + start_offset, length); memcpy (glyf_prime_data_next, glyf_data + start_offset, length);
_write_loca_entry (i, start_offset, use_short_loca, loca_prime_data); _write_loca_entry (i, glyf_prime_data_next - glyf_prime_data, use_short_loca, loca_prime_data);
glyf_prime_data_next += length; glyf_prime_data_next += length;
new_glyph_id++;
} }
// Add the last loca entry which doesn't correspond to a specific glyph _write_loca_entry (glyph_ids.len, glyf_prime_data_next - glyf_prime_data, use_short_loca, loca_prime_data);
// but identifies the end of the last glyphs data.
_write_loca_entry (new_glyph_id, end_offset, use_short_loca, loca_prime_data);
return true; return true;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册