Merge pull request #4329 from googlefonts/instancer_solver_fix

port instancer solver normalizeValue fixes from fonttools
pull/4331/head
Behdad Esfahbod 1 year ago committed by GitHub
commit a9e9279bee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      src/hb-ot-layout-common.hh
  2. 21
      src/hb-ot-var-common.hh
  3. 2
      src/hb-ot-var-cvar-table.hh
  4. 7
      src/hb-ot-var-fvar-table.hh
  5. 52
      src/hb-subset-instancer-solver.cc
  6. 24
      src/hb-subset-instancer-solver.hh
  7. 2
      src/hb-subset-plan-member-list.hh
  8. 12
      src/hb-subset-plan.cc
  9. 78
      src/test-subset-instancer-solver.cc
  10. 5
      src/test-tuple-varstore.cc

@ -2937,9 +2937,29 @@ struct ConditionFormat1
const hb_map_t *index_map = &c->plan->axes_index_map;
if (index_map->is_empty ()) return_trace (true);
if (!index_map->has (axisIndex))
const hb_map_t& axes_old_index_tag_map = c->plan->axes_old_index_tag_map;
hb_codepoint_t *axis_tag;
if (!axes_old_index_tag_map.has (axisIndex, &axis_tag) ||
!index_map->has (axisIndex))
return_trace (false);
const hb_hashmap_t<hb_tag_t, Triple>& normalized_axes_location = c->plan->axes_location;
Triple axis_limit{-1.f, 0.f, 1.f};
Triple *normalized_limit;
if (normalized_axes_location.has (*axis_tag, &normalized_limit))
axis_limit = *normalized_limit;
const hb_hashmap_t<hb_tag_t, TripleDistances>& axes_triple_distances = c->plan->axes_triple_distances;
TripleDistances axis_triple_distances{1.f, 1.f};
TripleDistances *triple_dists;
if (axes_triple_distances.has (*axis_tag, &triple_dists))
axis_triple_distances = *triple_dists;
float normalized_min = renormalizeValue (filterRangeMinValue.to_float (), axis_limit, axis_triple_distances, false);
float normalized_max = renormalizeValue (filterRangeMaxValue.to_float (), axis_limit, axis_triple_distances, false);
out->filterRangeMinValue.set_float (normalized_min);
out->filterRangeMaxValue.set_float (normalized_max);
return_trace (c->serializer->check_assign (out->axisIndex, index_map->get (axisIndex),
HB_SERIALIZE_ERROR_INT_OVERFLOW));
}

@ -533,7 +533,8 @@ struct tuple_delta_t
return *this;
}
hb_vector_t<tuple_delta_t> change_tuple_var_axis_limit (hb_tag_t axis_tag, Triple axis_limit) const
hb_vector_t<tuple_delta_t> change_tuple_var_axis_limit (hb_tag_t axis_tag, Triple axis_limit,
TripleDistances axis_triple_distances) const
{
hb_vector_t<tuple_delta_t> out;
Triple *tent;
@ -553,7 +554,7 @@ struct tuple_delta_t
return out;
}
result_t solutions = rebase_tent (*tent, axis_limit);
result_t solutions = rebase_tent (*tent, axis_limit, axis_triple_distances);
for (auto t : solutions)
{
tuple_delta_t new_var = *this;
@ -1006,16 +1007,21 @@ struct TupleVariationData
return true;
}
void change_tuple_variations_axis_limits (const hb_hashmap_t<hb_tag_t, Triple> *normalized_axes_location)
void change_tuple_variations_axis_limits (const hb_hashmap_t<hb_tag_t, Triple>& normalized_axes_location,
const hb_hashmap_t<hb_tag_t, TripleDistances>& axes_triple_distances)
{
for (auto _ : *normalized_axes_location)
for (auto _ : normalized_axes_location)
{
hb_tag_t axis_tag = _.first;
Triple axis_limit = _.second;
TripleDistances axis_triple_distances{1.f, 1.f};
if (axes_triple_distances.has (axis_tag))
axis_triple_distances = axes_triple_distances.get (axis_tag);
hb_vector_t<tuple_delta_t> new_vars;
for (const tuple_delta_t& var : tuple_vars)
{
hb_vector_t<tuple_delta_t> out = var.change_tuple_var_axis_limit (axis_tag, axis_limit);
hb_vector_t<tuple_delta_t> out = var.change_tuple_var_axis_limit (axis_tag, axis_limit, axis_triple_distances);
if (!out) continue;
unsigned new_len = new_vars.length + out.length;
@ -1196,9 +1202,10 @@ struct TupleVariationData
return res;
}
void instantiate (const hb_hashmap_t<hb_tag_t, Triple>& normalized_axes_location)
void instantiate (const hb_hashmap_t<hb_tag_t, Triple>& normalized_axes_location,
const hb_hashmap_t<hb_tag_t, TripleDistances>& axes_triple_distances)
{
change_tuple_variations_axis_limits (&normalized_axes_location);
change_tuple_variations_axis_limits (normalized_axes_location, axes_triple_distances);
merge_tuple_variations ();
}

@ -167,7 +167,7 @@ struct cvar
tuple_variations))
return_trace (false);
tuple_variations.instantiate (c->plan->axes_location);
tuple_variations.instantiate (c->plan->axes_location, c->plan->axes_triple_distances);
if (!tuple_variations.compile_bytes (c->plan->axes_index_map, c->plan->axes_old_index_tag_map))
return_trace (false);

@ -228,6 +228,13 @@ struct AxisRecord
return defaultValue.to_float ();
}
TripleDistances get_triple_distances () const
{
float min, default_, max;
get_coordinates (min, default_, max);
return TripleDistances (min, default_, max);
}
public:
Tag axisTag; /* Tag identifying the design variation for the axis. */
protected:

@ -253,9 +253,8 @@ _solve (Triple tent, Triple axisLimit, bool negative = false)
* axisDef axisMax
*/
float newUpper = peak + (1 - gain) * (upper - peak);
// I feel like the first condition is always true because
// outGain >= gain.
if (axisMax <= newUpper && newUpper <= axisDef + (axisMax - axisDef) * 2)
assert (axisMax <= newUpper); // Because outGain >= gain
if (newUpper <= axisDef + (axisMax - axisDef) * 2)
{
upper = newUpper;
if (!negative && axisDef + (axisMax - axisDef) * MAX_F2DOT14 < upper)
@ -362,38 +361,47 @@ _solve (Triple tent, Triple axisLimit, bool negative = false)
return out;
}
/* Normalizes value based on a min/default/max triple. */
static inline float normalizeValue (float v, const Triple &triple, bool extrapolate = false)
static inline TripleDistances _reverse_triple_distances (const TripleDistances &v)
{ return TripleDistances (v.positive, v.negative); }
float renormalizeValue (float v, const Triple &triple,
const TripleDistances &triple_distances, bool extrapolate)
{
/*
>>> normalizeValue(400, (100, 400, 900))
0.0
>>> normalizeValue(100, (100, 400, 900))
-1.0
>>> normalizeValue(650, (100, 400, 900))
0.5
*/
float lower = triple.minimum, def = triple.middle, upper = triple.maximum;
assert (lower <= def && def <= upper);
if (!extrapolate)
v = hb_max (hb_min (v, upper), lower);
if ((v == def) || (lower == upper))
if (v == def)
return 0.f;
if ((v < def && lower != def) || (v > def && upper == def))
if (def < 0.f)
return -renormalizeValue (-v, _reverse_negate (triple),
_reverse_triple_distances (triple_distances), extrapolate);
/* default >= 0 and v != default */
if (v > def)
return (v - def) / (upper - def);
/* v < def */
if (lower >= 0.f)
return (v - def) / (def - lower);
/* lower < 0 and v < default */
float total_distance = triple_distances.negative * (-lower) + triple_distances.positive * def;
float v_distance;
if (v >= 0.f)
v_distance = (def - v) * triple_distances.positive;
else
{
assert ((v > def && upper != def) ||
(v < def && lower == def));
return (v - def) / (upper - def);
}
v_distance = (-v) * triple_distances.negative + triple_distances.positive * def;
return (-v_distance) /total_distance;
}
result_t
rebase_tent (Triple tent, Triple axisLimit)
rebase_tent (Triple tent, Triple axisLimit, TripleDistances axis_triple_distances)
{
assert (-1.f <= axisLimit.minimum && axisLimit.minimum <= axisLimit.middle && axisLimit.middle <= axisLimit.maximum && axisLimit.maximum <= +1.f);
assert (-2.f <= tent.minimum && tent.minimum <= tent.middle && tent.middle <= tent.maximum && tent.maximum <= +2.f);
@ -401,7 +409,7 @@ rebase_tent (Triple tent, Triple axisLimit)
result_t sols = _solve (tent, axisLimit);
auto n = [&axisLimit] (float v) { return normalizeValue (v, axisLimit, true); };
auto n = [&axisLimit, &axis_triple_distances] (float v) { return renormalizeValue (v, axisLimit, axis_triple_distances); };
result_t out;
for (auto &p : sols)

@ -27,6 +27,21 @@
#include "hb.hh"
/* pre-normalized distances */
struct TripleDistances
{
TripleDistances (): negative (1.f), positive (1.f) {}
TripleDistances (float neg_, float pos_): negative (neg_), positive (pos_) {}
TripleDistances (float min, float default_, float max)
{
negative = default_ - min;
positive = max - default_;
}
float negative;
float positive;
};
struct Triple {
Triple () :
@ -66,6 +81,7 @@ struct Triple {
return current;
}
float minimum;
float middle;
float maximum;
@ -74,6 +90,12 @@ struct Triple {
using result_item_t = hb_pair_t<float, Triple>;
using result_t = hb_vector_t<result_item_t>;
/* renormalize a normalized value v to the range of an axis,
* considering the prenormalized distances as well as the new axis limits.
* Ported from fonttools */
HB_INTERNAL float renormalizeValue (float v, const Triple &triple,
const TripleDistances &triple_distances,
bool extrapolate = true);
/* Given a tuple (lower,peak,upper) "tent" and new axis limits
* (axisMin,axisDefault,axisMax), solves how to represent the tent
* under the new axis configuration. All values are in normalized
@ -85,6 +107,6 @@ using result_t = hb_vector_t<result_item_t>;
* If tent value is Triple{}, that is a special deltaset that should
* be always-enabled (called "gain").
*/
HB_INTERNAL result_t rebase_tent (Triple tent, Triple axisLimit);
HB_INTERNAL result_t rebase_tent (Triple tent, Triple axisLimit, TripleDistances axis_triple_distances);
#endif /* HB_SUBSET_INSTANCER_SOLVER_HH */

@ -105,6 +105,8 @@ HB_SUBSET_PLAN_MEMBER (hb_vector_t<int>, normalized_coords)
//user specified axes range map
HB_SUBSET_PLAN_MEMBER (hb_hashmap_t E(<hb_tag_t, Triple>), user_axes_location)
//axis->TripleDistances map (distances in the pre-normalized space)
HB_SUBSET_PLAN_MEMBER (hb_hashmap_t E(<hb_tag_t, TripleDistances>), axes_triple_distances)
//retained old axis index -> new axis index mapping in fvar axis array
HB_SUBSET_PLAN_MEMBER (hb_map_t, axes_index_map)

@ -930,12 +930,14 @@ _normalize_axes_location (hb_face_t *face, hb_subset_plan_t *plan)
new_axis_idx++;
}
if (plan->user_axes_location.has (axis_tag))
Triple *axis_range;
if (plan->user_axes_location.has (axis_tag, &axis_range))
{
Triple axis_range = plan->user_axes_location.get (axis_tag);
int normalized_min = axis.normalize_axis_value (axis_range.minimum);
int normalized_default = axis.normalize_axis_value (axis_range.middle);
int normalized_max = axis.normalize_axis_value (axis_range.maximum);
plan->axes_triple_distances.set (axis_tag, axis.get_triple_distances ());
int normalized_min = axis.normalize_axis_value (axis_range->minimum);
int normalized_default = axis.normalize_axis_value (axis_range->middle);
int normalized_max = axis.normalize_axis_value (axis_range->maximum);
if (has_avar && old_axis_idx < avar_axis_count)
{

@ -41,12 +41,13 @@ static inline bool approx (float a, float b)
int
main (int argc, char **argv)
{
TripleDistances default_axis_distances{1.f, 1.f};
/* Case 1 */
{
/* pin axis*/
Triple tent (0.f, 1.f, 1.f);
Triple axis_range (0.f, 0.f, 0.f);
result_t out = rebase_tent (tent, axis_range);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 0);
}
@ -54,7 +55,7 @@ main (int argc, char **argv)
/* pin axis*/
Triple tent (0.f, 1.f, 1.f);
Triple axis_range (0.5f, 0.5f, 0.5f);
result_t out = rebase_tent (tent, axis_range);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 1);
assert (out[0].first == 0.5f);
assert (out[0].second == Triple ());
@ -64,7 +65,7 @@ main (int argc, char **argv)
/* tent falls outside the new axis range */
Triple tent (0.3f, 0.5f, 0.8f);
Triple axis_range (0.1f, 0.2f, 0.3f);
result_t out = rebase_tent (tent, axis_range);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 0);
}
@ -72,7 +73,7 @@ main (int argc, char **argv)
{
Triple tent (0.f, 1.f, 1.f);
Triple axis_range (-1.f, 0.f, 0.5f);
result_t out = rebase_tent (tent, axis_range);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 1);
assert (out[0].first == 0.5f);
assert (out[0].second == Triple (0.f, 1.f, 1.f));
@ -82,7 +83,7 @@ main (int argc, char **argv)
{
Triple tent (0.f, 1.f, 1.f);
Triple axis_range (-1.f, 0.f, 0.75f);
result_t out = rebase_tent (tent, axis_range);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 1);
assert (out[0].first == 0.75f);
assert (out[0].second == Triple (0.f, 1.f, 1.f));
@ -93,7 +94,7 @@ main (int argc, char **argv)
{
Triple tent (0.f, 0.2f, 1.f);
Triple axis_range (-1.f, 0.f, 0.8f);
result_t out = rebase_tent (tent, axis_range);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 1);
assert (out[0].first == 1.f);
assert (out[0].second == Triple (0.f, 0.25f, 1.25f));
@ -103,7 +104,7 @@ main (int argc, char **argv)
{
Triple tent (0.f, 0.4f, 1.f);
Triple axis_range (-1.f, 0.f, 0.5f);
result_t out = rebase_tent (tent, axis_range);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 1);
assert (out[0].first == 1.f);
assert (out[0].second == Triple (0.f, 0.8f, 32767/(float) (1 << 14)));
@ -113,7 +114,7 @@ main (int argc, char **argv)
{
Triple tent (0.f, 0.25f, 1.f);
Triple axis_range (-1.f, 0.f, 0.4f);
result_t out = rebase_tent (tent, axis_range);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 2);
assert (out[0].first == 1.f);
assert (out[0].second == Triple (0.f, 0.625f, 1.f));
@ -125,7 +126,7 @@ main (int argc, char **argv)
{
Triple tent (0.25f, 0.3f, 1.05f);
Triple axis_range (0.f, 0.2f, 0.4f);
result_t out = rebase_tent (tent, axis_range);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 2);
assert (out[0].first == 1.f);
assert (approx (out[0].second, Triple (0.25f, 0.5f, 1.f)));
@ -137,7 +138,7 @@ main (int argc, char **argv)
{
Triple tent (0.25f, 0.5f, 1.f);
Triple axis_range (0.f, 0.25f, 0.5f);
result_t out = rebase_tent (tent, axis_range);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 1);
assert (out[0].first == 1.f);
assert (out[0].second == Triple (0.f, 1.f, 1.f));
@ -148,7 +149,7 @@ main (int argc, char **argv)
{
Triple tent (0.f, 0.5f, 1.f);
Triple axis_range (0.f, 0.5f, 1.f);
result_t out = rebase_tent (tent, axis_range);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 3);
assert (out[0].first == 1.f);
assert (out[0].second == Triple ());
@ -161,7 +162,7 @@ main (int argc, char **argv)
{
Triple tent (0.f, 0.5f, 1.f);
Triple axis_range (0.f, 0.5f, 0.75f);
result_t out = rebase_tent (tent, axis_range);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 3);
assert (out[0].first == 1.f);
assert (out[0].second == Triple ());
@ -174,7 +175,7 @@ main (int argc, char **argv)
{
Triple tent (0.f, 0.5f, 1.f);
Triple axis_range (0.f, 0.25f, 0.8f);
result_t out = rebase_tent (tent, axis_range);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 4);
assert (out[0].first == 0.5f);
assert (out[0].second == Triple ());
@ -190,7 +191,7 @@ main (int argc, char **argv)
{
Triple tent (0.f, 0.5f, 2.f);
Triple axis_range (0.2f, 0.5f, 0.8f);
result_t out = rebase_tent (tent, axis_range);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 3);
assert (out[0].first == 1.f);
assert (out[0].second == Triple ());
@ -204,7 +205,7 @@ main (int argc, char **argv)
{
Triple tent (0.f, 0.5f, 2.f);
Triple axis_range (0.2f, 0.5f, 1.f);
result_t out = rebase_tent (tent, axis_range);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 3);
assert (out[0].first == 1.f);
assert (out[0].second == Triple ());
@ -218,7 +219,7 @@ main (int argc, char **argv)
{
Triple tent (0.f, 0.5f, 1.f);
Triple axis_range (0.25f, 0.25f, 0.75f);
result_t out = rebase_tent (tent, axis_range);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 2);
assert (out[0].first == 0.5f);
assert (out[0].second == Triple ());
@ -230,7 +231,7 @@ main (int argc, char **argv)
{
Triple tent (0.f, 0.5f, 1.f);
Triple axis_range (0.f, 0.25f, 0.5f);
result_t out = rebase_tent (tent, axis_range);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 3);
assert (out[0].first == 0.5f);
assert (out[0].second == Triple ());
@ -244,7 +245,7 @@ main (int argc, char **argv)
{
Triple tent (0.05f, 0.55f, 1.f);
Triple axis_range (0.f, 0.25f, 0.5f);
result_t out = rebase_tent (tent, axis_range);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 4);
assert (approx (out[0].first, 0.4f));
assert (out[0].second == Triple ());
@ -260,7 +261,7 @@ main (int argc, char **argv)
{
Triple tent (-1.f, -0.55f, -0.05f);
Triple axis_range (-0.5f, -0.25f, 0.f);
result_t out = rebase_tent (tent, axis_range);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 4);
assert (approx (out[0].first, 0.4f));
assert (out[0].second == Triple ());
@ -276,7 +277,7 @@ main (int argc, char **argv)
{
Triple tent (0.5f, 0.5f, 0.5f);
Triple axis_range (0.5f, 0.5f, 0.5f);
result_t out = rebase_tent (tent, axis_range);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 1);
assert (out[0].first == 1.f);
assert (out[0].second == Triple ());
@ -285,7 +286,7 @@ main (int argc, char **argv)
{
Triple tent (0.3f, 0.5f, 0.7f);
Triple axis_range (0.1f, 0.5f, 0.9f);
result_t out = rebase_tent (tent, axis_range);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 5);
assert (out[0].first == 1.f);
assert (out[0].second == Triple ());
@ -302,7 +303,7 @@ main (int argc, char **argv)
{
Triple tent (0.5f, 0.5f, 0.5f);
Triple axis_range (0.25f, 0.25f, 0.5f);
result_t out = rebase_tent (tent, axis_range);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 1);
assert (out[0].first == 1.f);
assert (out[0].second == Triple (1.f, 1.f, 1.f));
@ -311,7 +312,7 @@ main (int argc, char **argv)
{
Triple tent (0.5f, 0.5f, 0.5f);
Triple axis_range (0.25f, 0.35f, 0.5f);
result_t out = rebase_tent (tent, axis_range);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 1);
assert (out[0].first == 1.f);
assert (out[0].second == Triple (1.f, 1.f, 1.f));
@ -320,7 +321,7 @@ main (int argc, char **argv)
{
Triple tent (0.5f, 0.5f, 0.55f);
Triple axis_range (0.25f, 0.35f, 0.5f);
result_t out = rebase_tent (tent, axis_range);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 1);
assert (out[0].first == 1.f);
assert (out[0].second == Triple (1.f, 1.f, 1.f));
@ -329,7 +330,7 @@ main (int argc, char **argv)
{
Triple tent (0.5f, 0.5f, 1.f);
Triple axis_range (0.5f, 0.5f, 1.f);
result_t out = rebase_tent (tent, axis_range);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 2);
assert (out[0].first == 1.f);
assert (out[0].second == Triple ());
@ -340,7 +341,7 @@ main (int argc, char **argv)
{
Triple tent (0.25f, 0.5f, 1.f);
Triple axis_range (0.5f, 0.5f, 1.f);
result_t out = rebase_tent (tent, axis_range);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 2);
assert (out[0].first == 1.f);
assert (out[0].second == Triple ());
@ -351,7 +352,7 @@ main (int argc, char **argv)
{
Triple tent (0.f, 0.2f, 1.f);
Triple axis_range (0.f, 0.f, 0.5f);
result_t out = rebase_tent (tent, axis_range);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 1);
assert (out[0].first == 1.f);
assert (out[0].second == Triple (0.f, 0.4f, 32767/(float) (1 << 14)));
@ -361,7 +362,7 @@ main (int argc, char **argv)
{
Triple tent (0.f, 0.5f, 1.f);
Triple axis_range (-1.f, 0.25f, 1.f);
result_t out = rebase_tent (tent, axis_range);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 5);
assert (out[0].first == 0.5f);
assert (out[0].second == Triple ());
@ -378,7 +379,7 @@ main (int argc, char **argv)
{
Triple tent (0.5f, 0.5f, 0.5f);
Triple axis_range (0.f, 0.5f, 1.f);
result_t out = rebase_tent (tent, axis_range);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 5);
assert (out[0].first == 1.f);
assert (out[0].second == Triple ());
@ -391,5 +392,24 @@ main (int argc, char **argv)
assert (out[4].first == -1.f);
assert (out[4].second == Triple (-1.f, -1.f, -2/(float) (1 << 14)));
}
{
Triple tent (0.f, 1.f, 1.f);
Triple axis_range (-1.f, -0.5f, 1.f);
result_t out = rebase_tent (tent, axis_range, default_axis_distances);
assert (out.length == 1);
assert (out[0].first == 1.f);
assert (out[0].second == Triple (1.f/3, 1.f, 1.f));
}
{
Triple tent (0.f, 1.f, 1.f);
Triple axis_range (-1.f, -0.5f, 1.f);
TripleDistances axis_distances{2.f, 1.f};
result_t out = rebase_tent (tent, axis_range, axis_distances);
assert (out.length == 1);
assert (out[0].first == 1.f);
assert (out[0].second == Triple (0.5f, 1.f, 1.f));
}
}

@ -80,7 +80,10 @@ test_decompile_cvar ()
hb_hashmap_t<hb_tag_t, Triple> normalized_axes_location;
normalized_axes_location.set (axis_tag, Triple (-0.512817f, 0.f, 0.700012f));
tuple_variations.change_tuple_variations_axis_limits (&normalized_axes_location);
hb_hashmap_t<hb_tag_t, TripleDistances> axes_triple_distances;
axes_triple_distances.set (axis_tag, TripleDistances (1.f, 1.f));
tuple_variations.change_tuple_variations_axis_limits (normalized_axes_location, axes_triple_distances);
tuple_variations.merge_tuple_variations ();
assert (tuple_variations.tuple_vars[0].indices.length == 65);

Loading…
Cancel
Save