aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQunxin Liu <qxliu@google.com>2023-09-25 08:59:11 -0700
committerQunxin Liu <qxliu@google.com>2023-09-27 11:22:53 -0700
commitf39e9bf1ed52140d2658b4d845f3bbacc215221b (patch)
treeeeb4bd3c5319a8cf2ccf1772d5dd58cd7518c2ca
parent5c6795e2701d7c2031bc3e7c6c1b356961350291 (diff)
downloadharfbuzz_ng-f39e9bf1ed52140d2658b4d845f3bbacc215221b.tar.gz
[instancer] instantiate GPOS
Just need to update var_idxes and deltas
-rw-r--r--src/OT/Layout/GDEF/GDEF.hh18
-rw-r--r--src/OT/Layout/GPOS/AnchorFormat3.hh23
-rw-r--r--src/hb-ot-layout-common.hh4
3 files changed, 30 insertions, 15 deletions
diff --git a/src/OT/Layout/GDEF/GDEF.hh b/src/OT/Layout/GDEF/GDEF.hh
index 62e0fb847..dd025c128 100644
--- a/src/OT/Layout/GDEF/GDEF.hh
+++ b/src/OT/Layout/GDEF/GDEF.hh
@@ -204,17 +204,19 @@ struct CaretValueFormat3
if (!c->serializer->embed (coordinate)) return_trace (false);
unsigned varidx = (this+deviceTable).get_variation_index ();
- if (c->plan->layout_variation_idx_delta_map.has (varidx))
+ hb_pair_t<unsigned, int> *new_varidx_delta;
+ if (!c->plan->layout_variation_idx_delta_map.has (varidx, &new_varidx_delta))
+ return_trace (false);
+
+ uint32_t new_varidx = hb_first (*new_varidx_delta);
+ int delta = hb_second (*new_varidx_delta);
+ if (delta != 0)
{
- int delta = hb_second (c->plan->layout_variation_idx_delta_map.get (varidx));
- if (delta != 0)
- {
- if (!c->serializer->check_assign (out->coordinate, coordinate + delta, HB_SERIALIZE_ERROR_INT_OVERFLOW))
- return_trace (false);
- }
+ if (!c->serializer->check_assign (out->coordinate, coordinate + delta, HB_SERIALIZE_ERROR_INT_OVERFLOW))
+ return_trace (false);
}
- if (c->plan->all_axes_pinned)
+ if (new_varidx == HB_OT_LAYOUT_NO_VARIATIONS_INDEX)
return_trace (c->serializer->check_assign (out->caretValueFormat, 1, HB_SERIALIZE_ERROR_INT_OVERFLOW));
if (!c->serializer->embed (deviceTable))
diff --git a/src/OT/Layout/GPOS/AnchorFormat3.hh b/src/OT/Layout/GPOS/AnchorFormat3.hh
index 8684f60ca..56eda4a57 100644
--- a/src/OT/Layout/GPOS/AnchorFormat3.hh
+++ b/src/OT/Layout/GPOS/AnchorFormat3.hh
@@ -52,9 +52,14 @@ struct AnchorFormat3
if (unlikely (!c->serializer->embed (yCoordinate))) return_trace (false);
unsigned x_varidx = xDeviceTable ? (this+xDeviceTable).get_variation_index () : HB_OT_LAYOUT_NO_VARIATIONS_INDEX;
- if (c->plan->layout_variation_idx_delta_map.has (x_varidx))
+ if (x_varidx != HB_OT_LAYOUT_NO_VARIATIONS_INDEX)
{
- int delta = hb_second (c->plan->layout_variation_idx_delta_map.get (x_varidx));
+ hb_pair_t<unsigned, int> *new_varidx_delta;
+ if (!c->plan->layout_variation_idx_delta_map.has (x_varidx, &new_varidx_delta))
+ return_trace (false);
+
+ x_varidx = hb_first (*new_varidx_delta);
+ int delta = hb_second (*new_varidx_delta);
if (delta != 0)
{
if (!c->serializer->check_assign (out->xCoordinate, xCoordinate + delta,
@@ -64,9 +69,14 @@ struct AnchorFormat3
}
unsigned y_varidx = yDeviceTable ? (this+yDeviceTable).get_variation_index () : HB_OT_LAYOUT_NO_VARIATIONS_INDEX;
- if (c->plan->layout_variation_idx_delta_map.has (y_varidx))
+ if (y_varidx != HB_OT_LAYOUT_NO_VARIATIONS_INDEX)
{
- int delta = hb_second (c->plan->layout_variation_idx_delta_map.get (y_varidx));
+ hb_pair_t<unsigned, int> *new_varidx_delta;
+ if (!c->plan->layout_variation_idx_delta_map.has (y_varidx, &new_varidx_delta))
+ return_trace (false);
+
+ y_varidx = hb_first (*new_varidx_delta);
+ int delta = hb_second (*new_varidx_delta);
if (delta != 0)
{
if (!c->serializer->check_assign (out->yCoordinate, yCoordinate + delta,
@@ -75,7 +85,10 @@ struct AnchorFormat3
}
}
- if (c->plan->all_axes_pinned)
+ /* in case that all axes are pinned or no variations after instantiation,
+ * both var_idxes will be mapped to HB_OT_LAYOUT_NO_VARIATIONS_INDEX */
+ if (x_varidx == HB_OT_LAYOUT_NO_VARIATIONS_INDEX &&
+ y_varidx == HB_OT_LAYOUT_NO_VARIATIONS_INDEX)
return_trace (c->serializer->check_assign (out->format, 1, HB_SERIALIZE_ERROR_INT_OVERFLOW));
if (!c->serializer->embed (xDeviceTable)) return_trace (false);
diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh
index 2146a1726..7125e99e4 100644
--- a/src/hb-ot-layout-common.hh
+++ b/src/hb-ot-layout-common.hh
@@ -3966,8 +3966,8 @@ struct VariationDevice
auto *out = c->embed (this);
if (unlikely (!out)) return_trace (nullptr);
- unsigned new_idx = hb_first (*v);
- out->varIdx = new_idx;
+ if (!c->check_assign (out->varIdx, hb_first (*v), HB_SERIALIZE_ERROR_INT_OVERFLOW))
+ return_trace (nullptr);
return_trace (out);
}