mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-25 00:41:09 +01:00
Merge pull request #6185 from harfbuzz/agent/depend-context-memoization
[depend] Speed up contextual dependency collection
This commit is contained in:
17 files changed
+1432
-337
No files matched your search
@@ -872,6 +872,7 @@ hb_set_symmetric_difference
|
||||
hb_set_invert
|
||||
hb_set_is_inverted
|
||||
hb_set_is_equal
|
||||
hb_set_intersects
|
||||
hb_set_is_subset
|
||||
hb_set_next
|
||||
hb_set_next_range
|
||||
|
||||
@@ -139,6 +139,19 @@ struct CoverageFormat2_4
|
||||
return false;
|
||||
}
|
||||
|
||||
static void add_intersected_bits (hb_set_t &set, hb_codepoint_t base, uint64_t bits)
|
||||
{ set.add_bits (base, bits); }
|
||||
|
||||
template <typename IterableOut>
|
||||
static void add_intersected_bits (IterableOut&& out, hb_codepoint_t base, uint64_t bits)
|
||||
{
|
||||
while (bits)
|
||||
{
|
||||
out << base + hb_ctz (bits);
|
||||
bits &= bits - 1;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename IterableOut,
|
||||
hb_requires (hb_is_sink_of (IterableOut, hb_codepoint_t))>
|
||||
void intersect_set (const hb_set_t &glyphs, IterableOut&& intersect_glyphs) const
|
||||
@@ -151,9 +164,18 @@ struct CoverageFormat2_4
|
||||
if (unlikely (range.first < last))
|
||||
break;
|
||||
last = range.last;
|
||||
for (hb_codepoint_t g = range.first - 1;
|
||||
glyphs.next (&g) && g <= last;)
|
||||
intersect_glyphs << g;
|
||||
hb_codepoint_t cursor = range.first & -hb_bit_page_t::ELT_BITS;
|
||||
cursor = cursor ? cursor - 1 : HB_SET_VALUE_INVALID;
|
||||
uint64_t bits;
|
||||
while (glyphs.next_bits (&cursor, &bits) && cursor <= last)
|
||||
{
|
||||
if (range.first > cursor)
|
||||
bits &= UINT64_MAX << (range.first - cursor);
|
||||
unsigned int end = last - cursor;
|
||||
if (end < hb_bit_page_t::ELT_BITS - 1)
|
||||
bits &= (uint64_t (1) << (end + 1)) - 1;
|
||||
add_intersected_bits (intersect_glyphs, cursor, bits);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -211,9 +211,9 @@ struct SubstLookup : Lookup
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline hb_depend_context_t::return_t depend_glyphs_recurse_func (hb_depend_context_t *c, unsigned lookup_index, hb_set_t *covered_seq_indices, unsigned seq_index, unsigned end_index);
|
||||
static inline hb_depend_context_t::return_t depend_glyphs_recurse_func (hb_depend_context_t *c, unsigned lookup_index, hb_bit_page_t *covered_seq_indices, unsigned seq_index, unsigned end_index);
|
||||
|
||||
static inline hb_depend_context_t::return_t dispatch_depend_recurse_func (hb_depend_context_t *c, unsigned lookup_index, hb_set_t *covered_seq_indices, unsigned seq_index, unsigned end_index)
|
||||
static inline hb_depend_context_t::return_t dispatch_depend_recurse_func (hb_depend_context_t *c, unsigned lookup_index, hb_bit_page_t *covered_seq_indices, unsigned seq_index, unsigned end_index)
|
||||
{
|
||||
return depend_glyphs_recurse_func (c, lookup_index, covered_seq_indices, seq_index, end_index);
|
||||
}
|
||||
|
||||
@@ -135,7 +135,9 @@ struct hb_bit_page_t
|
||||
}
|
||||
|
||||
void add (hb_codepoint_t g) { elt (g) |= mask (g); dirty (); }
|
||||
void add_bits (hb_codepoint_t g, uint64_t bits) { elt (g) |= bits; dirty (); }
|
||||
void del (hb_codepoint_t g) { elt (g) &= ~mask (g); dirty (); }
|
||||
void del_bits (hb_codepoint_t g, uint64_t bits) { elt (g) &= ~bits; dirty (); }
|
||||
void set (hb_codepoint_t g, bool value) { if (value) add (g); else del (g); }
|
||||
bool get (hb_codepoint_t g) const { return elt (g) & mask (g); }
|
||||
bool may_have (hb_codepoint_t g) const { return get (g); }
|
||||
|
||||
+140
-16
@@ -101,9 +101,20 @@ struct hb_bit_set_invertible_t
|
||||
}
|
||||
unsigned int get_population () const
|
||||
{ return inverted ? INVALID - s.get_population () : s.get_population (); }
|
||||
bool get_singleton (hb_codepoint_t *codepoint) const
|
||||
{
|
||||
if (likely (!inverted))
|
||||
return s.get_singleton (codepoint);
|
||||
if (s.get_population () != INVALID - 1)
|
||||
return false;
|
||||
*codepoint = get_min ();
|
||||
return *codepoint != INVALID;
|
||||
}
|
||||
|
||||
|
||||
void add (hb_codepoint_t g) { unlikely (inverted) ? s.del (g) : s.add (g); }
|
||||
void add_bits (hb_codepoint_t g, uint64_t bits)
|
||||
{ unlikely (inverted) ? s.del_bits (g, bits) : s.add_bits (g, bits); }
|
||||
bool add_range (hb_codepoint_t a, hb_codepoint_t b)
|
||||
{ return unlikely (inverted) ? ((void) s.del_range (a, b), true) : s.add_range (a, b); }
|
||||
|
||||
@@ -143,6 +154,24 @@ struct hb_bit_set_invertible_t
|
||||
bool may_intersect (const hb_bit_set_invertible_t &other) const
|
||||
{ return inverted || other.inverted || s.intersects (other.s); }
|
||||
|
||||
bool intersects (const hb_bit_set_invertible_t &other) const
|
||||
{
|
||||
if (likely (!inverted))
|
||||
return unlikely (other.inverted) ? !s.is_subset (other.s)
|
||||
: s.intersects (other.s);
|
||||
if (likely (!other.inverted))
|
||||
return !other.s.is_subset (s);
|
||||
|
||||
unsigned population = s.get_population ();
|
||||
unsigned other_population = other.s.get_population ();
|
||||
if ((uint64_t) population + other_population < INVALID)
|
||||
return true;
|
||||
|
||||
return population >= other_population
|
||||
? !hb_all (iter (), other.s)
|
||||
: !hb_all (other.iter (), s);
|
||||
}
|
||||
|
||||
bool intersects (hb_codepoint_t first, hb_codepoint_t last) const
|
||||
{
|
||||
hb_codepoint_t c = first - 1;
|
||||
@@ -187,8 +216,10 @@ struct hb_bit_set_invertible_t
|
||||
|
||||
protected:
|
||||
template <typename Op>
|
||||
void process (const Op& op, const hb_bit_set_invertible_t &other)
|
||||
{ s.process (op, other.s); }
|
||||
void process (const Op& op,
|
||||
const hb_bit_set_invertible_t &other,
|
||||
hb_vector_t<unsigned> *workspace = nullptr)
|
||||
{ s.process (op, other.s, workspace); }
|
||||
public:
|
||||
void union_ (const hb_bit_set_invertible_t &other)
|
||||
{
|
||||
@@ -209,21 +240,22 @@ struct hb_bit_set_invertible_t
|
||||
if (likely (s.successful))
|
||||
inverted = inverted || other.inverted;
|
||||
}
|
||||
void intersect (const hb_bit_set_invertible_t &other)
|
||||
void intersect (const hb_bit_set_invertible_t &other,
|
||||
hb_vector_t<unsigned> *workspace = nullptr)
|
||||
{
|
||||
if (likely (inverted == other.inverted))
|
||||
{
|
||||
if (unlikely (inverted))
|
||||
process (hb_bitwise_or, other);
|
||||
process (hb_bitwise_or, other, workspace);
|
||||
else
|
||||
process (hb_bitwise_and, other); /* Main branch. */
|
||||
process (hb_bitwise_and, other, workspace); /* Main branch. */
|
||||
}
|
||||
else
|
||||
{
|
||||
if (unlikely (inverted))
|
||||
process (hb_bitwise_lt, other);
|
||||
process (hb_bitwise_lt, other, workspace);
|
||||
else
|
||||
process (hb_bitwise_gt, other);
|
||||
process (hb_bitwise_gt, other, workspace);
|
||||
}
|
||||
if (likely (s.successful))
|
||||
inverted = inverted && other.inverted;
|
||||
@@ -280,6 +312,47 @@ struct hb_bit_set_invertible_t
|
||||
*codepoint = v + 1;
|
||||
return *codepoint != INVALID;
|
||||
}
|
||||
bool next_bits (hb_codepoint_t *codepoint, uint64_t *bits) const
|
||||
{
|
||||
if (likely (!inverted))
|
||||
return s.next_bits (codepoint, bits);
|
||||
|
||||
hb_codepoint_t base;
|
||||
if (unlikely (*codepoint == INVALID))
|
||||
base = 0;
|
||||
else
|
||||
{
|
||||
base = *codepoint & -hb_bit_page_t::ELT_BITS;
|
||||
if (unlikely (base >= INVALID - hb_bit_page_t::ELT_BITS + 1))
|
||||
goto done;
|
||||
base += hb_bit_page_t::ELT_BITS;
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
hb_codepoint_t cursor = base ? base - hb_bit_page_t::ELT_BITS : INVALID;
|
||||
uint64_t excluded = 0;
|
||||
if (!s.next_bits (&cursor, &excluded) || cursor != base)
|
||||
excluded = 0;
|
||||
*bits = ~excluded;
|
||||
bool last = unlikely (base >= INVALID - hb_bit_page_t::ELT_BITS + 1);
|
||||
if (last)
|
||||
*bits &= UINT64_MAX >> 1;
|
||||
if (*bits)
|
||||
{
|
||||
*codepoint = base;
|
||||
return true;
|
||||
}
|
||||
if (unlikely (last))
|
||||
break;
|
||||
base += hb_bit_page_t::ELT_BITS;
|
||||
}
|
||||
|
||||
done:
|
||||
*codepoint = INVALID;
|
||||
*bits = 0;
|
||||
return false;
|
||||
}
|
||||
bool previous (hb_codepoint_t *codepoint) const
|
||||
{
|
||||
if (likely (!inverted))
|
||||
@@ -352,27 +425,50 @@ struct hb_bit_set_invertible_t
|
||||
|
||||
/*
|
||||
* Iterator implementation.
|
||||
* Mutating the set invalidates its iterators.
|
||||
*/
|
||||
struct iter_t : hb_iter_with_fallback_t<iter_t, hb_codepoint_t>
|
||||
{
|
||||
static constexpr bool is_sorted_iterator = true;
|
||||
static constexpr bool has_fast_len = true;
|
||||
iter_t (const hb_bit_set_invertible_t &s_ = Null (hb_bit_set_invertible_t),
|
||||
bool init = true) : s (&s_), v (INVALID), l(0)
|
||||
bool init = true) : s (&s_), v (INVALID), remaining (0),
|
||||
have_len (!init), base (INVALID), bits (0)
|
||||
{
|
||||
if (init)
|
||||
{
|
||||
l = s->get_population () + 1;
|
||||
__next__ ();
|
||||
}
|
||||
advance ();
|
||||
}
|
||||
|
||||
typedef hb_codepoint_t __item_t__;
|
||||
hb_codepoint_t __item__ () const { return v; }
|
||||
bool __more__ () const { return v != INVALID; }
|
||||
void __next__ () { s->next (&v); if (likely (l)) l--; }
|
||||
void __prev__ () { s->previous (&v); l++; }
|
||||
unsigned __len__ () const { return l; }
|
||||
void __next__ ()
|
||||
{
|
||||
remaining--;
|
||||
advance ();
|
||||
}
|
||||
void __prev__ ()
|
||||
{
|
||||
if (s->previous (&v))
|
||||
{
|
||||
sync ();
|
||||
remaining++;
|
||||
}
|
||||
else
|
||||
{
|
||||
base = INVALID;
|
||||
bits = 0;
|
||||
}
|
||||
}
|
||||
unsigned __len__ () const
|
||||
{
|
||||
if (unlikely (!have_len))
|
||||
{
|
||||
remaining += s->get_population ();
|
||||
have_len = true;
|
||||
}
|
||||
return remaining;
|
||||
}
|
||||
iter_t end () const { return iter_t (*s, false); }
|
||||
bool operator != (const iter_t& o) const
|
||||
{ return v != o.v; }
|
||||
@@ -380,7 +476,35 @@ struct hb_bit_set_invertible_t
|
||||
protected:
|
||||
const hb_bit_set_invertible_t *s;
|
||||
hb_codepoint_t v;
|
||||
unsigned l;
|
||||
mutable unsigned remaining;
|
||||
mutable bool have_len;
|
||||
hb_codepoint_t base;
|
||||
uint64_t bits;
|
||||
|
||||
void advance ()
|
||||
{
|
||||
if (likely (bits))
|
||||
{
|
||||
v = base + hb_ctz (bits);
|
||||
bits &= bits - 1;
|
||||
}
|
||||
else if (s->next_bits (&base, &bits))
|
||||
{
|
||||
v = base + hb_ctz (bits);
|
||||
bits &= bits - 1;
|
||||
}
|
||||
else
|
||||
v = INVALID;
|
||||
}
|
||||
|
||||
void sync ()
|
||||
{
|
||||
base = v & -hb_bit_page_t::ELT_BITS;
|
||||
hb_codepoint_t cursor = base ? base - hb_bit_page_t::ELT_BITS : INVALID;
|
||||
s->next_bits (&cursor, &bits);
|
||||
unsigned int bit = v & (hb_bit_page_t::ELT_BITS - 1);
|
||||
bits = bit == hb_bit_page_t::ELT_BITS - 1 ? 0 : bits >> (bit + 1) << (bit + 1);
|
||||
}
|
||||
};
|
||||
iter_t iter () const { return iter_t (*this); }
|
||||
operator iter_t () const { return iter (); }
|
||||
|
||||
+116
-6
@@ -161,6 +161,14 @@ struct hb_bit_set_t
|
||||
page_t *page = page_for (g, true); if (unlikely (!page)) return;
|
||||
page->add (g);
|
||||
}
|
||||
void add_bits (hb_codepoint_t g, uint64_t bits)
|
||||
{
|
||||
if (unlikely (!successful) || unlikely (!bits)) return;
|
||||
assert (!(g & (page_t::ELT_BITS - 1)));
|
||||
dirty ();
|
||||
page_t *page = page_for (g, true); if (unlikely (!page)) return;
|
||||
page->add_bits (g, bits);
|
||||
}
|
||||
bool add_range (hb_codepoint_t a, hb_codepoint_t b)
|
||||
{
|
||||
if (unlikely (!successful)) return true; /* https://github.com/harfbuzz/harfbuzz/issues/657 */
|
||||
@@ -291,6 +299,16 @@ struct hb_bit_set_t
|
||||
dirty ();
|
||||
page->del (g);
|
||||
}
|
||||
void del_bits (hb_codepoint_t g, uint64_t bits)
|
||||
{
|
||||
if (unlikely (!successful) || unlikely (!bits)) return;
|
||||
assert (!(g & (page_t::ELT_BITS - 1)));
|
||||
page_t *page = page_for (g);
|
||||
if (!page)
|
||||
return;
|
||||
dirty ();
|
||||
page->del_bits (g, bits);
|
||||
}
|
||||
|
||||
private:
|
||||
void del_pages (int ds, int de)
|
||||
@@ -524,7 +542,8 @@ struct hb_bit_set_t
|
||||
|
||||
void process_ (hb_bit_page_t::vector_t (*op) (const hb_bit_page_t::vector_t &, const hb_bit_page_t::vector_t &),
|
||||
bool passthru_left, bool passthru_right,
|
||||
const hb_bit_set_t &other)
|
||||
const hb_bit_set_t &other,
|
||||
hb_vector_t<unsigned> *workspace = nullptr)
|
||||
{
|
||||
if (unlikely (!successful)) return;
|
||||
|
||||
@@ -540,8 +559,18 @@ struct hb_bit_set_t
|
||||
|
||||
// Pre-allocate the workspace that compact() will need so we can bail on allocation failure
|
||||
// before attempting to rewrite the page map.
|
||||
hb_vector_t<unsigned> compact_workspace;
|
||||
if (!passthru_left && unlikely (!allocate_compact_workspace (compact_workspace))) return;
|
||||
hb_vector_t<unsigned> local_workspace;
|
||||
hb_vector_t<unsigned> &compact_workspace = workspace ? *workspace : local_workspace;
|
||||
if (!passthru_left)
|
||||
{
|
||||
bool allocated = workspace ? compact_workspace.resize (pages.length)
|
||||
: allocate_compact_workspace (compact_workspace);
|
||||
if (unlikely (!allocated))
|
||||
{
|
||||
successful = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (; a < na && b < nb; )
|
||||
{
|
||||
@@ -651,13 +680,17 @@ struct hb_bit_set_t
|
||||
op_ (const hb_bit_page_t::vector_t &a, const hb_bit_page_t::vector_t &b)
|
||||
{ return Op{} (a, b); }
|
||||
template <typename Op>
|
||||
void process (const Op& op, const hb_bit_set_t &other)
|
||||
void process (const Op& op,
|
||||
const hb_bit_set_t &other,
|
||||
hb_vector_t<unsigned> *workspace = nullptr)
|
||||
{
|
||||
process_ (op_<Op>, op (1, 0), op (0, 1), other);
|
||||
process_ (op_<Op>, op (1, 0), op (0, 1), other, workspace);
|
||||
}
|
||||
|
||||
void union_ (const hb_bit_set_t &other) { process (hb_bitwise_or, other); }
|
||||
void intersect (const hb_bit_set_t &other) { process (hb_bitwise_and, other); }
|
||||
void intersect (const hb_bit_set_t &other,
|
||||
hb_vector_t<unsigned> *workspace = nullptr)
|
||||
{ process (hb_bitwise_and, other, workspace); }
|
||||
void subtract (const hb_bit_set_t &other) { process (hb_bitwise_gt, other); }
|
||||
void symmetric_difference (const hb_bit_set_t &other) { process (hb_bitwise_xor, other); }
|
||||
|
||||
@@ -708,6 +741,50 @@ struct hb_bit_set_t
|
||||
*codepoint = INVALID;
|
||||
return false;
|
||||
}
|
||||
bool next_bits (hb_codepoint_t *codepoint, uint64_t *bits) const
|
||||
{
|
||||
static_assert (page_t::ELT_BITS == 64, "");
|
||||
|
||||
unsigned int i = 0;
|
||||
unsigned int elt = 0;
|
||||
if (likely (*codepoint != INVALID))
|
||||
{
|
||||
hb_codepoint_t base = *codepoint & -page_t::ELT_BITS;
|
||||
if (unlikely (base >= INVALID - page_t::ELT_BITS + 1))
|
||||
goto done;
|
||||
base += page_t::ELT_BITS;
|
||||
|
||||
unsigned int major = get_major (base);
|
||||
i = last_page_lookup;
|
||||
if (unlikely (i >= page_map.length || page_map.arrayZ[i].major != major))
|
||||
{
|
||||
page_map.bfind (major, &i, HB_NOT_FOUND_STORE_CLOSEST);
|
||||
if (i >= page_map.length)
|
||||
goto done;
|
||||
}
|
||||
if (page_map.arrayZ[i].major == major)
|
||||
elt = page_remainder (base) / page_t::ELT_BITS;
|
||||
}
|
||||
|
||||
for (; i < page_map.length; i++, elt = 0)
|
||||
{
|
||||
const page_map_t &map = page_map.arrayZ[i];
|
||||
const page_t &page = pages.arrayZ[map.index];
|
||||
for (; elt < page_t::len (); elt++)
|
||||
if (page.v[elt])
|
||||
{
|
||||
*codepoint = major_start (map.major) + elt * page_t::ELT_BITS;
|
||||
*bits = page.v[elt];
|
||||
last_page_lookup = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
*codepoint = INVALID;
|
||||
*bits = 0;
|
||||
return false;
|
||||
}
|
||||
bool previous (hb_codepoint_t *codepoint) const
|
||||
{
|
||||
if (unlikely (*codepoint == INVALID)) {
|
||||
@@ -883,6 +960,39 @@ struct hb_bit_set_t
|
||||
population = pop;
|
||||
return pop;
|
||||
}
|
||||
bool get_singleton (hb_codepoint_t *codepoint) const
|
||||
{
|
||||
if (has_population ())
|
||||
{
|
||||
if (population != 1) return false;
|
||||
*codepoint = get_min ();
|
||||
return true;
|
||||
}
|
||||
|
||||
hb_codepoint_t singleton = INVALID;
|
||||
for (const auto &map : page_map)
|
||||
{
|
||||
const auto &page = pages.arrayZ[map.index];
|
||||
for (unsigned i = 0; i < page_t::len (); i++)
|
||||
{
|
||||
page_t::elt_t bits = page.v[i];
|
||||
if (!bits) continue;
|
||||
if (singleton != INVALID || (bits & (bits - 1)))
|
||||
return false;
|
||||
singleton = map.major * page_t::PAGE_BITS +
|
||||
i * page_t::ELT_BITS + hb_ctz (bits);
|
||||
}
|
||||
}
|
||||
|
||||
if (singleton == INVALID)
|
||||
{
|
||||
population = 0;
|
||||
return false;
|
||||
}
|
||||
population = 1;
|
||||
*codepoint = singleton;
|
||||
return true;
|
||||
}
|
||||
hb_codepoint_t get_min () const
|
||||
{
|
||||
unsigned count = pages.length;
|
||||
|
||||
+148
-17
@@ -273,8 +273,9 @@ struct hb_depend_data_t
|
||||
* construction is complete, leaving only hb_depend_data_t.
|
||||
*
|
||||
* Temporary state (freed on destruction):
|
||||
* - lookup_features: Lookup index to feature tag mapping
|
||||
* - seen_edges: Struct-based edge deduplication table
|
||||
* - lookup_features: Packed lookup index to feature tag mapping
|
||||
* - lookup_feature_offsets: Per-lookup offsets into lookup_features
|
||||
* - edge_slots: Compact edge deduplication table
|
||||
* - set_to_index: Content-based dependency set deduplication map
|
||||
* - free_set_list: Indices of freed sets available for reuse
|
||||
* - current_context_set_index: Context requirements for current rule
|
||||
@@ -455,6 +456,89 @@ struct hb_depend_data_builder_t
|
||||
return find_or_create_context_set (context_elements);
|
||||
}
|
||||
|
||||
static uint64_t encode_edge_ref (hb_codepoint_t source, unsigned int index)
|
||||
{ return (uint64_t (source) + 1) << 32 | index; }
|
||||
|
||||
static void decode_edge_ref (uint64_t ref,
|
||||
hb_codepoint_t *source,
|
||||
unsigned int *index)
|
||||
{
|
||||
*source = (ref >> 32) - 1;
|
||||
*index = ref;
|
||||
}
|
||||
|
||||
uint32_t edge_hash (hb_codepoint_t source, const hb_depend_edge_t &record) const
|
||||
{
|
||||
hb_depend_edge_key_t key (source, record.table_tag, record.layout_tag,
|
||||
record.dependent, record.ligature_set,
|
||||
record.context_set);
|
||||
return key.hash ();
|
||||
}
|
||||
|
||||
bool resize_edge_slots ()
|
||||
{
|
||||
unsigned int new_size = edge_slots.length ? edge_slots.length * 2 : 8;
|
||||
if (unlikely (new_size < edge_slots.length))
|
||||
return fail ();
|
||||
|
||||
hb_vector_t<uint64_t> new_slots;
|
||||
if (unlikely (!new_slots.resize_exact (new_size)))
|
||||
return fail ();
|
||||
|
||||
for (uint64_t ref : edge_slots)
|
||||
{
|
||||
if (!ref)
|
||||
continue;
|
||||
|
||||
hb_codepoint_t source;
|
||||
unsigned int index;
|
||||
decode_edge_ref (ref, &source, &index);
|
||||
const hb_depend_edge_t &record = data.glyph_dependencies[source].dependencies[index];
|
||||
unsigned int slot = edge_hash (source, record) & (new_size - 1);
|
||||
unsigned int step = 0;
|
||||
while (new_slots[slot])
|
||||
slot = (slot + ++step) & (new_size - 1);
|
||||
new_slots[slot] = ref;
|
||||
}
|
||||
|
||||
edge_slots = std::move (new_slots);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool add_edge (hb_codepoint_t source, const hb_depend_edge_t &record)
|
||||
{
|
||||
/* Store only a source and per-glyph edge index in each bucket. The edge
|
||||
* itself already lives in the output vector, where it can be compared to
|
||||
* resolve hash collisions exactly. Adding one to the encoded source
|
||||
* reserves zero as the empty-bucket value. */
|
||||
if (unlikely (!edge_slots.length ||
|
||||
uint64_t (edge_population) * 3 / 2 >= edge_slots.length - 1))
|
||||
if (unlikely (!resize_edge_slots ()))
|
||||
return false;
|
||||
|
||||
unsigned int slot = edge_hash (source, record) & (edge_slots.length - 1);
|
||||
unsigned int step = 0;
|
||||
while (uint64_t ref = edge_slots[slot])
|
||||
{
|
||||
hb_codepoint_t existing_source;
|
||||
unsigned int existing_index;
|
||||
decode_edge_ref (ref, &existing_source, &existing_index);
|
||||
if (existing_source == source &&
|
||||
data.glyph_dependencies[source].dependencies[existing_index] == record)
|
||||
return false;
|
||||
slot = (slot + ++step) & (edge_slots.length - 1);
|
||||
}
|
||||
|
||||
auto &dependencies = data.glyph_dependencies[source].dependencies;
|
||||
unsigned int index = dependencies.length;
|
||||
if (unlikely (!dependencies.push_or_fail (record)))
|
||||
return fail ();
|
||||
|
||||
edge_slots[slot] = encode_edge_ref (source, index);
|
||||
edge_population++;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool add_depend_layout (hb_codepoint_t target, hb_tag_t table_tag,
|
||||
hb_tag_t layout_tag,
|
||||
hb_codepoint_t dependent,
|
||||
@@ -468,18 +552,8 @@ struct hb_depend_data_builder_t
|
||||
return false;
|
||||
}
|
||||
|
||||
hb_depend_edge_key_t key (target, table_tag, layout_tag, dependent, lig_set, context_set);
|
||||
if (seen_edges.has (key))
|
||||
return false;
|
||||
|
||||
if (unlikely (!seen_edges.set (key, true)))
|
||||
return fail ();
|
||||
|
||||
auto &gdr = data.glyph_dependencies[target];
|
||||
if (unlikely (!gdr.dependencies.push_or_fail (table_tag, dependent, layout_tag,
|
||||
lig_set, context_set, flags)))
|
||||
return fail ();
|
||||
return true;
|
||||
return add_edge (target, hb_depend_edge_t (table_tag, dependent, layout_tag,
|
||||
lig_set, context_set, flags));
|
||||
}
|
||||
|
||||
bool add_gsub_lookup (hb_codepoint_t target, hb_codepoint_t lookup_index,
|
||||
@@ -492,13 +566,68 @@ struct hb_depend_data_builder_t
|
||||
hb_subset_depend_edge_flags_t flags = current_edge_flags;
|
||||
|
||||
bool any_added = false;
|
||||
for (auto t : lookup_features[lookup_index]) {
|
||||
for (uint64_t entry : get_lookup_features (lookup_index)) {
|
||||
hb_tag_t t = (hb_tag_t) entry;
|
||||
if (add_depend_layout (target, HB_OT_TAG_GSUB, t, dependent, lig_set, context_set, flags))
|
||||
any_added = true;
|
||||
}
|
||||
return any_added;
|
||||
}
|
||||
|
||||
bool init_lookup_features (unsigned lookup_count)
|
||||
{
|
||||
return check_success (lookup_feature_offsets.resize (lookup_count + 1));
|
||||
}
|
||||
|
||||
bool add_lookup_feature (hb_codepoint_t lookup_index, hb_tag_t feature_tag)
|
||||
{
|
||||
if (feature_tag == HB_SET_VALUE_INVALID)
|
||||
return true;
|
||||
|
||||
if (unlikely (!lookup_feature_offsets.length ||
|
||||
lookup_index >= lookup_feature_offsets.length - 1))
|
||||
return fail ();
|
||||
|
||||
uint64_t entry = ((uint64_t) lookup_index << 32) | feature_tag;
|
||||
return check_success (lookup_features.push_or_fail (entry));
|
||||
}
|
||||
|
||||
bool finish_lookup_features ()
|
||||
{
|
||||
lookup_features.qsort ([] (uint64_t a, uint64_t b) {
|
||||
return a < b ? -1 : a > b ? 1 : 0;
|
||||
});
|
||||
|
||||
unsigned write = 0;
|
||||
for (uint64_t entry : lookup_features)
|
||||
if (!write || entry != lookup_features[write - 1])
|
||||
lookup_features[write++] = entry;
|
||||
lookup_features.shrink (write, false);
|
||||
|
||||
unsigned feature_index = 0;
|
||||
unsigned lookup_count = lookup_feature_offsets.length - 1;
|
||||
for (unsigned lookup_index = 0; lookup_index < lookup_count; lookup_index++)
|
||||
{
|
||||
lookup_feature_offsets[lookup_index] = feature_index;
|
||||
while (feature_index < lookup_features.length &&
|
||||
lookup_features[feature_index] >> 32 == lookup_index)
|
||||
feature_index++;
|
||||
}
|
||||
lookup_feature_offsets[lookup_count] = feature_index;
|
||||
return true;
|
||||
}
|
||||
|
||||
hb_array_t<const uint64_t> get_lookup_features (hb_codepoint_t lookup_index) const
|
||||
{
|
||||
if (unlikely (!lookup_feature_offsets.length ||
|
||||
lookup_index >= lookup_feature_offsets.length - 1))
|
||||
return {};
|
||||
|
||||
unsigned start = lookup_feature_offsets[lookup_index];
|
||||
unsigned end = lookup_feature_offsets[lookup_index + 1];
|
||||
return lookup_features.as_array ().sub_array (start, end - start);
|
||||
}
|
||||
|
||||
void add_depend (hb_codepoint_t target, hb_tag_t table_tag,
|
||||
hb_codepoint_t dependent,
|
||||
hb_codepoint_t lig_set = HB_CODEPOINT_INVALID,
|
||||
@@ -523,8 +652,10 @@ struct hb_depend_data_builder_t
|
||||
bool successful = true;
|
||||
hb_set_t unicodes;
|
||||
hb_map_t nominal_glyphs;
|
||||
hb_vector_t<hb_set_t> lookup_features;
|
||||
hb_hashmap_t<hb_depend_edge_key_t, bool> seen_edges;
|
||||
hb_vector_t<uint64_t> lookup_features;
|
||||
hb_vector_t<unsigned> lookup_feature_offsets;
|
||||
hb_vector_t<uint64_t> edge_slots;
|
||||
unsigned int edge_population = 0;
|
||||
hb_hashmap_t<const hb_set_t*, hb_codepoint_t> set_to_index;
|
||||
hb_vector_t<hb_codepoint_t> free_set_list;
|
||||
hb_codepoint_t current_context_set_index;
|
||||
|
||||
@@ -58,15 +58,22 @@ template <typename context_t>
|
||||
return l.dispatch (c);
|
||||
}
|
||||
|
||||
/*static*/ hb_depend_context_t::return_t SubstLookup::depend_glyphs_recurse_func (hb_depend_context_t *c, unsigned lookup_index, hb_set_t *covered_seq_indices, unsigned seq_index, unsigned end_index)
|
||||
/*static*/ hb_depend_context_t::return_t SubstLookup::depend_glyphs_recurse_func (hb_depend_context_t *c, unsigned lookup_index, hb_bit_page_t *covered_seq_indices, unsigned seq_index, unsigned end_index)
|
||||
{
|
||||
const SubstLookup &l = c->face->table.GSUB.get_relaxed ()->table->get_lookup (lookup_index);
|
||||
/* After a non-1-to-1 lookup (expansion/contraction), subsequent lookups in the same
|
||||
* contextual rule see all glyphs, not position-specific ones. This matches closure behavior.
|
||||
* Mark sequence positions as covered so later lookups use the full glyph set. */
|
||||
if (l.may_have_non_1to1 ())
|
||||
hb_set_add_range (covered_seq_indices, seq_index, end_index);
|
||||
return l.dispatch (c);
|
||||
covered_seq_indices->add_range (seq_index, end_index);
|
||||
|
||||
hb_depend_context_t::recurse_key_t key;
|
||||
if (!c->get_recurse_key (lookup_index, &key))
|
||||
return hb_empty_t ();
|
||||
|
||||
hb_depend_context_t::return_t ret = l.dispatch (c);
|
||||
c->finish_recurse (key);
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <>
|
||||
@@ -121,7 +128,7 @@ GSUB_accelerator_t::depend (hb_depend_data_builder_t *builder, hb_face_t *face)
|
||||
return;
|
||||
this->table->get_feature_tags (0, &num_features, feature_tags.arrayZ);
|
||||
|
||||
if (!builder->check_success (builder->lookup_features.resize (num_lookups)))
|
||||
if (!builder->init_lookup_features (num_lookups))
|
||||
return;
|
||||
|
||||
hb_vector_t<hb_tag_t> feature_query_v;
|
||||
@@ -144,7 +151,8 @@ GSUB_accelerator_t::depend (hb_depend_data_builder_t *builder, hb_face_t *face)
|
||||
this->table->get_feature (feature_index).add_lookup_indexes_to (&lookup_indexes);
|
||||
|
||||
for (auto lookup_index : lookup_indexes)
|
||||
builder->lookup_features[lookup_index].add (ft);
|
||||
if (unlikely (!builder->add_lookup_feature (lookup_index, ft)))
|
||||
return;
|
||||
|
||||
auto &fv = this->table->get_feature_variations ();
|
||||
auto fi_count = fv.record_count ();
|
||||
@@ -158,29 +166,32 @@ GSUB_accelerator_t::depend (hb_depend_data_builder_t *builder, hb_face_t *face)
|
||||
feature_ptr->add_lookup_indexes_to (&lookup_indexes);
|
||||
}
|
||||
for (auto lookup_index : lookup_indexes)
|
||||
if (!builder->lookup_features[lookup_index].has (ft))
|
||||
builder->lookup_features[lookup_index].add (ft);
|
||||
if (unlikely (!builder->add_lookup_feature (lookup_index, ft)))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (unlikely (!builder->finish_lookup_features ()))
|
||||
return;
|
||||
|
||||
hb_set_t all_glyphs;
|
||||
all_glyphs.add_range (0, face->get_num_glyphs () - 1);
|
||||
|
||||
hb_depend_context_t c (builder, face, &all_glyphs);
|
||||
|
||||
int i = -1;
|
||||
for (auto &feature_set : builder->lookup_features)
|
||||
for (unsigned i = 0; i < num_lookups; i++)
|
||||
{
|
||||
i++;
|
||||
if (feature_set.is_empty ())
|
||||
auto features = builder->get_lookup_features (i);
|
||||
if (!features)
|
||||
{
|
||||
DEBUG_MSG_LEVEL (DEPEND, nullptr, 1, 0,
|
||||
"Skipping lookup %d (no features)", i);
|
||||
"Skipping lookup %u (no features)", i);
|
||||
continue;
|
||||
}
|
||||
DEBUG_MSG_LEVEL (DEPEND, nullptr, 1, 0,
|
||||
"Processing lookup %d with features:", i);
|
||||
"Processing lookup %u with features:", i);
|
||||
c.lookup_index = i;
|
||||
c.reset_recurse_cache ();
|
||||
c.lookups_seen.clear ();
|
||||
c.lookups_seen.add (i); /* Seed for A→B→A cycle detection in recurse(). */
|
||||
this->table->get_lookup (i).depend (&c);
|
||||
|
||||
+752
-270
File diff suppressed because it is too large.
Load diff
@@ -357,6 +357,24 @@ hb_set_is_equal (const hb_set_t *set,
|
||||
return set->is_equal (*other);
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_set_intersects:
|
||||
* @set: A set
|
||||
* @other: Another set
|
||||
*
|
||||
* Tests whether @set and @other have any elements in common.
|
||||
*
|
||||
* Return value: `true` if the two sets intersect, `false` otherwise.
|
||||
*
|
||||
* XSince: REPLACEME
|
||||
**/
|
||||
hb_bool_t
|
||||
hb_set_intersects (const hb_set_t *set,
|
||||
const hb_set_t *other)
|
||||
{
|
||||
return set->intersects (*other);
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_set_hash:
|
||||
* @set: A set
|
||||
|
||||
@@ -131,6 +131,10 @@ HB_EXTERN hb_bool_t
|
||||
hb_set_is_equal (const hb_set_t *set,
|
||||
const hb_set_t *other);
|
||||
|
||||
HB_EXTERN hb_bool_t
|
||||
hb_set_intersects (const hb_set_t *set,
|
||||
const hb_set_t *other);
|
||||
|
||||
HB_EXTERN unsigned int
|
||||
hb_set_hash (const hb_set_t *set);
|
||||
|
||||
|
||||
+10
-1
@@ -87,6 +87,7 @@ struct hb_sparseset_t
|
||||
uint32_t hash () const { return s.hash (); }
|
||||
|
||||
void add (hb_codepoint_t g) { s.add (g); }
|
||||
void add_bits (hb_codepoint_t g, uint64_t bits) { s.add_bits (g, bits); }
|
||||
bool add_range (hb_codepoint_t first, hb_codepoint_t last) { return s.add_range (first, last); }
|
||||
|
||||
template <typename T>
|
||||
@@ -125,6 +126,9 @@ struct hb_sparseset_t
|
||||
bool may_intersect (const hb_sparseset_t &other) const
|
||||
{ return s.may_intersect (other.s); }
|
||||
|
||||
bool intersects (const hb_sparseset_t &other) const
|
||||
{ return s.intersects (other.s); }
|
||||
|
||||
bool intersects (hb_codepoint_t first, hb_codepoint_t last) const
|
||||
{ return s.intersects (first, last); }
|
||||
|
||||
@@ -137,11 +141,15 @@ struct hb_sparseset_t
|
||||
bool is_subset (const hb_sparseset_t &larger_set) const { return s.is_subset (larger_set.s); }
|
||||
|
||||
void union_ (const hb_sparseset_t &other) { s.union_ (other.s); }
|
||||
void intersect (const hb_sparseset_t &other) { s.intersect (other.s); }
|
||||
void intersect (const hb_sparseset_t &other,
|
||||
hb_vector_t<unsigned> *workspace = nullptr)
|
||||
{ s.intersect (other.s, workspace); }
|
||||
void subtract (const hb_sparseset_t &other) { s.subtract (other.s); }
|
||||
void symmetric_difference (const hb_sparseset_t &other) { s.symmetric_difference (other.s); }
|
||||
|
||||
bool next (hb_codepoint_t *codepoint) const { return s.next (codepoint); }
|
||||
bool next_bits (hb_codepoint_t *codepoint, uint64_t *bits) const
|
||||
{ return s.next_bits (codepoint, bits); }
|
||||
bool previous (hb_codepoint_t *codepoint) const { return s.previous (codepoint); }
|
||||
bool next_range (hb_codepoint_t *first, hb_codepoint_t *last) const
|
||||
{ return s.next_range (first, last); }
|
||||
@@ -151,6 +159,7 @@ struct hb_sparseset_t
|
||||
{ return s.next_many (codepoint, out, size); }
|
||||
|
||||
unsigned int get_population () const { return s.get_population (); }
|
||||
bool get_singleton (hb_codepoint_t *codepoint) const { return s.get_singleton (codepoint); }
|
||||
hb_codepoint_t get_min () const { return s.get_min (); }
|
||||
hb_codepoint_t get_max () const { return s.get_max (); }
|
||||
|
||||
|
||||
@@ -806,9 +806,8 @@ _format_tag (hb_tag_t tag, hb_vector_t<char> &out)
|
||||
static void
|
||||
_format_tag_set (const hb_set_t *set, hb_vector_t<char> &out)
|
||||
{
|
||||
hb_codepoint_t tag = HB_SET_VALUE_INVALID;
|
||||
bool first_tag = true;
|
||||
while (hb_set_next (set, &tag))
|
||||
for (hb_codepoint_t tag : *set)
|
||||
{
|
||||
if (!first_tag)
|
||||
out.push (',');
|
||||
@@ -916,9 +915,8 @@ _format_glyph_map_arg (const hb_map_t &glyph_map,
|
||||
hb_set_t keys;
|
||||
hb_map_keys (&glyph_map, &keys);
|
||||
hb_vector_t<char> pairs;
|
||||
hb_codepoint_t key = HB_SET_VALUE_INVALID;
|
||||
bool first = true;
|
||||
while (hb_set_next (&keys, &key))
|
||||
for (hb_codepoint_t key : keys)
|
||||
{
|
||||
if (!first)
|
||||
pairs.push (',');
|
||||
|
||||
+120
@@ -137,6 +137,61 @@ main (int argc, char **argv)
|
||||
hb_always_assert (s.has (HB_SET_VALUE_INVALID));
|
||||
}
|
||||
|
||||
/* Test set intersection. */
|
||||
{
|
||||
hb_set_t a {1, 2};
|
||||
hb_set_t b {2, 3};
|
||||
hb_set_t c {3, 4};
|
||||
|
||||
hb_always_assert (a.intersects (b));
|
||||
hb_always_assert (!a.intersects (c));
|
||||
|
||||
b.invert ();
|
||||
hb_always_assert (a.intersects (b));
|
||||
hb_always_assert (b.intersects (a));
|
||||
|
||||
hb_set_t singleton {2};
|
||||
hb_always_assert (!singleton.intersects (b));
|
||||
hb_always_assert (!b.intersects (singleton));
|
||||
|
||||
c.invert ();
|
||||
hb_always_assert (b.intersects (c));
|
||||
}
|
||||
|
||||
/* Test singleton detection. */
|
||||
{
|
||||
hb_set_t s;
|
||||
hb_codepoint_t singleton;
|
||||
hb_always_assert (!s.get_singleton (&singleton));
|
||||
|
||||
s.add (63);
|
||||
hb_always_assert (s.get_singleton (&singleton));
|
||||
hb_always_assert (singleton == 63);
|
||||
|
||||
s.add (1024);
|
||||
hb_always_assert (!s.get_singleton (&singleton));
|
||||
s.del (63);
|
||||
hb_always_assert (s.get_singleton (&singleton));
|
||||
hb_always_assert (singleton == 1024);
|
||||
|
||||
s.invert ();
|
||||
hb_always_assert (!s.get_singleton (&singleton));
|
||||
}
|
||||
|
||||
/* Test word-at-a-time insertion. */
|
||||
{
|
||||
hb_set_t s;
|
||||
s.add_bits (64, uint64_t (1) | (uint64_t (1) << 63));
|
||||
hb_always_assert (s.get_population () == 2);
|
||||
hb_always_assert (s.has (64));
|
||||
hb_always_assert (s.has (127));
|
||||
|
||||
s.invert ();
|
||||
s.add_bits (64, uint64_t (1) | (uint64_t (1) << 63));
|
||||
hb_always_assert (s.has (64));
|
||||
hb_always_assert (s.has (127));
|
||||
}
|
||||
|
||||
/* Adding HB_SET_VALUE_INVALID */
|
||||
{
|
||||
hb_set_t s;
|
||||
@@ -161,5 +216,70 @@ main (int argc, char **argv)
|
||||
hb_always_assert(s.has(2));
|
||||
}
|
||||
|
||||
/* Test iteration across words and pages. */
|
||||
{
|
||||
hb_set_t s {0, 1, 63, 64, 65, 127, 511, 512, 513, 1024,
|
||||
HB_SET_VALUE_INVALID - 1};
|
||||
hb_codepoint_t expected[] = {0, 1, 63, 64, 65, 127, 511, 512, 513,
|
||||
1024, HB_SET_VALUE_INVALID - 1};
|
||||
unsigned int i = 0;
|
||||
for (hb_codepoint_t v : s)
|
||||
{
|
||||
hb_always_assert (i < ARRAY_LENGTH (expected));
|
||||
hb_always_assert (v == expected[i++]);
|
||||
}
|
||||
hb_always_assert (i == ARRAY_LENGTH (expected));
|
||||
|
||||
auto it = s.iter ();
|
||||
hb_always_assert (*it == 0);
|
||||
hb_always_assert (it.len () == ARRAY_LENGTH (expected));
|
||||
++it;
|
||||
hb_always_assert (*it == 1);
|
||||
hb_always_assert (it.len () == ARRAY_LENGTH (expected) - 1);
|
||||
--it;
|
||||
hb_always_assert (*it == 0);
|
||||
++it;
|
||||
hb_always_assert (*it == 1);
|
||||
it += 3;
|
||||
hb_always_assert (*it == 65);
|
||||
--it;
|
||||
hb_always_assert (*it == 64);
|
||||
--it;
|
||||
hb_always_assert (*it == 63);
|
||||
++it;
|
||||
hb_always_assert (*it == 64);
|
||||
|
||||
it = it.end ();
|
||||
--it;
|
||||
hb_always_assert (*it == HB_SET_VALUE_INVALID - 1);
|
||||
--it;
|
||||
hb_always_assert (*it == 1024);
|
||||
++it;
|
||||
hb_always_assert (*it == HB_SET_VALUE_INVALID - 1);
|
||||
|
||||
it = s.iter ();
|
||||
it += 2;
|
||||
hb_always_assert (it.len () == ARRAY_LENGTH (expected) - 2);
|
||||
}
|
||||
|
||||
/* Test inverted-set iteration. */
|
||||
{
|
||||
hb_set_t s {0, 1, 63, 64};
|
||||
s.invert ();
|
||||
auto it = s.iter ();
|
||||
hb_always_assert (*it == 2);
|
||||
hb_always_assert (it.len () == HB_SET_VALUE_INVALID - 4);
|
||||
++it;
|
||||
hb_always_assert (*it == 3);
|
||||
--it;
|
||||
hb_always_assert (*it == 2);
|
||||
|
||||
it = it.end ();
|
||||
--it;
|
||||
hb_always_assert (*it == HB_SET_VALUE_INVALID - 1);
|
||||
--it;
|
||||
hb_always_assert (*it == HB_SET_VALUE_INVALID - 2);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1024,6 +1024,41 @@ test_set_inverted_equality (void)
|
||||
hb_set_destroy (b);
|
||||
}
|
||||
|
||||
static void
|
||||
test_set_intersects (void)
|
||||
{
|
||||
hb_set_t *a = hb_set_create ();
|
||||
hb_set_t *b = hb_set_create ();
|
||||
hb_set_t *c = hb_set_create ();
|
||||
|
||||
hb_set_add (a, 1);
|
||||
hb_set_add (a, 2);
|
||||
hb_set_add (b, 2);
|
||||
hb_set_add (b, 3);
|
||||
hb_set_add (c, 3);
|
||||
hb_set_add (c, 4);
|
||||
|
||||
g_assert_true (hb_set_intersects (a, b));
|
||||
g_assert_true (hb_set_intersects (b, a));
|
||||
g_assert_true (!hb_set_intersects (a, c));
|
||||
|
||||
hb_set_invert (b);
|
||||
g_assert_true (hb_set_intersects (a, b));
|
||||
g_assert_true (hb_set_intersects (b, a));
|
||||
|
||||
hb_set_clear (a);
|
||||
hb_set_add (a, 2);
|
||||
g_assert_true (!hb_set_intersects (a, b));
|
||||
g_assert_true (!hb_set_intersects (b, a));
|
||||
|
||||
hb_set_invert (c);
|
||||
g_assert_true (hb_set_intersects (b, c));
|
||||
|
||||
hb_set_destroy (a);
|
||||
hb_set_destroy (b);
|
||||
hb_set_destroy (c);
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
UNION = 0,
|
||||
INTERSECT,
|
||||
@@ -1300,6 +1335,7 @@ main (int argc, char **argv)
|
||||
hb_test_add (test_set_inverted_iteration_next);
|
||||
hb_test_add (test_set_inverted_iteration_prev);
|
||||
hb_test_add (test_set_inverted_equality);
|
||||
hb_test_add (test_set_intersects);
|
||||
hb_test_add (test_set_inverted_operations);
|
||||
|
||||
hb_test_add (test_hb_set_add_sorted_array);
|
||||
|
||||
@@ -126,10 +126,11 @@ subset_fonts_glob = run_command(glob_cmd, meson.current_source_dir() / '..' / 's
|
||||
graphs_glob = run_command(glob_cmd, meson.current_source_dir() / 'graphs', check:true).stdout().strip().split('\n')
|
||||
|
||||
depend_closure_parity_fonts_glob = []
|
||||
depend_closure_parity_noto_nastaliq_fonts = []
|
||||
foreach font : subset_fonts_glob
|
||||
# These fonts currently spend tens of seconds or more building the
|
||||
# contextual GSUB dependency graph before the parity tests start.
|
||||
if not font.contains('NotoNastaliqUrdu-Bold.ttf') and not font.contains('NotoNastaliqUrdu-Regular.ttf')
|
||||
if font.contains('NotoNastaliqUrdu-Bold.ttf') or font.contains('NotoNastaliqUrdu-Regular.ttf')
|
||||
depend_closure_parity_noto_nastaliq_fonts += [font]
|
||||
else
|
||||
depend_closure_parity_fonts_glob += [font]
|
||||
endif
|
||||
endforeach
|
||||
@@ -250,6 +251,20 @@ if conf.get('HB_EXPERIMENTAL_API', 0) == 1
|
||||
)
|
||||
i += 1
|
||||
endforeach
|
||||
|
||||
foreach font : depend_closure_parity_noto_nastaliq_fonts
|
||||
font_name = 'regular'
|
||||
if font.contains('NotoNastaliqUrdu-Bold.ttf')
|
||||
font_name = 'bold'
|
||||
endif
|
||||
test('depend-closure-parity-noto-nastaliq-@0@'.format(font_name),
|
||||
hb_depend_closure_parity_exe,
|
||||
args: ['-s', '42', '-n', '16', font],
|
||||
workdir: meson.current_build_dir() / '..' / '..',
|
||||
protocol: 'tap',
|
||||
suite: ['fuzzing'],
|
||||
)
|
||||
endforeach
|
||||
endif
|
||||
|
||||
i = 0
|
||||
|
||||
@@ -38,6 +38,8 @@ struct depend_t : option_parser_t, face_options_t
|
||||
gboolean flagged_only = false;
|
||||
gboolean no_context = false;
|
||||
gboolean no_glyph_names = false;
|
||||
gboolean compile_only = false;
|
||||
gboolean quiet = false;
|
||||
char *gids_str = nullptr;
|
||||
|
||||
void
|
||||
@@ -60,6 +62,10 @@ struct depend_t : option_parser_t, face_options_t
|
||||
"Suppress context set output", nullptr},
|
||||
{"no-glyph-names", 0, 0, G_OPTION_ARG_NONE, &this->no_glyph_names,
|
||||
"Use numeric glyph IDs instead of names", nullptr},
|
||||
{"compile", 0, 0, G_OPTION_ARG_NONE, &this->compile_only,
|
||||
"Build the dependency graph without retrieving it", nullptr},
|
||||
{"quiet", 'q', 0, G_OPTION_ARG_NONE, &this->quiet,
|
||||
"Retrieve the dependency graph without printing it", nullptr},
|
||||
{nullptr}
|
||||
};
|
||||
add_group (depend_entries,
|
||||
@@ -209,7 +215,13 @@ struct depend_t : option_parser_t, face_options_t
|
||||
return 1;
|
||||
}
|
||||
|
||||
hb_font_t *font = no_glyph_names ? nullptr : hb_font_create (face);
|
||||
if (compile_only)
|
||||
{
|
||||
hb_subset_depend_destroy (depend);
|
||||
return 0;
|
||||
}
|
||||
|
||||
hb_font_t *font = no_glyph_names || quiet ? nullptr : hb_font_create (face);
|
||||
|
||||
std::set<unsigned> gid_filter;
|
||||
bool filter_gids = gids_str != nullptr;
|
||||
@@ -240,7 +252,7 @@ struct depend_t : option_parser_t, face_options_t
|
||||
entries.push_back (entry);
|
||||
}
|
||||
|
||||
if (entries.empty ()) continue;
|
||||
if (entries.empty () || quiet) continue;
|
||||
|
||||
if (printed_any) printf ("\n");
|
||||
printed_any = true;
|
||||
|
||||
Reference in new issue
Block a user