mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-22 15:31:05 +01:00
[subset] add more aggressive pruning for MarkLigPos and MarkMarkPos (#5434)
Remove lig/mark glyphs without defined anchor points after subsetting
This commit is contained in:
1 parent
7d7f868109
commit
cd49b14b4f
27 files changed
+39
-26
No files matched your search
@@ -19,22 +19,30 @@ struct LigatureArray : List16OfOffset16To<LigatureAttach>
|
||||
bool subset (hb_subset_context_t *c,
|
||||
Iterator coverage,
|
||||
unsigned class_count,
|
||||
const hb_map_t *klass_mapping) const
|
||||
const hb_map_t *klass_mapping,
|
||||
hb_sorted_vector_t<hb_codepoint_t> &new_coverage /* OUT */) const
|
||||
{
|
||||
TRACE_SUBSET (this);
|
||||
const hb_set_t &glyphset = *c->plan->glyphset_gsub ();
|
||||
const hb_map_t &glyph_map = c->plan->glyph_map_gsub;
|
||||
|
||||
auto *out = c->serializer->start_embed (this);
|
||||
if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
|
||||
|
||||
bool ret = false;
|
||||
for (const auto _ : + hb_zip (coverage, *this)
|
||||
| hb_filter (glyphset, hb_first))
|
||||
| hb_filter (glyph_map, hb_first))
|
||||
{
|
||||
const LigatureAttach& src = (this + _.second);
|
||||
bool non_empty = + hb_range (src.rows * class_count)
|
||||
| hb_filter ([=] (unsigned index) { return klass_mapping->has (index % class_count); })
|
||||
| hb_map ([&] (const unsigned index) { return !src.offset_is_null (index / class_count, index % class_count, class_count); })
|
||||
| hb_any;
|
||||
|
||||
if (!non_empty) continue;
|
||||
|
||||
auto *matrix = out->serialize_append (c->serializer);
|
||||
if (unlikely (!matrix)) return_trace (false);
|
||||
|
||||
const LigatureAttach& src = (this + _.second);
|
||||
auto indexes =
|
||||
+ hb_range (src.rows * class_count)
|
||||
| hb_filter ([=] (unsigned index) { return klass_mapping->has (index % class_count); })
|
||||
@@ -44,6 +52,9 @@ struct LigatureArray : List16OfOffset16To<LigatureAttach>
|
||||
this,
|
||||
src.rows,
|
||||
indexes);
|
||||
|
||||
hb_codepoint_t new_gid = glyph_map.get (_.first);
|
||||
new_coverage.push (new_gid);
|
||||
}
|
||||
return_trace (ret);
|
||||
}
|
||||
|
||||
@@ -200,19 +200,13 @@ struct MarkLigPosFormat1_2
|
||||
&klass_mapping)))
|
||||
return_trace (false);
|
||||
|
||||
auto new_ligature_coverage =
|
||||
+ hb_iter (this + ligatureCoverage)
|
||||
| hb_take ((this + ligatureArray).len)
|
||||
| hb_map_retains_sorting (glyph_map)
|
||||
| hb_filter ([] (hb_codepoint_t glyph) { return glyph != HB_MAP_VALUE_INVALID; })
|
||||
;
|
||||
|
||||
if (!out->ligatureCoverage.serialize_serialize (c->serializer, new_ligature_coverage))
|
||||
hb_sorted_vector_t<hb_codepoint_t> new_lig_coverage;
|
||||
if (!out->ligatureArray.serialize_subset (c, ligatureArray, this,
|
||||
hb_iter (this+ligatureCoverage),
|
||||
classCount, &klass_mapping, new_lig_coverage))
|
||||
return_trace (false);
|
||||
|
||||
return_trace (out->ligatureArray.serialize_subset (c, ligatureArray, this,
|
||||
hb_iter (this+ligatureCoverage),
|
||||
classCount, &klass_mapping));
|
||||
return_trace (out->ligatureCoverage.serialize_serialize (c->serializer, new_lig_coverage.iter ()));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -196,19 +196,23 @@ struct MarkMarkPosFormat1_2
|
||||
;
|
||||
|
||||
new_coverage.reset ();
|
||||
+ mark2_iter
|
||||
| hb_map (hb_first)
|
||||
| hb_map (glyph_map)
|
||||
| hb_sink (new_coverage)
|
||||
;
|
||||
|
||||
if (!out->mark2Coverage.serialize_serialize (c->serializer, new_coverage.iter ()))
|
||||
return_trace (false);
|
||||
|
||||
hb_sorted_vector_t<unsigned> mark2_indexes;
|
||||
for (const unsigned row : + mark2_iter
|
||||
| hb_map (hb_second))
|
||||
auto &mark2_array = (this+mark2Array);
|
||||
for (const auto _ : + mark2_iter)
|
||||
{
|
||||
unsigned row = _.second;
|
||||
|
||||
bool non_empty = + hb_range ((unsigned) classCount)
|
||||
| hb_filter (klass_mapping)
|
||||
| hb_map ([&] (const unsigned col) { return !mark2_array.offset_is_null (row, col, (unsigned) classCount); })
|
||||
| hb_any
|
||||
;
|
||||
|
||||
if (!non_empty) continue;
|
||||
|
||||
hb_codepoint_t new_g = glyph_map.get ( _.first);
|
||||
new_coverage.push (new_g);
|
||||
|
||||
+ hb_range ((unsigned) classCount)
|
||||
| hb_filter (klass_mapping)
|
||||
| hb_map ([&] (const unsigned col) { return row * (unsigned) classCount + col; })
|
||||
@@ -216,6 +220,10 @@ struct MarkMarkPosFormat1_2
|
||||
;
|
||||
}
|
||||
|
||||
if (!new_coverage) return_trace (false);
|
||||
if (!out->mark2Coverage.serialize_serialize (c->serializer, new_coverage.iter ()))
|
||||
return_trace (false);
|
||||
|
||||
return_trace (out->mark2Array.serialize_subset (c, mark2Array, this,
|
||||
mark2_iter.len (),
|
||||
mark2_indexes.iter ()));
|
||||
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Reference in new issue
Block a user