From a19138e668e77a0c05da2ab065c5366c8359b377 Mon Sep 17 00:00:00 2001 From: Rod Sheeter Date: Thu, 8 Feb 2018 19:03:41 -0800 Subject: [PATCH] comment the serialization of table --- src/hb-open-file-private.hh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh index ab168ab8..d0e03ddc 100644 --- a/src/hb-open-file-private.hh +++ b/src/hb-open-file-private.hh @@ -133,10 +133,15 @@ typedef struct OffsetTable unsigned int table_count) { TRACE_SERIALIZE (this); + // alloc 12 for the OTHeader if (unlikely (!c->extend_min (*this))) return_trace (false); + // write sfntVersion (bytes 0..3) sfnt_version.set (sfnt_tag); + // take space for numTables, searchRange, entrySelector, RangeShift + // and the TableRecords themselves if (unlikely (!tables.serialize (c, table_count))) return_trace (false); + // write OffsetTables, alloc for and write actual table blobs for (unsigned int i = 0; i < table_count; i++) { TableRecord &rec = tables.array[i]; @@ -145,9 +150,12 @@ typedef struct OffsetTable rec.length.set (hb_blob_get_length (blob)); rec.checkSum.set_for_data (hb_blob_get_data (blob, nullptr), rec.length); rec.offset.serialize (c, this); + // take room for the tablerec void *p = c->allocate_size (rec.length); if (unlikely (!p)) {return false;} + // copy the actual table memcpy (p, hb_blob_get_data (blob, nullptr), rec.length); + // 4-byte allignment if (rec.length % 4) p = c->allocate_size (4 - rec.length % 4); } -- GitLab