summaryrefslogtreecommitdiffstats
path: root/thirdparty/harfbuzz/src/OT/glyf
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-10-02 15:01:23 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-10-02 15:01:23 +0200
commit991b741f6c4a3b7968662c318077c8af6932d7e2 (patch)
treef2a46f72a403341062e84df84a261909736f169b /thirdparty/harfbuzz/src/OT/glyf
parent2bd0fd8e3d7eabe57569096646bb6e939431ee28 (diff)
parentb6a369de79203a73c3318f4195777edec68399a6 (diff)
downloadredot-engine-991b741f6c4a3b7968662c318077c8af6932d7e2.tar.gz
Merge pull request #97677 from bruvzg/hb1001
Update HarfBuzz to 10.0.1
Diffstat (limited to 'thirdparty/harfbuzz/src/OT/glyf')
-rw-r--r--thirdparty/harfbuzz/src/OT/glyf/Glyph.hh135
-rw-r--r--thirdparty/harfbuzz/src/OT/glyf/SubsetGlyph.hh13
-rw-r--r--thirdparty/harfbuzz/src/OT/glyf/glyf.hh13
3 files changed, 16 insertions, 145 deletions
diff --git a/thirdparty/harfbuzz/src/OT/glyf/Glyph.hh b/thirdparty/harfbuzz/src/OT/glyf/Glyph.hh
index 69a0b625c7..7772597e59 100644
--- a/thirdparty/harfbuzz/src/OT/glyf/Glyph.hh
+++ b/thirdparty/harfbuzz/src/OT/glyf/Glyph.hh
@@ -7,8 +7,6 @@
#include "GlyphHeader.hh"
#include "SimpleGlyph.hh"
#include "CompositeGlyph.hh"
-#include "VarCompositeGlyph.hh"
-#include "coord-setter.hh"
namespace OT {
@@ -33,9 +31,6 @@ struct Glyph
EMPTY,
SIMPLE,
COMPOSITE,
-#ifndef HB_NO_VAR_COMPOSITES
- VAR_COMPOSITE,
-#endif
};
public:
@@ -44,22 +39,10 @@ struct Glyph
if (type != COMPOSITE) return composite_iter_t ();
return CompositeGlyph (*header, bytes).iter ();
}
- var_composite_iter_t get_var_composite_iterator () const
- {
-#ifndef HB_NO_VAR_COMPOSITES
- if (type != VAR_COMPOSITE) return var_composite_iter_t ();
- return VarCompositeGlyph (*header, bytes).iter ();
-#else
- return var_composite_iter_t ();
-#endif
- }
const hb_bytes_t trim_padding () const
{
switch (type) {
-#ifndef HB_NO_VAR_COMPOSITES
- case VAR_COMPOSITE: return VarCompositeGlyph (*header, bytes).trim_padding ();
-#endif
case COMPOSITE: return CompositeGlyph (*header, bytes).trim_padding ();
case SIMPLE: return SimpleGlyph (*header, bytes).trim_padding ();
case EMPTY: return bytes;
@@ -70,9 +53,6 @@ struct Glyph
void drop_hints ()
{
switch (type) {
-#ifndef HB_NO_VAR_COMPOSITES
- case VAR_COMPOSITE: return; // No hinting
-#endif
case COMPOSITE: CompositeGlyph (*header, bytes).drop_hints (); return;
case SIMPLE: SimpleGlyph (*header, bytes).drop_hints (); return;
case EMPTY: return;
@@ -82,9 +62,6 @@ struct Glyph
void set_overlaps_flag ()
{
switch (type) {
-#ifndef HB_NO_VAR_COMPOSITES
- case VAR_COMPOSITE: return; // No overlaps flag
-#endif
case COMPOSITE: CompositeGlyph (*header, bytes).set_overlaps_flag (); return;
case SIMPLE: SimpleGlyph (*header, bytes).set_overlaps_flag (); return;
case EMPTY: return;
@@ -94,9 +71,6 @@ struct Glyph
void drop_hints_bytes (hb_bytes_t &dest_start, hb_bytes_t &dest_end) const
{
switch (type) {
-#ifndef HB_NO_VAR_COMPOSITES
- case VAR_COMPOSITE: return; // No hinting
-#endif
case COMPOSITE: CompositeGlyph (*header, bytes).drop_hints_bytes (dest_start); return;
case SIMPLE: SimpleGlyph (*header, bytes).drop_hints_bytes (dest_start, dest_end); return;
case EMPTY: return;
@@ -120,14 +94,6 @@ struct Glyph
if (unlikely (!item.get_points (points))) return false;
break;
}
-#ifndef HB_NO_VAR_COMPOSITES
- case VAR_COMPOSITE:
- {
- for (auto &item : get_var_composite_iterator ())
- if (unlikely (!item.get_points (points))) return false;
- break;
- }
-#endif
case EMPTY:
break;
}
@@ -303,13 +269,6 @@ struct Glyph
{
switch (type)
{
-#ifndef HB_NO_VAR_COMPOSITES
- case VAR_COMPOSITE:
- // TODO
- dest_end = hb_bytes_t ();
- break;
-#endif
-
case COMPOSITE:
if (!CompositeGlyph (*header, bytes).compile_bytes_with_deltas (dest_start,
points_with_deltas,
@@ -352,7 +311,7 @@ struct Glyph
bool shift_points_hori = true,
bool use_my_metrics = true,
bool phantom_only = false,
- hb_array_t<int> coords = hb_array_t<int> (),
+ hb_array_t<const int> coords = hb_array_t<const int> (),
hb_map_t *current_glyphs = nullptr,
unsigned int depth = 0,
unsigned *edge_count = nullptr) const
@@ -360,7 +319,7 @@ struct Glyph
if (unlikely (depth > HB_MAX_NESTING_LEVEL)) return false;
unsigned stack_edge_count = 0;
if (!edge_count) edge_count = &stack_edge_count;
- if (unlikely (*edge_count > HB_GLYF_MAX_EDGE_COUNT)) return false;
+ if (unlikely (*edge_count > HB_MAX_GRAPH_EDGE_COUNT)) return false;
(*edge_count)++;
hb_map_t current_glyphs_stack;
@@ -394,14 +353,6 @@ struct Glyph
if (unlikely (!item.get_points (points))) return false;
break;
}
-#ifndef HB_NO_VAR_COMPOSITES
- case VAR_COMPOSITE:
- {
- for (auto &item : get_var_composite_iterator ())
- if (unlikely (!item.get_points (points))) return false;
- break;
- }
-#endif
case EMPTY:
break;
}
@@ -542,81 +493,6 @@ struct Glyph
}
all_points.extend (phantoms);
} break;
-#ifndef HB_NO_VAR_COMPOSITES
- case VAR_COMPOSITE:
- {
- hb_array_t<contour_point_t> points_left = points.as_array ();
- for (auto &item : get_var_composite_iterator ())
- {
- hb_codepoint_t item_gid = item.get_gid ();
-
- if (unlikely (current_glyphs->has (item_gid)))
- continue;
-
- current_glyphs->add (item_gid);
-
- unsigned item_num_points = item.get_num_points ();
- hb_array_t<contour_point_t> record_points = points_left.sub_array (0, item_num_points);
- assert (record_points.length == item_num_points);
-
- auto component_coords = coords;
- /* Copying coords is expensive; so we have put an arbitrary
- * limit on the max number of coords for now. */
- if (item.is_reset_unspecified_axes () ||
- coords.length > HB_GLYF_VAR_COMPOSITE_MAX_AXES)
- component_coords = hb_array<int> ();
-
- coord_setter_t coord_setter (component_coords);
- item.set_variations (coord_setter, record_points);
-
- unsigned old_count = all_points.length;
-
- if (unlikely ((!phantom_only || (use_my_metrics && item.is_use_my_metrics ())) &&
- !glyf_accelerator.glyph_for_gid (item_gid)
- .get_points (font,
- glyf_accelerator,
- all_points,
- points_with_deltas,
- head_maxp_info,
- nullptr,
- shift_points_hori,
- use_my_metrics,
- phantom_only,
- coord_setter.get_coords (),
- current_glyphs,
- depth + 1,
- edge_count)))
- {
- current_glyphs->del (item_gid);
- return false;
- }
-
- auto comp_points = all_points.as_array ().sub_array (old_count);
-
- /* Apply component transformation */
- if (comp_points) // Empty in case of phantom_only
- item.transform_points (record_points, comp_points);
-
- /* Copy phantom points from component if USE_MY_METRICS flag set */
- if (use_my_metrics && item.is_use_my_metrics ())
- for (unsigned int i = 0; i < PHANTOM_COUNT; i++)
- phantoms[i] = comp_points[comp_points.length - PHANTOM_COUNT + i];
-
- all_points.resize (all_points.length - PHANTOM_COUNT);
-
- if (all_points.length > HB_GLYF_MAX_POINTS)
- {
- current_glyphs->del (item_gid);
- return false;
- }
-
- points_left += item_num_points;
-
- current_glyphs->del (item_gid);
- }
- all_points.extend (phantoms);
- } break;
-#endif
case EMPTY:
all_points.extend (phantoms);
break;
@@ -627,7 +503,7 @@ struct Glyph
/* Undocumented rasterizer behavior:
* Shift points horizontally by the updated left side bearing
*/
- int v = -phantoms[PHANTOM_LEFT].x;
+ float v = -phantoms[PHANTOM_LEFT].x;
if (v)
for (auto &point : all_points)
point.x += v;
@@ -661,10 +537,7 @@ struct Glyph
int num_contours = header->numberOfContours;
if (unlikely (num_contours == 0)) type = EMPTY;
else if (num_contours > 0) type = SIMPLE;
- else if (num_contours == -1) type = COMPOSITE;
-#ifndef HB_NO_VAR_COMPOSITES
- else if (num_contours == -2) type = VAR_COMPOSITE;
-#endif
+ else if (num_contours <= -1) type = COMPOSITE;
else type = EMPTY; // Spec deviation; Spec says COMPOSITE, but not seen in the wild.
}
diff --git a/thirdparty/harfbuzz/src/OT/glyf/SubsetGlyph.hh b/thirdparty/harfbuzz/src/OT/glyf/SubsetGlyph.hh
index 8099d3c126..fe63066e41 100644
--- a/thirdparty/harfbuzz/src/OT/glyf/SubsetGlyph.hh
+++ b/thirdparty/harfbuzz/src/OT/glyf/SubsetGlyph.hh
@@ -53,23 +53,12 @@ struct SubsetGlyph
if (plan->new_gid_for_old_gid (_.get_gid(), &new_gid))
const_cast<CompositeGlyphRecord &> (_).set_gid (new_gid);
}
-#ifndef HB_NO_VAR_COMPOSITES
- for (auto &_ : Glyph (dest_glyph).get_var_composite_iterator ())
- {
- hb_codepoint_t new_gid;
- if (plan->new_gid_for_old_gid (_.get_gid(), &new_gid))
- const_cast<VarCompositeGlyphRecord &> (_).set_gid (new_gid);
- }
-#endif
#ifndef HB_NO_BEYOND_64K
auto it = Glyph (dest_glyph).get_composite_iterator ();
if (it)
{
- /* lower GID24 to GID16 in components if possible.
- *
- * TODO: VarComposite. Not as critical, since VarComposite supports
- * gid24 from the first version. */
+ /* lower GID24 to GID16 in components if possible. */
char *p = it ? (char *) &*it : nullptr;
char *q = p;
const char *end = dest_glyph.arrayZ + dest_glyph.length;
diff --git a/thirdparty/harfbuzz/src/OT/glyf/glyf.hh b/thirdparty/harfbuzz/src/OT/glyf/glyf.hh
index 6300cf4be0..f346ae05dc 100644
--- a/thirdparty/harfbuzz/src/OT/glyf/glyf.hh
+++ b/thirdparty/harfbuzz/src/OT/glyf/glyf.hh
@@ -205,8 +205,12 @@ struct glyf_accelerator_t
protected:
template<typename T>
- bool get_points (hb_font_t *font, hb_codepoint_t gid, T consumer) const
+ bool get_points (hb_font_t *font, hb_codepoint_t gid, T consumer,
+ hb_array_t<const int> coords = hb_array_t<const int> ()) const
{
+ if (!coords)
+ coords = hb_array (font->coords, font->num_coords);
+
if (gid >= num_glyphs) return false;
/* Making this allocfree is not that easy
@@ -216,7 +220,7 @@ struct glyf_accelerator_t
contour_point_vector_t all_points;
bool phantom_only = !consumer.is_consuming_contour_points ();
- if (unlikely (!glyph_for_gid (gid).get_points (font, *this, all_points, nullptr, nullptr, nullptr, true, true, phantom_only)))
+ if (unlikely (!glyph_for_gid (gid).get_points (font, *this, all_points, nullptr, nullptr, nullptr, true, true, phantom_only, coords)))
return false;
unsigned count = all_points.length;
@@ -408,6 +412,11 @@ struct glyf_accelerator_t
get_path (hb_font_t *font, hb_codepoint_t gid, hb_draw_session_t &draw_session) const
{ return get_points (font, gid, glyf_impl::path_builder_t (font, draw_session)); }
+ bool
+ get_path_at (hb_font_t *font, hb_codepoint_t gid, hb_draw_session_t &draw_session,
+ hb_array_t<const int> coords) const
+ { return get_points (font, gid, glyf_impl::path_builder_t (font, draw_session), coords); }
+
#ifndef HB_NO_VAR
const gvar_accelerator_t *gvar;
#endif