Skip to content

Commit

Permalink
Merge pull request #79260 from bruvzg/hb800
Browse files Browse the repository at this point in the history
HarfBuzz: Update to version 8.0.0
  • Loading branch information
YuriSizov committed Jul 12, 2023
2 parents 1da09fd + ad83a31 commit da88468
Show file tree
Hide file tree
Showing 133 changed files with 4,100 additions and 1,766 deletions.
4 changes: 2 additions & 2 deletions thirdparty/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,15 @@ Files extracted from upstream source:
## harfbuzz

- Upstream: https://github.com/harfbuzz/harfbuzz
- Version: 7.3.0 (4584bcdc326564829d3cee3572386c90e4fd1974, 2023)
- Version: 8.0.0 (b4305532a7746422e0b615eee6304119c1092fd8, 2023)
- License: MIT

Files extracted from upstream source:

- `AUTHORS`, `COPYING`, `THANKS`
- from the `src` folder, recursively
- all the `*.c`, `*.cc`, `*.h`, `*.hh` files
- _except_ `main.cc`, `harfbuzz*.cc`, `failing-alloc.c`, `test*.cc`
- _except_ `main.cc`, `harfbuzz*.cc`, `failing-alloc.c`, `test*.cc`, `hb-wasm*.*`


## icu4c
Expand Down
11 changes: 3 additions & 8 deletions thirdparty/harfbuzz/src/OT/Color/CBDT/CBDT.hh
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,6 @@ struct IndexSubtableRecord
TRACE_SERIALIZE (this);

auto *subtable = c->serializer->start_embed<IndexSubtable> ();
if (unlikely (!subtable)) return_trace (false);
if (unlikely (!c->serializer->extend_min (subtable))) return_trace (false);

auto *old_subtable = get_subtable (base);
Expand Down Expand Up @@ -545,7 +544,8 @@ struct IndexSubtableArray
const IndexSubtableRecord*>> *lookup /* OUT */) const
{
bool start_glyph_is_set = false;
for (hb_codepoint_t new_gid = 0; new_gid < c->plan->num_output_glyphs (); new_gid++)
unsigned num_glyphs = c->plan->num_output_glyphs ();
for (hb_codepoint_t new_gid = 0; new_gid < num_glyphs; new_gid++)
{
hb_codepoint_t old_gid;
if (unlikely (!c->plan->old_gid_for_new_gid (new_gid, &old_gid))) continue;
Expand Down Expand Up @@ -576,9 +576,6 @@ struct IndexSubtableArray
{
TRACE_SUBSET (this);

auto *dst = c->serializer->start_embed<IndexSubtableArray> ();
if (unlikely (!dst)) return_trace (false);

hb_vector_t<hb_pair_t<hb_codepoint_t, const IndexSubtableRecord*>> lookup;
build_lookup (c, bitmap_size_context, &lookup);
if (unlikely (!c->serializer->propagate_error (lookup)))
Expand Down Expand Up @@ -993,12 +990,10 @@ CBLC::subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);

auto *cblc_prime = c->serializer->start_embed<CBLC> ();

// Use a vector as a secondary buffer as the tables need to be built in parallel.
hb_vector_t<char> cbdt_prime;

if (unlikely (!cblc_prime)) return_trace (false);
auto *cblc_prime = c->serializer->start_embed<CBLC> ();
if (unlikely (!c->serializer->extend_min (cblc_prime))) return_trace (false);
cblc_prime->version = version;

Expand Down
4 changes: 2 additions & 2 deletions thirdparty/harfbuzz/src/OT/Color/COLR/COLR.hh
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,6 @@ struct ColorLine
{
TRACE_SUBSET (this);
auto *out = c->serializer->start_embed (this);
if (unlikely (!out)) return_trace (false);
if (unlikely (!c->serializer->extend_min (out))) return_trace (false);

if (!c->serializer->check_assign (out->extend, extend, HB_SERIALIZE_ERROR_INT_OVERFLOW)) return_trace (false);
Expand Down Expand Up @@ -1434,6 +1433,7 @@ struct PaintComposite
{
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) &&
c->check_ops (this->min_size) && // PainComposite can get exponential
src.sanitize (c, this) &&
backdrop.sanitize (c, this));
}
Expand Down Expand Up @@ -2167,7 +2167,7 @@ struct COLR
if (version == 0 && (!base_it || !layer_it))
return_trace (false);

COLR *colr_prime = c->serializer->start_embed<COLR> ();
auto *colr_prime = c->serializer->start_embed<COLR> ();
if (unlikely (!c->serializer->extend_min (colr_prime))) return_trace (false);

if (version == 0)
Expand Down
5 changes: 0 additions & 5 deletions thirdparty/harfbuzz/src/OT/Color/sbix/sbix.hh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ struct SBIXGlyph
{
TRACE_SERIALIZE (this);
SBIXGlyph* new_glyph = c->start_embed<SBIXGlyph> ();
if (unlikely (!new_glyph)) return_trace (nullptr);
if (unlikely (!c->extend_min (new_glyph))) return_trace (nullptr);

new_glyph->xOffset = xOffset;
Expand Down Expand Up @@ -143,7 +142,6 @@ struct SBIXStrike
unsigned int num_output_glyphs = c->plan->num_output_glyphs ();

auto* out = c->serializer->start_embed<SBIXStrike> ();
if (unlikely (!out)) return_trace (false);
auto snap = c->serializer->snapshot ();
if (unlikely (!c->serializer->extend (out, num_output_glyphs + 1))) return_trace (false);
out->ppem = ppem;
Expand Down Expand Up @@ -388,7 +386,6 @@ struct sbix
TRACE_SERIALIZE (this);

auto *out = c->serializer->start_embed<Array32OfOffset32To<SBIXStrike>> ();
if (unlikely (!out)) return_trace (false);
if (unlikely (!c->serializer->extend_min (out))) return_trace (false);

hb_vector_t<Offset32To<SBIXStrike>*> new_strikes;
Expand Down Expand Up @@ -423,8 +420,6 @@ struct sbix
{
TRACE_SUBSET (this);

sbix *sbix_prime = c->serializer->start_embed<sbix> ();
if (unlikely (!sbix_prime)) return_trace (false);
if (unlikely (!c->serializer->embed (this->version))) return_trace (false);
if (unlikely (!c->serializer->embed (this->flags))) return_trace (false);

Expand Down
3 changes: 3 additions & 0 deletions thirdparty/harfbuzz/src/OT/Layout/Common/Coverage.hh
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ struct Coverage
public:
DEFINE_SIZE_UNION (2, format);

#ifndef HB_OPTIMIZE_SIZE
HB_ALWAYS_INLINE
#endif
bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ struct CoverageFormat1_3
{
if (glyphArray.len > glyphs->get_population () * hb_bit_storage ((unsigned) glyphArray.len) / 2)
{
for (hb_codepoint_t g = HB_SET_VALUE_INVALID; glyphs->next (&g);)
for (auto g : *glyphs)
if (get_coverage (g) != NOT_COVERED)
return true;
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ struct CoverageFormat2_4
{
if (rangeRecord.len > glyphs->get_population () * hb_bit_storage ((unsigned) rangeRecord.len) / 2)
{
for (hb_codepoint_t g = HB_SET_VALUE_INVALID; glyphs->next (&g);)
for (auto g : *glyphs)
if (get_coverage (g) != NOT_COVERED)
return true;
return false;
Expand Down
3 changes: 0 additions & 3 deletions thirdparty/harfbuzz/src/OT/Layout/GDEF/GDEF.hh
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ struct AttachPoint : Array16Of<HBUINT16>
{
TRACE_SUBSET (this);
auto *out = c->serializer->start_embed (*this);
if (unlikely (!out)) return_trace (false);

return_trace (out->serialize (c->serializer, + iter ()));
}
};
Expand Down Expand Up @@ -202,7 +200,6 @@ struct CaretValueFormat3
{
TRACE_SUBSET (this);
auto *out = c->serializer->start_embed (*this);
if (unlikely (!out)) return_trace (false);
if (!c->serializer->embed (caretValueFormat)) return_trace (false);
if (!c->serializer->embed (coordinate)) return_trace (false);

Expand Down
9 changes: 5 additions & 4 deletions thirdparty/harfbuzz/src/OT/Layout/GPOS/AnchorFormat3.hh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ struct AnchorFormat3
bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) && xDeviceTable.sanitize (c, this) && yDeviceTable.sanitize (c, this));
if (unlikely (!c->check_struct (this))) return_trace (false);

return_trace (xDeviceTable.sanitize (c, this) && yDeviceTable.sanitize (c, this));
}

void get_anchor (hb_ot_apply_context_t *c, hb_codepoint_t glyph_id HB_UNUSED,
Expand All @@ -35,17 +37,16 @@ struct AnchorFormat3
*x = font->em_fscale_x (xCoordinate);
*y = font->em_fscale_y (yCoordinate);

if (font->x_ppem || font->num_coords)
if ((font->x_ppem || font->num_coords) && xDeviceTable.sanitize (&c->sanitizer, this))
*x += (this+xDeviceTable).get_x_delta (font, c->var_store, c->var_store_cache);
if (font->y_ppem || font->num_coords)
if ((font->y_ppem || font->num_coords) && yDeviceTable.sanitize (&c->sanitizer, this))
*y += (this+yDeviceTable).get_y_delta (font, c->var_store, c->var_store_cache);
}

bool subset (hb_subset_context_t *c) const
{
TRACE_SUBSET (this);
auto *out = c->serializer->start_embed (*this);
if (unlikely (!out)) return_trace (false);
if (unlikely (!c->serializer->embed (format))) return_trace (false);
if (unlikely (!c->serializer->embed (xCoordinate))) return_trace (false);
if (unlikely (!c->serializer->embed (yCoordinate))) return_trace (false);
Expand Down
15 changes: 11 additions & 4 deletions thirdparty/harfbuzz/src/OT/Layout/GPOS/AnchorMatrix.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,25 @@ struct AnchorMatrix
if (unlikely (hb_unsigned_mul_overflows (rows, cols))) return_trace (false);
unsigned int count = rows * cols;
if (!c->check_array (matrixZ.arrayZ, count)) return_trace (false);

if (c->lazy_some_gpos)
return_trace (true);

for (unsigned int i = 0; i < count; i++)
if (!matrixZ[i].sanitize (c, this)) return_trace (false);
return_trace (true);
}

const Anchor& get_anchor (unsigned int row, unsigned int col,
unsigned int cols, bool *found) const
const Anchor& get_anchor (hb_ot_apply_context_t *c,
unsigned int row, unsigned int col,
unsigned int cols, bool *found) const
{
*found = false;
if (unlikely (row >= rows || col >= cols)) return Null (Anchor);
*found = !matrixZ[row * cols + col].is_null ();
return this+matrixZ[row * cols + col];
auto &offset = matrixZ[row * cols + col];
if (unlikely (!offset.sanitize (&c->sanitizer, this))) return Null (Anchor);
*found = !offset.is_null ();
return this+offset;
}

template <typename Iterator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ struct CursivePosFormat1
const hb_map_t &glyph_map = *c->plan->glyph_map;

auto *out = c->serializer->start_embed (*this);
if (unlikely (!out)) return_trace (false);

auto it =
+ hb_zip (this+coverage, entryExitRecord)
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/harfbuzz/src/OT/Layout/GPOS/MarkArray.hh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct MarkArray : Array16Of<MarkRecord> /* Array of MarkRecords--in Cove

const Anchor& mark_anchor = this + record.markAnchor;
bool found;
const Anchor& glyph_anchor = anchors.get_anchor (glyph_index, mark_class, class_count, &found);
const Anchor& glyph_anchor = anchors.get_anchor (c, glyph_index, mark_class, class_count, &found);
/* If this subtable doesn't have an anchor for this base and this class,
* return false such that the subsequent subtables have a chance at it. */
if (unlikely (!found)) return_trace (false);
Expand Down
11 changes: 7 additions & 4 deletions thirdparty/harfbuzz/src/OT/Layout/GPOS/PairPosFormat2.hh
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ struct PairPosFormat2_4
return_trace (c->check_range ((const void *) values,
count,
stride) &&
valueFormat1.sanitize_values_stride_unsafe (c, this, &values[0], count, stride) &&
valueFormat2.sanitize_values_stride_unsafe (c, this, &values[len1], count, stride));
(c->lazy_some_gpos ||
(valueFormat1.sanitize_values_stride_unsafe (c, this, &values[0], count, stride) &&
valueFormat2.sanitize_values_stride_unsafe (c, this, &values[len1], count, stride))));
}

bool intersects (const hb_set_t *glyphs) const
Expand Down Expand Up @@ -298,11 +299,13 @@ struct PairPosFormat2_4
out->valueFormat2 = out->valueFormat2.drop_device_table_flags ();
}

unsigned total_len = len1 + len2;
hb_vector_t<unsigned> class2_idxs (+ hb_range ((unsigned) class2Count) | hb_filter (klass2_map));
for (unsigned class1_idx : + hb_range ((unsigned) class1Count) | hb_filter (klass1_map))
{
for (unsigned class2_idx : + hb_range ((unsigned) class2Count) | hb_filter (klass2_map))
for (unsigned class2_idx : class2_idxs)
{
unsigned idx = (class1_idx * (unsigned) class2Count + class2_idx) * (len1 + len2);
unsigned idx = (class1_idx * (unsigned) class2Count + class2_idx) * total_len;
valueFormat1.copy_values (c->serializer, out->valueFormat1, this, &values[idx], &c->plan->layout_variation_idx_delta_map);
valueFormat2.copy_values (c->serializer, out->valueFormat2, this, &values[idx + len1], &c->plan->layout_variation_idx_delta_map);
}
Expand Down
5 changes: 3 additions & 2 deletions thirdparty/harfbuzz/src/OT/Layout/GPOS/PairSet.hh
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ struct PairSet

unsigned int count = len;
const PairValueRecord *record = &firstPairValueRecord;
return_trace (closure->valueFormats[0].sanitize_values_stride_unsafe (c, this, &record->values[0], count, closure->stride) &&
closure->valueFormats[1].sanitize_values_stride_unsafe (c, this, &record->values[closure->len1], count, closure->stride));
return_trace (c->lazy_some_gpos ||
(closure->valueFormats[0].sanitize_values_stride_unsafe (c, this, &record->values[0], count, closure->stride) &&
closure->valueFormats[1].sanitize_values_stride_unsafe (c, this, &record->values[closure->len1], count, closure->stride)));
}

bool intersects (const hb_set_t *glyphs,
Expand Down
3 changes: 2 additions & 1 deletion thirdparty/harfbuzz/src/OT/Layout/GPOS/SinglePosFormat1.hh
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ struct SinglePosFormat1

bool
position_single (hb_font_t *font,
hb_blob_t *table_blob,
hb_direction_t direction,
hb_codepoint_t gid,
hb_glyph_position_t &pos) const
Expand All @@ -100,7 +101,7 @@ struct SinglePosFormat1
/* This is ugly... */
hb_buffer_t buffer;
buffer.props.direction = direction;
OT::hb_ot_apply_context_t c (1, font, &buffer);
OT::hb_ot_apply_context_t c (1, font, &buffer, table_blob);

valueFormat.apply_value (&c, this, values, pos);
return true;
Expand Down
3 changes: 2 additions & 1 deletion thirdparty/harfbuzz/src/OT/Layout/GPOS/SinglePosFormat2.hh
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ struct SinglePosFormat2

bool
position_single (hb_font_t *font,
hb_blob_t *table_blob,
hb_direction_t direction,
hb_codepoint_t gid,
hb_glyph_position_t &pos) const
Expand All @@ -105,7 +106,7 @@ struct SinglePosFormat2
/* This is ugly... */
hb_buffer_t buffer;
buffer.props.direction = direction;
OT::hb_ot_apply_context_t c (1, font, &buffer);
OT::hb_ot_apply_context_t c (1, font, &buffer, table_blob);

valueFormat.apply_value (&c, this,
&values[index * valueFormat.get_len ()],
Expand Down
Loading

0 comments on commit da88468

Please sign in to comment.