Skip to content

Commit

Permalink
Merge pull request #81327 from bruvzg/hb811
Browse files Browse the repository at this point in the history
HarfBuzz: Update to version 8.1.1
  • Loading branch information
YuriSizov committed Sep 5, 2023
2 parents 14cfed5 + afbba19 commit 59d3a36
Show file tree
Hide file tree
Showing 59 changed files with 2,063 additions and 1,427 deletions.
2 changes: 1 addition & 1 deletion thirdparty/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ Files extracted from upstream source:
## harfbuzz

- Upstream: https://github.com/harfbuzz/harfbuzz
- Version: 8.0.0 (b4305532a7746422e0b615eee6304119c1092fd8, 2023)
- Version: 8.1.1 (1d665c2b521512cdd56964138fc601debd1f1177, 2023)
- License: MIT

Files extracted from upstream source:
Expand Down
33 changes: 33 additions & 0 deletions thirdparty/harfbuzz/src/OT/Layout/GDEF/GDEF.hh
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,16 @@ struct MarkGlyphSetsFormat1
bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const
{ return (this+coverage[set_index]).get_coverage (glyph_id) != NOT_COVERED; }

template <typename set_t>
void collect_coverage (hb_vector_t<set_t> &sets) const
{
for (const auto &offset : coverage)
{
const auto &cov = this+offset;
cov.collect_coverage (sets.push ());
}
}

bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
Expand Down Expand Up @@ -492,6 +502,15 @@ struct MarkGlyphSets
}
}

template <typename set_t>
void collect_coverage (hb_vector_t<set_t> &sets) const
{
switch (u.format) {
case 1: u.format1.collect_coverage (sets); return;
default:return;
}
}

bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
Expand Down Expand Up @@ -856,6 +875,10 @@ struct GDEF
hb_blob_destroy (table.get_blob ());
table = hb_blob_get_empty ();
}

#ifndef HB_NO_GDEF_CACHE
table->get_mark_glyph_sets ().collect_coverage (mark_glyph_set_digests);
#endif
}
~accelerator_t () { table.destroy (); }

Expand All @@ -879,8 +902,18 @@ struct GDEF

}

bool mark_set_covers (unsigned int set_index, hb_codepoint_t glyph_id) const
{
return
#ifndef HB_NO_GDEF_CACHE
mark_glyph_set_digests[set_index].may_have (glyph_id) &&
#endif
table->mark_set_covers (set_index, glyph_id);
}

hb_blob_ptr_t<GDEF> table;
#ifndef HB_NO_GDEF_CACHE
hb_vector_t<hb_set_digest_t> mark_glyph_set_digests;
mutable hb_cache_t<21, 3, 8> glyph_props_cache;
#endif
};
Expand Down
20 changes: 14 additions & 6 deletions thirdparty/harfbuzz/src/OT/Layout/GPOS/CursivePosFormat1.hh
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,13 @@ struct CursivePosFormat1
bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
return_trace (coverage.sanitize (c, this) && entryExitRecord.sanitize (c, this));
if (unlikely (!coverage.sanitize (c, this)))
return_trace (false);

if (c->lazy_some_gpos)
return_trace (entryExitRecord.sanitize_shallow (c));
else
return_trace (entryExitRecord.sanitize (c, this));
}

bool intersects (const hb_set_t *glyphs) const
Expand Down Expand Up @@ -119,10 +125,11 @@ struct CursivePosFormat1
hb_buffer_t *buffer = c->buffer;

const EntryExitRecord &this_record = entryExitRecord[(this+coverage).get_coverage (buffer->cur().codepoint)];
if (!this_record.entryAnchor) return_trace (false);
if (!this_record.entryAnchor ||
unlikely (!this_record.entryAnchor.sanitize (&c->sanitizer, this))) return_trace (false);

hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
skippy_iter.reset_fast (buffer->idx, 1);
skippy_iter.reset_fast (buffer->idx);
unsigned unsafe_from;
if (unlikely (!skippy_iter.prev (&unsafe_from)))
{
Expand All @@ -131,7 +138,8 @@ struct CursivePosFormat1
}

const EntryExitRecord &prev_record = entryExitRecord[(this+coverage).get_coverage (buffer->info[skippy_iter.idx].codepoint)];
if (!prev_record.exitAnchor)
if (!prev_record.exitAnchor ||
unlikely (!prev_record.exitAnchor.sanitize (&c->sanitizer, this)))
{
buffer->unsafe_to_concat_from_outbuffer (skippy_iter.idx, buffer->idx + 1);
return_trace (false);
Expand Down Expand Up @@ -200,8 +208,8 @@ struct CursivePosFormat1
* Arabic. */
unsigned int child = i;
unsigned int parent = j;
hb_position_t x_offset = entry_x - exit_x;
hb_position_t y_offset = entry_y - exit_y;
hb_position_t x_offset = roundf (entry_x - exit_x);
hb_position_t y_offset = roundf (entry_y - exit_y);
if (!(c->lookup_props & LookupFlag::RightToLeft))
{
unsigned int k = child;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ struct MarkMarkPosFormat1_2

/* now we search backwards for a suitable mark glyph until a non-mark glyph */
hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
skippy_iter.reset_fast (buffer->idx, 1);
skippy_iter.reset_fast (buffer->idx);
skippy_iter.set_lookup_props (c->lookup_props & ~(uint32_t)LookupFlag::IgnoreFlags);
unsigned unsafe_from;
if (unlikely (!skippy_iter.prev (&unsafe_from)))
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/harfbuzz/src/OT/Layout/GPOS/PairPosFormat1.hh
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ struct PairPosFormat1_3
if (likely (index == NOT_COVERED)) return_trace (false);

hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
skippy_iter.reset_fast (buffer->idx, 1);
skippy_iter.reset_fast (buffer->idx);
unsigned unsafe_to;
if (unlikely (!skippy_iter.next (&unsafe_to)))
{
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/harfbuzz/src/OT/Layout/GPOS/PairPosFormat2.hh
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ struct PairPosFormat2_4
if (likely (index == NOT_COVERED)) return_trace (false);

hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
skippy_iter.reset_fast (buffer->idx, 1);
skippy_iter.reset_fast (buffer->idx);
unsigned unsafe_to;
if (unlikely (!skippy_iter.next (&unsafe_to)))
{
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/harfbuzz/src/OT/Layout/GPOS/PairValueRecord.hh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct PairValueRecord
ValueRecord values; /* Positioning data for the first glyph
* followed by for second glyph */
public:
DEFINE_SIZE_ARRAY (Types::size, values);
DEFINE_SIZE_ARRAY (Types::HBGlyphID::static_size, values);

int cmp (hb_codepoint_t k) const
{ return secondGlyph.cmp (k); }
Expand Down
1 change: 0 additions & 1 deletion thirdparty/harfbuzz/src/OT/Layout/GSUB/Ligature.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ struct Ligature
* in writing direction */
public:
DEFINE_SIZE_ARRAY (Types::size + 2, component);
DEFINE_SIZE_MAX (65536 * Types::HBGlyphID::static_size);

bool sanitize (hb_sanitize_context_t *c) const
{
Expand Down
19 changes: 9 additions & 10 deletions thirdparty/harfbuzz/src/OT/Layout/GSUB/LigatureSet.hh
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,14 @@ struct LigatureSet
;
}

static bool match_always (hb_glyph_info_t &info HB_UNUSED, unsigned value HB_UNUSED, const void *data HB_UNUSED)
{
return true;
}

bool apply (hb_ot_apply_context_t *c) const
{
TRACE_APPLY (this);

unsigned int num_ligs = ligature.len;

#ifndef HB_NO_OT_LIGATURES_FAST_PATH
if (HB_OPTIMIZE_SIZE_VAL || num_ligs <= 2)
#ifndef HB_NO_OT_RULESETS_FAST_PATH
if (HB_OPTIMIZE_SIZE_VAL || num_ligs <= 4)
#endif
{
slow:
Expand All @@ -97,10 +92,12 @@ struct LigatureSet
}

/* This version is optimized for speed by matching the first component
* of the ligature here, instead of calling into the ligation code. */
* of the ligature here, instead of calling into the ligation code.
*
* This is replicated in ChainRuleSet and RuleSet. */

hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
skippy_iter.reset (c->buffer->idx, 1);
skippy_iter.reset (c->buffer->idx);
skippy_iter.set_match_func (match_always, nullptr);
skippy_iter.set_glyph_data ((HBUINT16 *) nullptr);
unsigned unsafe_to;
Expand All @@ -118,14 +115,16 @@ struct LigatureSet
goto slow;
}
}
else
goto slow;

bool unsafe_to_concat = false;

for (unsigned int i = 0; i < num_ligs; i++)
{
const auto &lig = this+ligature.arrayZ[i];
if (unlikely (lig.component.lenP1 <= 1) ||
lig.component[1] == first)
lig.component.arrayZ[0] == first)
{
if (lig.apply (c))
{
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/harfbuzz/src/graph/classdef-graph.hh
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct ClassDef : public OT::ClassDef
class_def_link->width = SmallTypes::size;
class_def_link->objidx = class_def_prime_id;
class_def_link->position = link_position;
class_def_prime_vertex.parents.push (parent_id);
class_def_prime_vertex.add_parent (parent_id);

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/harfbuzz/src/graph/coverage-graph.hh
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ struct Coverage : public OT::Layout::Common::Coverage
coverage_link->width = SmallTypes::size;
coverage_link->objidx = coverage_prime_id;
coverage_link->position = link_position;
coverage_prime_vertex.parents.push (parent_id);
coverage_prime_vertex.add_parent (parent_id);

return (Coverage*) coverage_prime_vertex.obj.head;
}
Expand Down
Loading

0 comments on commit 59d3a36

Please sign in to comment.