From 36e1a6339cb0a9bd9ec6e76b64ae83ec871d2f8f Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 1 Dec 2022 16:52:29 -0700 Subject: [PATCH] [cff] Add total_size to INDEX --- src/hb-ot-cff-common.hh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/hb-ot-cff-common.hh b/src/hb-ot-cff-common.hh index 2a17b3218..f22824fc6 100644 --- a/src/hb-ot-cff-common.hh +++ b/src/hb-ot-cff-common.hh @@ -117,6 +117,19 @@ struct CFFIndex return_trace (true); } + template + static unsigned total_size (const Iterable &iterable) + { + auto it = + hb_iter (iterable) | hb_map (hb_iter) | hb_map (hb_len); + if (!it) return 0; + + unsigned total = + it | hb_reduce (hb_add, 0); + unsigned off_size = (hb_bit_storage (total + 1) + 7) / 8; + + return min_size + HBUINT8::static_size + (hb_len (it) + 1) * off_size + total; + } + void set_offset_at (unsigned int index, unsigned int offset) { assert (index <= count);