summaryrefslogtreecommitdiff
path: root/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hmtx-table.hh
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hmtx-table.hh')
-rw-r--r--Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hmtx-table.hh58
1 files changed, 43 insertions, 15 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hmtx-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hmtx-table.hh
index 6b2cc866265..e20b3726226 100644
--- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hmtx-table.hh
+++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-hmtx-table.hh
@@ -42,6 +42,13 @@
#define HB_OT_TAG_vmtx HB_TAG('v','m','t','x')
+HB_INTERNAL int
+_glyf_get_side_bearing_var (hb_font_t *font, hb_codepoint_t glyph, bool is_vertical);
+
+HB_INTERNAL unsigned
+_glyf_get_advance_var (hb_font_t *font, hb_codepoint_t glyph, bool is_vertical);
+
+
namespace OT {
@@ -53,6 +60,7 @@ struct LongMetric
DEFINE_SIZE_STATIC (4);
};
+
template <typename T, typename H>
struct hmtxvmtx
{
@@ -128,13 +136,12 @@ struct hmtxvmtx
auto it =
+ hb_range (c->plan->num_output_glyphs ())
| hb_map ([c, &_mtx] (unsigned _)
- {
- hb_codepoint_t old_gid;
- if (c->plan->old_gid_for_new_gid (_, &old_gid))
- return hb_pair (_mtx.get_advance (old_gid), _mtx.get_side_bearing (old_gid));
- else
- return hb_pair (0u, 0u);
- })
+ {
+ hb_codepoint_t old_gid;
+ if (!c->plan->old_gid_for_new_gid (_, &old_gid))
+ return hb_pair (0u, 0);
+ return hb_pair (_mtx.get_advance (old_gid), _mtx.get_side_bearing (old_gid));
+ })
;
table_prime->serialize (c->serializer, it, num_advances);
@@ -146,9 +153,7 @@ struct hmtxvmtx
// Amend header num hmetrics
if (unlikely (!subset_update_header (c->plan, num_advances)))
- {
return_trace (false);
- }
return_trace (true);
}
@@ -190,8 +195,7 @@ struct hmtxvmtx
var_table.destroy ();
}
- /* TODO Add variations version. */
- unsigned int get_side_bearing (hb_codepoint_t glyph) const
+ int get_side_bearing (hb_codepoint_t glyph) const
{
if (glyph < num_advances)
return table->longMetricZ[glyph].sb;
@@ -203,6 +207,23 @@ struct hmtxvmtx
return bearings[glyph - num_advances];
}
+ int get_side_bearing (hb_font_t *font, hb_codepoint_t glyph) const
+ {
+ int side_bearing = get_side_bearing (glyph);
+
+#ifndef HB_NO_VAR
+ if (unlikely (glyph >= num_metrics) || !font->num_coords)
+ return side_bearing;
+
+ if (var_table.get_length ())
+ return side_bearing + var_table->get_side_bearing_var (glyph, font->coords, font->num_coords); // TODO Optimize?!
+
+ return _glyf_get_side_bearing_var (font, glyph, T::tableTag == HB_OT_TAG_vmtx);
+#else
+ return side_bearing;
+#endif
+ }
+
unsigned int get_advance (hb_codepoint_t glyph) const
{
if (unlikely (glyph >= num_metrics))
@@ -223,11 +244,18 @@ struct hmtxvmtx
hb_font_t *font) const
{
unsigned int advance = get_advance (glyph);
- if (likely (glyph < num_metrics))
- {
- advance += (font->num_coords ? var_table->get_advance_var (glyph, font->coords, font->num_coords) : 0); // TODO Optimize?!
- }
+
+#ifndef HB_NO_VAR
+ if (unlikely (glyph >= num_metrics) || !font->num_coords)
+ return advance;
+
+ if (var_table.get_length ())
+ return advance + roundf (var_table->get_advance_var (font, glyph)); // TODO Optimize?!
+
+ return _glyf_get_advance_var (font, glyph, T::tableTag == HB_OT_TAG_vmtx);
+#else
return advance;
+#endif
}
unsigned int num_advances_for_subset (const hb_subset_plan_t *plan) const