From 65ed82fde5ad413ebbfb214a692b4c671f49d097 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Tue, 2 Aug 2022 22:22:42 +0000 Subject: [PATCH] [repacker] PairPosFormat2::do_split. --- src/graph/pairpos-graph.hh | 45 +++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/src/graph/pairpos-graph.hh b/src/graph/pairpos-graph.hh index 96d325f69..2f8df0b16 100644 --- a/src/graph/pairpos-graph.hh +++ b/src/graph/pairpos-graph.hh @@ -264,7 +264,19 @@ struct PairPosFormat2 : public OT::Layout::GPOS_impl::PairPosFormat2_4& format2_device_table_indices; }; - hb_vector_t do_split (gsubgpos_graph_context_t& c, - unsigned this_index, + hb_vector_t do_split (split_context& split_context, hb_vector_t split_points) { - // TODO(garretrieger): implement me. - return hb_vector_t (); + hb_vector_t new_objects; + if (!split_points) + return new_objects; + + for (unsigned i = 0; i < split_points.length; i++) + { + unsigned start = split_points[i]; + unsigned end = (i < split_points.length - 1) ? split_points[i + 1] : class1Count; + unsigned id = clone_range (split_context, start, end); + + if (id == (unsigned) -1) + { + new_objects.reset (); + new_objects.allocated = -1; // mark error + return new_objects; + } + new_objects.push (id); + } + + if (!shrink (split_context, split_points[0])) + { + new_objects.reset (); + new_objects.allocated = -1; // mark error + } + + return new_objects; } unsigned clone_range (split_context& split_context,