[repacker] add classDef1 clone_range to PairPosFormat2 split.

This commit is contained in:
Garret Rieger 2022-08-02 21:04:38 +00:00
parent 68b90153ea
commit 22eae32b3b
3 changed files with 27 additions and 16 deletions

View File

@ -72,7 +72,7 @@ struct ClassDef : public OT::ClassDef
auto new_class_def = auto new_class_def =
+ glyphs + glyphs
| hb_map_retains_sorting ([&] (hb_codepoint_t gid) { | hb_map_retains_sorting ([&] (hb_codepoint_t gid) {
return hb_pair (gid, class_def_table[gid]); return hb_pair (gid, class_def_table->get_class (gid));
}) })
; ;
@ -98,7 +98,7 @@ struct ClassDef : public OT::ClassDef
{ {
char* buffer = (char*) hb_calloc (1, max_size); char* buffer = (char*) hb_calloc (1, max_size);
hb_serialize_context_t serializer (buffer, max_size); hb_serialize_context_t serializer (buffer, max_size);
ClassDef_serialize (&serializer, glyph_and_class); OT::ClassDef_serialize (&serializer, glyph_and_class);
serializer.end_serialize (); serializer.end_serialize ();
if (serializer.in_error ()) if (serializer.in_error ())
{ {

View File

@ -56,7 +56,7 @@ struct CoverageFormat2 : public OT::Layout::Common::CoverageFormat2_4<SmallTypes
struct Coverage : public OT::Layout::Common::Coverage struct Coverage : public OT::Layout::Common::Coverage
{ {
static bool clone_coverage (gsubgpos_graph_context_t& c, static Coverage* clone_coverage (gsubgpos_graph_context_t& c,
unsigned coverage_id, unsigned coverage_id,
unsigned new_parent_id, unsigned new_parent_id,
unsigned link_position, unsigned link_position,
@ -67,7 +67,7 @@ struct Coverage : public OT::Layout::Common::Coverage
auto& coverage_v = c.graph.vertices_[coverage_id]; auto& coverage_v = c.graph.vertices_[coverage_id];
Coverage* coverage_table = (Coverage*) coverage_v.obj.head; Coverage* coverage_table = (Coverage*) coverage_v.obj.head;
if (!coverage_table->sanitize (coverage_v)) if (!coverage_table->sanitize (coverage_v))
return false; return nullptr;
auto new_coverage = auto new_coverage =
+ hb_zip (coverage_table->iter (), hb_range ()) + hb_zip (coverage_table->iter (), hb_range ())
@ -80,7 +80,7 @@ struct Coverage : public OT::Layout::Common::Coverage
unsigned coverage_prime_id = c.graph.new_node (nullptr, nullptr); unsigned coverage_prime_id = c.graph.new_node (nullptr, nullptr);
auto& coverage_prime_vertex = c.graph.vertices_[coverage_prime_id]; auto& coverage_prime_vertex = c.graph.vertices_[coverage_prime_id];
if (!make_coverage (c, new_coverage, coverage_prime_id, coverage_size)) if (!make_coverage (c, new_coverage, coverage_prime_id, coverage_size))
return false; return nullptr;
auto* coverage_link = c.graph.vertices_[new_parent_id].obj.real_links.push (); auto* coverage_link = c.graph.vertices_[new_parent_id].obj.real_links.push ();
coverage_link->width = SmallTypes::size; coverage_link->width = SmallTypes::size;
@ -88,7 +88,7 @@ struct Coverage : public OT::Layout::Common::Coverage
coverage_link->position = link_position; coverage_link->position = link_position;
coverage_prime_vertex.parents.push (new_parent_id); coverage_prime_vertex.parents.push (new_parent_id);
return true; return (Coverage*) coverage_prime_vertex.obj.head;
} }
template<typename It> template<typename It>

View File

@ -311,14 +311,25 @@ struct PairPosFormat2 : public OT::Layout::GPOS_impl::PairPosFormat2_4<SmallType
unsigned coverage_id = unsigned coverage_id =
split_context.c.graph.index_for_offset (split_context.this_index, &coverage); split_context.c.graph.index_for_offset (split_context.this_index, &coverage);
if (!Coverage::clone_coverage (split_context.c,
Coverage* new_coverage = Coverage::clone_coverage (split_context.c,
coverage_id, coverage_id,
pair_pos_prime_id, pair_pos_prime_id,
2, 2,
start, end)) start, end);
if (!new_coverage)
return -1;
// classDef1
unsigned class_def_1_id =
split_context.c.graph.index_for_offset (split_context.this_index, &classDef1);
if (!ClassDef::clone_class_def (split_context.c,
class_def_1_id,
pair_pos_prime_id,
8,
new_coverage->iter ()))
return -1; return -1;
// TODO: class def 1 (clone_classdef (start, end))
// TODO: class def 2 (just link to existing) // TODO: class def 2 (just link to existing)
return -1; // TODO return -1; // TODO