[subset] Use a supplier instead of memcpy and fix a few unnecessary {}s for cmap

This commit is contained in:
Rod Sheeter 2018-02-14 15:20:43 -08:00
parent 42a80f00d5
commit 88d56e241b

View File

@ -276,8 +276,8 @@ struct CmapSubtableLongSegmented
{ {
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
if (unlikely(!context->extend_min (*this))) return_trace (false); if (unlikely(!context->extend_min (*this))) return_trace (false);
if (unlikely(!groups.serialize(context, group_data.len))) return_trace (false); Supplier<CmapSubtableLongGroup> supplier(group_data.array, group_data.len);
memcpy(&groups[0], &group_data[0], group_data.len * sizeof(CmapSubtableLongGroup)); if (unlikely(!groups.serialize(context, supplier, group_data.len))) return_trace (false);
return true; return true;
} }
@ -565,10 +565,7 @@ struct cmap
cmap->version.set(0); cmap->version.set(0);
if (unlikely(!cmap->encodingRecord.serialize(&context, /* numTables */ 1))) if (unlikely(!cmap->encodingRecord.serialize(&context, /* numTables */ 1))) return false;
{
return false;
}
EncodingRecord &rec = cmap->encodingRecord[0]; EncodingRecord &rec = cmap->encodingRecord[0];
rec.platformID.set (3); // Windows rec.platformID.set (3); // Windows
@ -580,19 +577,13 @@ struct cmap
subtable.u.format.set(12); subtable.u.format.set(12);
CmapSubtableFormat12 &format12 = subtable.u.format12; CmapSubtableFormat12 &format12 = subtable.u.format12;
if (unlikely(!context.extend_min(format12))) if (unlikely(!context.extend_min(format12))) return false;
{
return false;
}
format12.format.set(12); format12.format.set(12);
format12.reservedZ.set(0); format12.reservedZ.set(0);
format12.lengthZ.set(16 + 12 * groups.len); format12.lengthZ.set(16 + 12 * groups.len);
if (unlikely(!format12.serialize(&context, groups))) if (unlikely(!format12.serialize(&context, groups))) return false;
{
return false;
}
context.end_serialize (); context.end_serialize ();
@ -603,10 +594,7 @@ struct cmap
{ {
hb_auto_array_t<CmapSubtableLongGroup> groups; hb_auto_array_t<CmapSubtableLongGroup> groups;
if (unlikely(!populate_groups(plan, &groups))) if (unlikely(!populate_groups(plan, &groups))) return false;
{
return false;
}
// We now know how big our blob needs to be // We now know how big our blob needs to be
// TODO use APIs from the structs to get size? // TODO use APIs from the structs to get size?