From 2cfa55056cdbcaf724971f26d098fc118fd3f81b Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Wed, 27 Mar 2024 23:21:57 +0000 Subject: [PATCH] [instancer] Switch to doubles for delta calculations. FontTools uses double's internally so match FontTool's precision so we get the same results more often for floating point calculations. --- src/hb-algs.hh | 4 + src/hb-ot-os2-table.hh | 2 +- src/hb-ot-post-table.hh | 2 +- src/hb-ot-stat-table.hh | 3 +- src/hb-ot-var-common.hh | 52 +-- src/hb-ot-var-fvar-table.hh | 7 +- src/hb-subset-instancer-solver.cc | 76 ++-- src/hb-subset-instancer-solver.hh | 24 +- src/test-subset-instancer-solver.cc | 390 +++++++++--------- src/test-tuple-varstore.cc | 22 +- ...ht=200-300-500,wdth=80-90.iup_optimize.ttf | Bin 8684 -> 8684 bytes ...-codepoint.wght=200-300-500,wdth=80-90.ttf | Bin 8708 -> 8708 bytes ...ht=200-300-500,wdth=80-90.iup_optimize.ttf | Bin 7516 -> 7516 bytes ...-codepoint.wght=200-300-500,wdth=80-90.ttf | Bin 7568 -> 7568 bytes .../data/tests/glyf_partial_instancing.tests | 4 - 15 files changed, 295 insertions(+), 291 deletions(-) diff --git a/src/hb-algs.hh b/src/hb-algs.hh index efa6074a4..b02793a09 100644 --- a/src/hb-algs.hh +++ b/src/hb-algs.hh @@ -202,8 +202,12 @@ struct BEInt /* Floats. */ /* We want our rounding towards +infinity. */ +static inline double +_hb_roundf (double x) { return floor (x + .5); } + static inline float _hb_roundf (float x) { return floorf (x + .5f); } + #define roundf(x) _hb_roundf(x) diff --git a/src/hb-ot-os2-table.hh b/src/hb-ot-os2-table.hh index 43b58d9bb..6c9140226 100644 --- a/src/hb-ot-os2-table.hh +++ b/src/hb-ot-os2-table.hh @@ -272,7 +272,7 @@ struct OS2 Triple *axis_range; if (c->plan->user_axes_location.has (HB_TAG ('w','g','h','t'), &axis_range)) { - unsigned weight_class = static_cast (roundf (hb_clamp (axis_range->middle, 1.0f, 1000.0f))); + unsigned weight_class = static_cast (roundf (hb_clamp (axis_range->middle, 1.0, 1000.0))); if (os2_prime->usWeightClass != weight_class) os2_prime->usWeightClass = weight_class; } diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh index 8132dcfb9..419187903 100644 --- a/src/hb-ot-post-table.hh +++ b/src/hb-ot-post-table.hh @@ -116,7 +116,7 @@ struct post Triple *axis_range; if (c->plan->user_axes_location.has (HB_TAG ('s','l','n','t'), &axis_range)) { - float italic_angle = hb_max (-90.f, hb_min (axis_range->middle, 90.f)); + float italic_angle = hb_max (-90.0, hb_min (axis_range->middle, 90.0)); if (post_prime->italicAngle.to_float () != italic_angle) post_prime->italicAngle.set_float (italic_angle); } diff --git a/src/hb-ot-stat-table.hh b/src/hb-ot-stat-table.hh index e88c82a13..ea5459ef4 100644 --- a/src/hb-ot-stat-table.hh +++ b/src/hb-ot-stat-table.hh @@ -63,8 +63,9 @@ static bool axis_value_is_outside_axis_range (hb_tag_t axis_tag, float axis_valu if (!user_axes_location->has (axis_tag)) return false; + double axis_value_double = static_cast(axis_value); Triple axis_range = user_axes_location->get (axis_tag); - return (axis_value < axis_range.minimum || axis_value > axis_range.maximum); + return (axis_value_double < axis_range.minimum || axis_value_double > axis_range.maximum); } struct StatAxisRecord diff --git a/src/hb-ot-var-common.hh b/src/hb-ot-var-common.hh index 379e16405..481b1af03 100644 --- a/src/hb-ot-var-common.hh +++ b/src/hb-ot-var-common.hh @@ -305,7 +305,7 @@ struct TupleVariationHeader return true; } - float calculate_scalar (hb_array_t coords, unsigned int coord_count, + double calculate_scalar (hb_array_t coords, unsigned int coord_count, const hb_array_t shared_tuples, const hb_vector_t> *shared_tuple_active_idx = nullptr) const { @@ -321,13 +321,13 @@ struct TupleVariationHeader { unsigned int index = get_index (); if (unlikely ((index + 1) * coord_count > shared_tuples.length)) - return 0.f; + return 0.0; peak_tuple = shared_tuples.sub_array (coord_count * index, coord_count).arrayZ; if (shared_tuple_active_idx) { if (unlikely (index >= shared_tuple_active_idx->length)) - return 0.f; + return 0.0; auto _ = (*shared_tuple_active_idx).arrayZ[index]; if (_.second != -1) { @@ -352,7 +352,7 @@ struct TupleVariationHeader end_tuple = get_end_tuple (coord_count).arrayZ; } - float scalar = 1.f; + double scalar = 1.0; for (unsigned int i = start_idx; i < end_idx; i += step) { int peak = peak_tuple[i].to_int (); @@ -367,15 +367,15 @@ struct TupleVariationHeader int end = end_tuple[i].to_int (); if (unlikely (start > peak || peak > end || (start < 0 && end > 0 && peak))) continue; - if (v < start || v > end) return 0.f; + if (v < start || v > end) return 0.0; if (v < peak) - { if (peak != start) scalar *= (float) (v - start) / (peak - start); } + { if (peak != start) scalar *= (double) (v - start) / (peak - start); } else - { if (peak != end) scalar *= (float) (end - v) / (end - peak); } + { if (peak != end) scalar *= (double) (end - v) / (end - peak); } } - else if (!v || v < hb_min (0, peak) || v > hb_max (0, peak)) return 0.f; + else if (!v || v < hb_min (0, peak) || v > hb_max (0, peak)) return 0.0; else - scalar *= (float) v / peak; + scalar *= (double) v / peak; } return scalar; } @@ -445,9 +445,9 @@ struct tuple_delta_t /* indices_length = point_count, indice[i] = 1 means point i is referenced */ hb_vector_t indices; - hb_vector_t deltas_x; + hb_vector_t deltas_x; /* empty for cvar tuples */ - hb_vector_t deltas_y; + hb_vector_t deltas_y; /* compiled data: header and deltas * compiled point data is saved in a hashmap within tuple_variations_t cause @@ -513,9 +513,9 @@ struct tuple_delta_t return *this; } - tuple_delta_t& operator *= (float scalar) + tuple_delta_t& operator *= (double scalar) { - if (scalar == 1.0f) + if (scalar == 1.0) return *this; unsigned num = indices.length; @@ -546,11 +546,11 @@ struct tuple_delta_t return out; } - if ((tent->minimum < 0.f && tent->maximum > 0.f) || + if ((tent->minimum < 0.0 && tent->maximum > 0.0) || !(tent->minimum <= tent->middle && tent->middle <= tent->maximum)) return out; - if (tent->middle == 0.f) + if (tent->middle == 0.0) { out.push (*this); return out; @@ -729,8 +729,8 @@ struct tuple_delta_t { return compile_deltas (indices, deltas_x, deltas_y, compiled_deltas); } bool compile_deltas (const hb_vector_t &point_indices, - const hb_vector_t &x_deltas, - const hb_vector_t &y_deltas, + const hb_vector_t &x_deltas, + const hb_vector_t &y_deltas, hb_vector_t &compiled_deltas /* OUT */) { hb_vector_t rounded_deltas; @@ -1020,8 +1020,8 @@ struct tuple_delta_t { if (!inferred_idxes.has (i)) { - deltas_x.arrayZ[i] = 0.f; - deltas_y.arrayZ[i] = 0.f; + deltas_x.arrayZ[i] = 0.0; + deltas_y.arrayZ[i] = 0.0; } indices[i] = true; } @@ -1062,7 +1062,7 @@ struct tuple_delta_t if (ref_count == count) return true; - hb_vector_t opt_deltas_x, opt_deltas_y; + hb_vector_t opt_deltas_x, opt_deltas_y; bool is_comp_glyph_wo_deltas = (is_composite && ref_count == 0); if (is_comp_glyph_wo_deltas) { @@ -1194,16 +1194,16 @@ struct tuple_delta_t return compiled_points.resize (pos, false); } - static float infer_delta (float target_val, float prev_val, float next_val, float prev_delta, float next_delta) + static double infer_delta (double target_val, double prev_val, double next_val, double prev_delta, double next_delta) { if (prev_val == next_val) - return (prev_delta == next_delta) ? prev_delta : 0.f; + return (prev_delta == next_delta) ? prev_delta : 0.0; else if (target_val <= hb_min (prev_val, next_val)) return (prev_val < next_val) ? prev_delta : next_delta; else if (target_val >= hb_max (prev_val, next_val)) return (prev_val > next_val) ? prev_delta : next_delta; - float r = (target_val - prev_val) / (next_val - prev_val); + double r = (target_val - prev_val) / (next_val - prev_val); return prev_delta + r * (next_delta - prev_delta); } @@ -1347,9 +1347,9 @@ struct TupleVariationData unsigned idx = apply_to_all ? i : indices[i]; if (idx >= point_count) continue; var.indices[idx] = true; - var.deltas_x[idx] = static_cast (deltas_x[i]); + var.deltas_x[idx] = deltas_x[i]; if (is_gvar) - var.deltas_y[idx] = static_cast (deltas_y[i]); + var.deltas_y[idx] = deltas_y[i]; } tuple_vars.push (std::move (var)); } while (iterator.move_to_next ()); @@ -1425,7 +1425,7 @@ struct TupleVariationData Triple *axis_limit; if (!normalized_axes_location.has (axis_tag, &axis_limit)) return false; - TripleDistances axis_triple_distances{1.f, 1.f}; + TripleDistances axis_triple_distances{1.0, 1.0}; if (axes_triple_distances.has (axis_tag)) axis_triple_distances = axes_triple_distances.get (axis_tag); diff --git a/src/hb-ot-var-fvar-table.hh b/src/hb-ot-var-fvar-table.hh index 07d7586ba..2cd9afbb7 100644 --- a/src/hb-ot-var-fvar-table.hh +++ b/src/hb-ot-var-fvar-table.hh @@ -43,7 +43,7 @@ static bool axis_coord_pinned_or_within_axis_range (const hb_array_t(coords[axis_index].to_float ()); if (axis_limit.is_point ()) { if (axis_limit.minimum != axis_coord) @@ -233,7 +233,10 @@ struct AxisRecord { float min, default_, max; get_coordinates (min, default_, max); - return TripleDistances (min, default_, max); + return TripleDistances ( + static_cast(min), + static_cast(default_), + static_cast(max)); } bool subset (hb_subset_context_t *c) const diff --git a/src/hb-subset-instancer-solver.cc b/src/hb-subset-instancer-solver.cc index 70783c0a0..7eb3d51ff 100644 --- a/src/hb-subset-instancer-solver.cc +++ b/src/hb-subset-instancer-solver.cc @@ -32,17 +32,17 @@ * This should be safe. */ -constexpr static float EPSILON = 1.f / (1 << 14); -constexpr static float MAX_F2DOT14 = float (0x7FFF) / (1 << 14); +constexpr static double EPSILON = 1.0 / (1 << 14); +constexpr static double MAX_F2DOT14 = double (0x7FFF) / (1 << 14); static inline Triple _reverse_negate(const Triple &v) { return {-v.maximum, -v.middle, -v.minimum}; } -static inline float supportScalar (float coord, const Triple &tent) +static inline double supportScalar (double coord, const Triple &tent) { /* Copied from VarRegionAxis::evaluate() */ - float start = tent.minimum, peak = tent.middle, end = tent.maximum; + double start = tent.minimum, peak = tent.middle, end = tent.maximum; if (unlikely (start > peak || peak > end)) return 1.; @@ -65,12 +65,12 @@ static inline float supportScalar (float coord, const Triple &tent) static inline result_t _solve (Triple tent, Triple axisLimit, bool negative = false) { - float axisMin = axisLimit.minimum; - float axisDef = axisLimit.middle; - float axisMax = axisLimit.maximum; - float lower = tent.minimum; - float peak = tent.middle; - float upper = tent.maximum; + double axisMin = axisLimit.minimum; + double axisDef = axisLimit.middle; + double axisMax = axisLimit.maximum; + double lower = tent.minimum; + double peak = tent.middle; + double upper = tent.maximum; // Mirror the problem such that axisDef <= peak if (axisDef > peak) @@ -130,7 +130,7 @@ _solve (Triple tent, Triple axisLimit, bool negative = false) */ if (axisMax < peak) { - float mult = supportScalar (axisMax, tent); + double mult = supportScalar (axisMax, tent); tent = Triple{lower, axisMax, axisMax}; result_t vec = _solve (tent, axisLimit); @@ -143,13 +143,13 @@ _solve (Triple tent, Triple axisLimit, bool negative = false) // lower <= axisDef <= peak <= axisMax - float gain = supportScalar (axisDef, tent); + double gain = supportScalar (axisDef, tent); result_t out {hb_pair (gain, Triple{})}; // First, the positive side // outGain is the scalar of axisMax at the tent. - float outGain = supportScalar (axisMax, tent); + double outGain = supportScalar (axisMax, tent); /* Case 3a: Gain is more than outGain. The tent down-slope crosses * the axis into negative. We have to split it into multiples. @@ -173,10 +173,10 @@ _solve (Triple tent, Triple axisLimit, bool negative = false) // Note that this is the branch taken if both gain and outGain are 0. // Crossing point on the axis. - float crossing = peak + (1 - gain) * (upper - peak); + double crossing = peak + (1 - gain) * (upper - peak); Triple loc{hb_max (lower, axisDef), peak, crossing}; - float scalar = 1.f; + double scalar = 1.0; // The part before the crossing point. out.push (hb_pair (scalar - gain, loc)); @@ -191,7 +191,7 @@ _solve (Triple tent, Triple axisLimit, bool negative = false) if (upper >= axisMax) { Triple loc {crossing, axisMax, axisMax}; - float scalar = outGain; + double scalar = outGain; out.push (hb_pair (scalar - gain, loc)); } @@ -221,11 +221,11 @@ _solve (Triple tent, Triple axisLimit, bool negative = false) // Downslope. Triple loc1 {crossing, upper, axisMax}; - float scalar1 = 0.f; + double scalar1 = 0.0; // Eternity justify. Triple loc2 {upper, axisMax, axisMax}; - float scalar2 = 0.f; + double scalar2 = 0.0; out.push (hb_pair (scalar1 - gain, loc1)); out.push (hb_pair (scalar2 - gain, loc2)); @@ -254,7 +254,7 @@ _solve (Triple tent, Triple axisLimit, bool negative = false) * | | newUpper * axisDef axisMax */ - float newUpper = peak + (1 - gain) * (upper - peak); + double newUpper = peak + (1 - gain) * (upper - peak); assert (axisMax <= newUpper); // Because outGain > gain /* Disabled because ots doesn't like us: * https://github.com/fonttools/fonttools/issues/3350 */ @@ -270,7 +270,7 @@ _solve (Triple tent, Triple axisLimit, bool negative = false) } Triple loc {hb_max (axisDef, lower), peak, upper}; - float scalar = 1.f; + double scalar = 1.0; out.push (hb_pair (scalar - gain, loc)); } @@ -294,10 +294,10 @@ _solve (Triple tent, Triple axisLimit, bool negative = false) else { Triple loc1 {hb_max (axisDef, lower), peak, axisMax}; - float scalar1 = 1.f; + double scalar1 = 1.0; Triple loc2 {peak, axisMax, axisMax}; - float scalar2 = outGain; + double scalar2 = outGain; out.push (hb_pair (scalar1 - gain, loc1)); // Don't add a dirac delta! @@ -325,7 +325,7 @@ _solve (Triple tent, Triple axisLimit, bool negative = false) if (lower <= axisMin) { Triple loc {axisMin, axisMin, axisDef}; - float scalar = supportScalar (axisMin, tent); + double scalar = supportScalar (axisMin, tent); out.push (hb_pair (scalar - gain, loc)); } @@ -353,11 +353,11 @@ _solve (Triple tent, Triple axisLimit, bool negative = false) // Downslope. Triple loc1 {axisMin, lower, axisDef}; - float scalar1 = 0.f; + double scalar1 = 0.0; // Eternity justify. Triple loc2 {axisMin, axisMin, lower}; - float scalar2 = 0.f; + double scalar2 = 0.0; out.push (hb_pair (scalar1 - gain, loc1)); out.push (hb_pair (scalar2 - gain, loc2)); @@ -369,19 +369,19 @@ _solve (Triple tent, Triple axisLimit, bool negative = 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) +double renormalizeValue (double v, const Triple &triple, + const TripleDistances &triple_distances, bool extrapolate) { - float lower = triple.minimum, def = triple.middle, upper = triple.maximum; + double 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) - return 0.f; + return 0.0; - if (def < 0.f) + if (def < 0.0) return -renormalizeValue (-v, _reverse_negate (triple), _reverse_triple_distances (triple_distances), extrapolate); @@ -390,14 +390,14 @@ float renormalizeValue (float v, const Triple &triple, return (v - def) / (upper - def); /* v < def */ - if (lower >= 0.f) + if (lower >= 0.0) return (v - def) / (def - lower); /* lower < 0 and v < default */ - float total_distance = triple_distances.negative * (-lower) + triple_distances.positive * def; + double total_distance = triple_distances.negative * (-lower) + triple_distances.positive * def; - float v_distance; - if (v >= 0.f) + double v_distance; + if (v >= 0.0) v_distance = (def - v) * triple_distances.positive; else v_distance = (-v) * triple_distances.negative + triple_distances.positive * def; @@ -408,13 +408,13 @@ float renormalizeValue (float v, const Triple &triple, result_t 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); - assert (tent.middle != 0.f); + assert (-1.0 <= axisLimit.minimum && axisLimit.minimum <= axisLimit.middle && axisLimit.middle <= axisLimit.maximum && axisLimit.maximum <= +1.0); + assert (-2.0 <= tent.minimum && tent.minimum <= tent.middle && tent.middle <= tent.maximum && tent.maximum <= +2.0); + assert (tent.middle != 0.0); result_t sols = _solve (tent, axisLimit); - auto n = [&axisLimit, &axis_triple_distances] (float v) { return renormalizeValue (v, axisLimit, axis_triple_distances); }; + auto n = [&axisLimit, &axis_triple_distances] (double v) { return renormalizeValue (v, axisLimit, axis_triple_distances); }; result_t out; for (auto &p : sols) diff --git a/src/hb-subset-instancer-solver.hh b/src/hb-subset-instancer-solver.hh index 563fccbb5..09daa242e 100644 --- a/src/hb-subset-instancer-solver.hh +++ b/src/hb-subset-instancer-solver.hh @@ -31,23 +31,23 @@ 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) + TripleDistances (double neg_, double pos_): negative (neg_), positive (pos_) {} + TripleDistances (double min, double default_, double max) { negative = default_ - min; positive = max - default_; } - float negative; - float positive; + double negative; + double positive; }; struct Triple { Triple () : - minimum (0.f), middle (0.f), maximum (0.f) {} + minimum (0.0), middle (0.0), maximum (0.0) {} - Triple (float minimum_, float middle_, float maximum_) : + Triple (double minimum_, double middle_, double maximum_) : minimum (minimum_), middle (middle_), maximum (maximum_) {} bool operator == (const Triple &o) const @@ -63,7 +63,7 @@ struct Triple { bool is_point () const { return minimum == middle && middle == maximum; } - bool contains (float point) const + bool contains (double point) const { return minimum <= point && point <= maximum; } /* from hb_array_t hash ()*/ @@ -82,18 +82,18 @@ struct Triple { } - float minimum; - float middle; - float maximum; + double minimum; + double middle; + double maximum; }; -using result_item_t = hb_pair_t; +using result_item_t = hb_pair_t; using result_t = hb_vector_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, +HB_INTERNAL double renormalizeValue (double v, const Triple &triple, const TripleDistances &triple_distances, bool extrapolate = true); /* Given a tuple (lower,peak,upper) "tent" and new axis limits diff --git a/src/test-subset-instancer-solver.cc b/src/test-subset-instancer-solver.cc index c7cba3415..5814c1938 100644 --- a/src/test-subset-instancer-solver.cc +++ b/src/test-subset-instancer-solver.cc @@ -24,408 +24,408 @@ * Google Author(s): Qunxin Liu */ +#include #include "hb-subset-instancer-solver.hh" static inline bool approx (Triple a, Triple b) { - return fabsf (a.minimum - b.minimum) < 0.000001f && - fabsf (a.middle - b.middle) < 0.000001f && - fabsf (a.maximum - b.maximum) < 0.000001f; + return abs (a.minimum - b.minimum) < 0.000001 && + abs (a.middle - b.middle) < 0.000001 && + abs (a.maximum - b.maximum) < 0.000001; } -static inline bool approx (float a, float b) -{ return fabsf (a - b) < 0.000001f; } +static inline bool approx (double a, double b) +{ return abs (a - b) < 0.000001; } /* tests ported from * https://github.com/fonttools/fonttools/blob/main/Tests/varLib/instancer/solver_test.py */ int main (int argc, char **argv) { - TripleDistances default_axis_distances{1.f, 1.f}; + TripleDistances default_axis_distances{1.0, 1.0}; /* Case 1 */ { /* pin axis*/ - Triple tent (0.f, 1.f, 1.f); - Triple axis_range (0.f, 0.f, 0.f); + Triple tent (0.0, 1.0, 1.0); + Triple axis_range (0.0, 0.0, 0.0); result_t out = rebase_tent (tent, axis_range, default_axis_distances); assert (out.length == 0); } { /* pin axis*/ - Triple tent (0.f, 1.f, 1.f); - Triple axis_range (0.5f, 0.5f, 0.5f); + Triple tent (0.0, 1.0, 1.0); + Triple axis_range (0.5, 0.5, 0.5); result_t out = rebase_tent (tent, axis_range, default_axis_distances); assert (out.length == 1); - assert (out[0].first == 0.5f); + assert (out[0].first == 0.5); assert (out[0].second == Triple ()); } { /* tent falls outside the new axis range */ - Triple tent (0.3f, 0.5f, 0.8f); - Triple axis_range (0.1f, 0.2f, 0.3f); + Triple tent (0.3, 0.5, 0.8); + Triple axis_range (0.1, 0.2, 0.3); result_t out = rebase_tent (tent, axis_range, default_axis_distances); assert (out.length == 0); } /* Case 2 */ { - Triple tent (0.f, 1.f, 1.f); - Triple axis_range (-1.f, 0.f, 0.5f); + Triple tent (0.0, 1.0, 1.0); + Triple axis_range (-1.0, 0.0, 0.5); 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)); + assert (out[0].first == 0.5); + assert (out[0].second == Triple (0.0, 1.0, 1.0)); } /* Case 2 */ { - Triple tent (0.f, 1.f, 1.f); - Triple axis_range (-1.f, 0.f, 0.75f); + Triple tent (0.0, 1.0, 1.0); + Triple axis_range (-1.0, 0.0, 0.75); 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)); + assert (out[0].first == 0.75); + assert (out[0].second == Triple (0.0, 1.0, 1.0)); } /* Without gain: */ /* Case 3 */ { - Triple tent (0.f, 0.2f, 1.f); - Triple axis_range (-1.f, 0.f, 0.8f); + Triple tent (0.0, 0.2, 1.0); + Triple axis_range (-1.0, 0.0, 0.8); 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.25f, 1.f)); - assert (approx (out[1].first, 0.25f)); - assert (out[1].second == Triple (0.25f, 1.f, 1.f)); + assert (out[0].first == 1.0); + assert (out[0].second == Triple (0.0, 0.25, 1.0)); + assert (approx (out[1].first, 0.250)); + assert (out[1].second == Triple (0.25, 1.0, 1.0)); } /* Case 3 boundary */ { - Triple tent (0.f, 0.4f, 1.f); - Triple axis_range (-1.f, 0.f, 0.5f); + Triple tent (0.0, 0.4, 1.0); + Triple axis_range (-1.0, 0.0, 0.5); 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.8f, 1.f)); - assert (approx (out[1].first, 2.5f/3)); - assert (out[1].second == Triple (0.8f, 1.f, 1.f)); + assert (out[0].first == 1.0); + assert (out[0].second == Triple (0.0, 0.8, 1.0)); + assert (approx (out[1].first, 2.5/3)); + assert (out[1].second == Triple (0.8, 1.0, 1.0)); } /* Case 4 */ { - Triple tent (0.f, 0.25f, 1.f); - Triple axis_range (-1.f, 0.f, 0.4f); + Triple tent (0.0, 0.25, 1.0); + Triple axis_range (-1.0, 0.0, 0.4); 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)); - assert (approx (out[1].first, 0.8f)); - assert (out[1].second == Triple (0.625f, 1.f, 1.f)); + assert (out[0].first == 1.0); + assert (out[0].second == Triple (0.0, 0.625, 1.0)); + assert (approx (out[1].first, 0.80)); + assert (out[1].second == Triple (0.625, 1.0, 1.0)); } /* Case 4 */ { - Triple tent (0.25f, 0.3f, 1.05f); - Triple axis_range (0.f, 0.2f, 0.4f); + Triple tent (0.25, 0.3, 1.05); + Triple axis_range (0.0, 0.2, 0.4); 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))); - assert (approx (out[1].first, 2.6f/3)); - assert (approx (out[1].second, Triple (0.5f, 1.f, 1.f))); + assert (out[0].first == 1.0); + assert (approx (out[0].second, Triple (0.25, 0.5, 1.0))); + assert (approx (out[1].first, 2.6 / 3)); + assert (approx (out[1].second, Triple (0.5, 1.0, 1.0))); } /* Case 4 boundary */ { - Triple tent (0.25f, 0.5f, 1.f); - Triple axis_range (0.f, 0.25f, 0.5f); + Triple tent (0.25, 0.5, 1.0); + Triple axis_range (0.0, 0.25, 0.5); 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)); + assert (out[0].first == 1.0); + assert (out[0].second == Triple (0.0, 1.0, 1.0)); } /* With gain */ /* Case 3a/1neg */ { - Triple tent (0.f, 0.5f, 1.f); - Triple axis_range (0.f, 0.5f, 1.f); + Triple tent (0.0, 0.5, 1.0); + Triple axis_range (0.0, 0.5, 1.0); result_t out = rebase_tent (tent, axis_range, default_axis_distances); assert (out.length == 3); - assert (out[0].first == 1.f); + assert (out[0].first == 1.0); assert (out[0].second == Triple ()); - assert (out[1].first == -1.f); - assert (out[1].second == Triple (0.f, 1.f, 1.f)); - assert (out[2].first == -1.f); - assert (out[2].second == Triple (-1.f, -1.f, 0.f)); + assert (out[1].first == -1.0); + assert (out[1].second == Triple (0.0, 1.0, 1.0)); + assert (out[2].first == -1.0); + assert (out[2].second == Triple (-1.0, -1.0, 0.0)); } { - Triple tent (0.f, 0.5f, 1.f); - Triple axis_range (0.f, 0.5f, 0.75f); + Triple tent (0.0, 0.5, 1.0); + Triple axis_range (0.0, 0.5, 0.75); result_t out = rebase_tent (tent, axis_range, default_axis_distances); assert (out.length == 3); - assert (out[0].first == 1.f); + assert (out[0].first == 1.0); assert (out[0].second == Triple ()); - assert (out[1].first == -0.5f); - assert (out[1].second == Triple (0.f, 1.f, 1.f)); - assert (out[2].first == -1.f); - assert (out[2].second == Triple (-1.f, -1.f, 0.f)); + assert (out[1].first == -0.5); + assert (out[1].second == Triple (0.0, 1.0, 1.0)); + assert (out[2].first == -1.0); + assert (out[2].second == Triple (-1.0, -1.0, 0.0)); } { - Triple tent (0.f, 0.5f, 1.f); - Triple axis_range (0.f, 0.25f, 0.8f); + Triple tent (0.0, 0.50, 1.0); + Triple axis_range (0.0, 0.25, 0.8); result_t out = rebase_tent (tent, axis_range, default_axis_distances); assert (out.length == 4); - assert (out[0].first == 0.5f); + assert (out[0].first == 0.5); assert (out[0].second == Triple ()); - assert (out[1].first == 0.5f); - assert (approx (out[1].second, Triple (0.f, 0.454545f, 0.909091f))); - assert (approx (out[2].first, -0.1f)); - assert (approx (out[2].second, Triple (0.909091f, 1.f, 1.f))); - assert (out[3].first == -0.5f); - assert (out[3].second == Triple (-1.f, -1.f, 0.f)); + assert (out[1].first == 0.5); + assert (approx (out[1].second, Triple (0.0, 0.454545, 0.909091))); + assert (approx (out[2].first, -0.1)); + assert (approx (out[2].second, Triple (0.909091, 1.0, 1.0))); + assert (out[3].first == -0.5); + assert (out[3].second == Triple (-1.0, -1.0, 0.0)); } /* Case 3a/1neg */ { - Triple tent (0.f, 0.5f, 2.f); - Triple axis_range (0.2f, 0.5f, 0.8f); + Triple tent (0.0, 0.5, 2.0); + Triple axis_range (0.2, 0.5, 0.8); result_t out = rebase_tent (tent, axis_range, default_axis_distances); assert (out.length == 3); - assert (out[0].first == 1.f); + assert (out[0].first == 1.0); assert (out[0].second == Triple ()); - assert (approx (out[1].first, -0.2f)); - assert (out[1].second == Triple (0.f, 1.f, 1.f)); - assert (approx (out[2].first, -0.6f)); - assert (out[2].second == Triple (-1.f, -1.f, 0.f)); + assert (approx (out[1].first, -0.2)); + assert (out[1].second == Triple (0.0, 1.0, 1.0)); + assert (approx (out[2].first, -0.6)); + assert (out[2].second == Triple (-1.0, -1.0, 0.0)); } /* Case 3a/1neg */ { - Triple tent (0.f, 0.5f, 2.f); - Triple axis_range (0.2f, 0.5f, 1.f); + Triple tent (0.0, 0.5, 2.0); + Triple axis_range (0.2, 0.5, 1.0); result_t out = rebase_tent (tent, axis_range, default_axis_distances); assert (out.length == 3); - assert (out[0].first == 1.f); + assert (out[0].first == 1.0); assert (out[0].second == Triple ()); - assert (approx (out[1].first, -1.f/3)); - assert (out[1].second == Triple (0.f, 1.f, 1.f)); - assert (approx (out[2].first, -0.6f)); - assert (out[2].second == Triple (-1.f, -1.f, 0.f)); + assert (approx (out[1].first, -1.0/3)); + assert (out[1].second == Triple (0.0, 1.0, 1.0)); + assert (approx (out[2].first, -0.6)); + assert (out[2].second == Triple (-1.0, -1.0, 0.0)); } /* Case 3 */ { - Triple tent (0.f, 0.5f, 1.f); - Triple axis_range (0.25f, 0.25f, 0.75f); + Triple tent (0.0, 0.5, 1.0); + Triple axis_range (0.25, 0.25, 0.75); result_t out = rebase_tent (tent, axis_range, default_axis_distances); assert (out.length == 2); - assert (out[0].first == 0.5f); + assert (out[0].first == 0.5); assert (out[0].second == Triple ()); - assert (out[1].first == 0.5f); - assert (out[1].second == Triple (0.f, 0.5f, 1.0f)); + assert (out[1].first == 0.5); + assert (out[1].second == Triple (0.0, 0.5, 1.0)); } /* Case 1neg */ { - Triple tent (0.f, 0.5f, 1.f); - Triple axis_range (0.f, 0.25f, 0.5f); + Triple tent (0.0, 0.5, 1.0); + Triple axis_range (0.0, 0.25, 0.5); result_t out = rebase_tent (tent, axis_range, default_axis_distances); assert (out.length == 3); - assert (out[0].first == 0.5f); + assert (out[0].first == 0.5); assert (out[0].second == Triple ()); - assert (out[1].first == 0.5f); - assert (out[1].second == Triple (0.f, 1.f, 1.f)); - assert (out[2].first == -0.5f); - assert (out[2].second == Triple (-1.f, -1.f, 0.f)); + assert (out[1].first == 0.5); + assert (out[1].second == Triple (0.0, 1.0, 1.0)); + assert (out[2].first == -0.5); + assert (out[2].second == Triple (-1.0, -1.0, 0.0)); } /* Case 2neg */ { - Triple tent (0.05f, 0.55f, 1.f); - Triple axis_range (0.f, 0.25f, 0.5f); + Triple tent (0.05, 0.55, 1.0); + Triple axis_range (0.0, 0.25, 0.5); result_t out = rebase_tent (tent, axis_range, default_axis_distances); assert (out.length == 4); - assert (approx (out[0].first, 0.4f)); + assert (approx (out[0].first, 0.4)); assert (out[0].second == Triple ()); - assert (approx (out[1].first, 0.5f)); - assert (out[1].second == Triple (0.f, 1.f, 1.f)); - assert (approx (out[2].first, -0.4f)); - assert (out[2].second == Triple (-1.f, -0.8f, 0.f)); - assert (approx (out[3].first, -0.4f)); - assert (out[3].second == Triple (-1.f, -1.f, -0.8f)); + assert (approx (out[1].first, 0.5)); + assert (out[1].second == Triple (0.0, 1.0, 1.0)); + assert (approx (out[2].first, -0.4)); + assert (out[2].second == Triple (-1.0, -0.8, 0.0)); + assert (approx (out[3].first, -0.4)); + assert (out[3].second == Triple (-1.0, -1.0, -0.8)); } /* Case 2neg, other side */ { - Triple tent (-1.f, -0.55f, -0.05f); - Triple axis_range (-0.5f, -0.25f, 0.f); + Triple tent (-1.0, -0.55, -0.05); + Triple axis_range (-0.5, -0.25, 0.0); result_t out = rebase_tent (tent, axis_range, default_axis_distances); assert (out.length == 4); - assert (approx (out[0].first, 0.4f)); + assert (approx (out[0].first, 0.4)); assert (out[0].second == Triple ()); - assert (approx (out[1].first, 0.5f)); - assert (out[1].second == Triple (-1.f, -1.f, 0.f)); - assert (approx (out[2].first, -0.4f)); - assert (out[2].second == Triple (0.f, 0.8f, 1.f)); - assert (approx (out[3].first, -0.4f)); - assert (out[3].second == Triple (0.8f, 1.f, 1.f)); + assert (approx (out[1].first, 0.5)); + assert (out[1].second == Triple (-1.0, -1.0, 0.0)); + assert (approx (out[2].first, -0.4)); + assert (out[2].second == Triple (0.0, 0.8, 1.0)); + assert (approx (out[3].first, -0.4)); + assert (out[3].second == Triple (0.8, 1.0, 1.0)); } /* Misc corner cases */ { - Triple tent (0.5f, 0.5f, 0.5f); - Triple axis_range (0.5f, 0.5f, 0.5f); + Triple tent (0.5, 0.5, 0.5); + Triple axis_range (0.5, 0.5, 0.5); result_t out = rebase_tent (tent, axis_range, default_axis_distances); assert (out.length == 1); - assert (out[0].first == 1.f); + assert (out[0].first == 1.0); assert (out[0].second == Triple ()); } { - Triple tent (0.3f, 0.5f, 0.7f); - Triple axis_range (0.1f, 0.5f, 0.9f); + Triple tent (0.3, 0.5, 0.7); + Triple axis_range (0.1, 0.5, 0.9); result_t out = rebase_tent (tent, axis_range, default_axis_distances); assert (out.length == 5); - assert (out[0].first == 1.f); + assert (out[0].first == 1.0); assert (out[0].second == Triple ()); - assert (out[1].first == -1.f); - assert (out[1].second == Triple (0.f, 0.5f, 1.f)); - assert (out[2].first == -1.f); - assert (out[2].second == Triple (0.5f, 1.f, 1.f)); - assert (out[3].first == -1.f); - assert (approx (out[3].second, Triple (-1.f, -0.5f, 0.f))); - assert (out[4].first == -1.f); - assert (approx (out[4].second, Triple (-1.f, -1.f, -0.5f))); + assert (out[1].first == -1.0); + assert (approx(out[1].second, Triple (0.0, 0.5, 1.0))); + assert (out[2].first == -1.0); + assert (approx(out[2].second, Triple (0.5, 1.0, 1.0))); + assert (out[3].first == -1.0); + assert (approx (out[3].second, Triple (-1.0, -0.5, 0.0))); + assert (out[4].first == -1.0); + assert (approx (out[4].second, Triple (-1.0, -1.0, -0.5))); } { - Triple tent (0.5f, 0.5f, 0.5f); - Triple axis_range (0.25f, 0.25f, 0.5f); + Triple tent (0.5, 0.5, 0.5); + Triple axis_range (0.25, 0.25, 0.5); 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)); + assert (out[0].first == 1.0); + assert (out[0].second == Triple (1.0, 1.0, 1.0)); } { - Triple tent (0.5f, 0.5f, 0.5f); - Triple axis_range (0.25f, 0.35f, 0.5f); + Triple tent (0.5, 0.5, 0.5); + Triple axis_range (0.25, 0.35, 0.5); 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)); + assert (out[0].first == 1.0); + assert (out[0].second == Triple (1.0, 1.0, 1.0)); } { - Triple tent (0.5f, 0.5f, 0.55f); - Triple axis_range (0.25f, 0.35f, 0.5f); + Triple tent (0.5, 0.5, 0.55); + Triple axis_range (0.25, 0.35, 0.5); 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)); + assert (out[0].first == 1.0); + assert (out[0].second == Triple (1.0, 1.0, 1.0)); } { - Triple tent (0.5f, 0.5f, 1.f); - Triple axis_range (0.5f, 0.5f, 1.f); + Triple tent (0.5, 0.5, 1.0); + Triple axis_range (0.5, 0.5, 1.0); result_t out = rebase_tent (tent, axis_range, default_axis_distances); assert (out.length == 2); - assert (out[0].first == 1.f); + assert (out[0].first == 1.0); assert (out[0].second == Triple ()); - assert (out[1].first == -1.f); - assert (out[1].second == Triple (0.f, 1.f, 1.f)); + assert (out[1].first == -1.0); + assert (out[1].second == Triple (0.0, 1.0, 1.0)); } { - Triple tent (0.25f, 0.5f, 1.f); - Triple axis_range (0.5f, 0.5f, 1.f); + Triple tent (0.25, 0.5, 1.0); + Triple axis_range (0.5, 0.5, 1.0); result_t out = rebase_tent (tent, axis_range, default_axis_distances); assert (out.length == 2); - assert (out[0].first == 1.f); + assert (out[0].first == 1.0); assert (out[0].second == Triple ()); - assert (out[1].first == -1.f); - assert (out[1].second == Triple (0.f, 1.f, 1.f)); + assert (out[1].first == -1.0); + assert (out[1].second == Triple (0.0, 1.0, 1.0)); } { - Triple tent (0.f, 0.2f, 1.f); - Triple axis_range (0.f, 0.f, 0.5f); + Triple tent (0.0, 0.2, 1.0); + Triple axis_range (0.0, 0.0, 0.5); 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.4f, 1.f)); - assert (out[1].first == 0.625f); - assert (out[1].second == Triple (0.4f, 1.f, 1.f)); + assert (out[0].first == 1.0); + assert (out[0].second == Triple (0.0, 0.4, 1.0)); + assert (out[1].first == 0.625); + assert (out[1].second == Triple (0.4, 1.0, 1.0)); } { - Triple tent (0.f, 0.5f, 1.f); - Triple axis_range (-1.f, 0.25f, 1.f); + Triple tent (0.0, 0.5, 1.0); + Triple axis_range (-1.0, 0.25, 1.0); result_t out = rebase_tent (tent, axis_range, default_axis_distances); assert (out.length == 5); - assert (out[0].first == 0.5f); + assert (out[0].first == 0.5); assert (out[0].second == Triple ()); - assert (out[1].first == 0.5f); - assert (out[1].second == Triple (0.f, 1.f/3, 2.f/3)); - assert (out[2].first == -0.5f); - assert (out[2].second == Triple (2.f/3, 1.f, 1.f)); - assert (out[3].first == -0.5f); - assert (out[3].second == Triple (-1.f, -0.2f, 0.f)); - assert (out[4].first == -0.5f); - assert (out[4].second == Triple (-1.f, -1.f, -0.2f)); + assert (out[1].first == 0.5); + assert (out[1].second == Triple (0.0, 1.0/3, 2.0/3)); + assert (out[2].first == -0.5); + assert (out[2].second == Triple (2.0/3, 1.0, 1.0)); + assert (out[3].first == -0.5); + assert (out[3].second == Triple (-1.0, -0.2, 0.0)); + assert (out[4].first == -0.5); + assert (out[4].second == Triple (-1.0, -1.0, -0.2)); } { - Triple tent (0.5f, 0.5f, 0.5f); - Triple axis_range (0.f, 0.5f, 1.f); + Triple tent (0.5, 0.5, 0.5); + Triple axis_range (0.0, 0.5, 1.0); result_t out = rebase_tent (tent, axis_range, default_axis_distances); assert (out.length == 5); - assert (out[0].first == 1.f); + assert (out[0].first == 1.0); assert (out[0].second == Triple ()); - assert (out[1].first == -1.f); - assert (out[1].second == Triple (0.f, 2/(float) (1 << 14), 1.f)); - assert (out[2].first == -1.f); - assert (out[2].second == Triple (2/(float) (1 << 14), 1.f, 1.f)); - assert (out[3].first == -1.f); - assert (out[3].second == Triple (-1.f, -2/(float) (1 << 14), 0.f)); - assert (out[4].first == -1.f); - assert (out[4].second == Triple (-1.f, -1.f, -2/(float) (1 << 14))); + assert (out[1].first == -1.0); + assert (out[1].second == Triple (0.0, 2/(double) (1 << 14), 1.0)); + assert (out[2].first == -1.0); + assert (out[2].second == Triple (2/(double) (1 << 14), 1.0, 1.0)); + assert (out[3].first == -1.0); + assert (out[3].second == Triple (-1.0, -2/(double) (1 << 14), 0.0)); + assert (out[4].first == -1.0); + assert (out[4].second == Triple (-1.0, -1.0, -2/(double) (1 << 14))); } { - Triple tent (0.f, 1.f, 1.f); - Triple axis_range (-1.f, -0.5f, 1.f); + Triple tent (0.0, 1.0, 1.0); + Triple axis_range (-1.0, -0.5, 1.0); 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)); + assert (out[0].first == 1.0); + assert (out[0].second == Triple (1.0/3, 1.0, 1.0)); } { - Triple tent (0.f, 1.f, 1.f); - Triple axis_range (-1.f, -0.5f, 1.f); - TripleDistances axis_distances{2.f, 1.f}; + Triple tent (0.0, 1.0, 1.0); + Triple axis_range (-1.0, -0.5, 1.0); + TripleDistances axis_distances{2.0, 1.0}; 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)); + assert (out[0].first == 1.0); + assert (out[0].second == Triple (0.5, 1.0, 1.0)); } { - Triple tent (0.6f, 0.7f, 0.8f); - Triple axis_range (-1.f, 0.2f, 1.f); - TripleDistances axis_distances{1.f, 1.f}; + Triple tent (0.6, 0.7, 0.8); + Triple axis_range (-1.0, 0.2, 1.0); + TripleDistances axis_distances{1.0, 1.0}; result_t out = rebase_tent (tent, axis_range, axis_distances); assert (out.length == 1); - assert (out[0].first == 1.f); - assert (approx (out[0].second, Triple (0.5f, 0.625f, 0.75f))); + assert (out[0].first == 1.0); + assert (approx (out[0].second, Triple (0.5, 0.625, 0.75))); } } - diff --git a/src/test-tuple-varstore.cc b/src/test-tuple-varstore.cc index 97fec25e7..16a43381b 100644 --- a/src/test-tuple-varstore.cc +++ b/src/test-tuple-varstore.cc @@ -63,10 +63,10 @@ test_decompile_cvar () assert (tuple_variations.tuple_vars[i].indices.length == 65); assert (tuple_variations.tuple_vars[i].indices.length == tuple_variations.tuple_vars[i].deltas_x.length); } - assert (tuple_variations.tuple_vars[0].axis_tuples.get (axis_tag) == Triple (-1.f, -1.f, 0.f)); - assert (tuple_variations.tuple_vars[1].axis_tuples.get (axis_tag) == Triple (0.f, 1.f, 1.f)); - - hb_vector_t deltas_1 {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, -1.f, 0.f, -3.f, 1.f, 0.f, -1.f, 0.f, -3.f, 1.f, 0.f, -37.f, -37.f, -26.f, -26.f, 0.f, 0.f, 0.f, -3.f, 0.f, 0.f, 0.f, 0.f, 0.f, -3.f, 0.f, 2.f, -29.f, -29.f, -20.f, -20.f, 0.f, 0.f, 0.f, 1.f, -29.f, -29.f, -20.f, -20.f, 0.f, 0.f, 0.f, 1.f}; + assert (tuple_variations.tuple_vars[0].axis_tuples.get (axis_tag) == Triple (-1.0, -1.0, 0.0)); + assert (tuple_variations.tuple_vars[1].axis_tuples.get (axis_tag) == Triple (0.0, 1.0, 1.0)); + + hb_vector_t deltas_1 {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, -3.0, 1.0, 0.0, -1.0, 0.0, -3.0, 1.0, 0.0, -37.0, -37.0, -26.0, -26.0, 0.0, 0.0, 0.0, -3.0, 0.0, 0.0, 0.0, 0.0, 0.0, -3.0, 0.0, 2.0, -29.0, -29.0, -20.0, -20.0, 0.0, 0.0, 0.0, 1.0, -29.0, -29.0, -20.0, -20.0, 0.0, 0.0, 0.0, 1.0}; for (unsigned i = 0; i < 65; i++) { if (i < 23) @@ -78,7 +78,7 @@ test_decompile_cvar () } } - hb_vector_t deltas_2 {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 5.f, -3.f, 0.f, 1.f, 0.f, 5.f, -3.f, 0.f, 97.f, 97.f, 68.f, 68.f, 0.f, 0.f, 0.f, 5.f, 0.f, 0.f, 1.f, -1.f, 1.f, 7.f, -1.f, -5.f, 73.f, 73.f, 53.f, 53.f, 0.f, 0.f, 0.f, -1.f, 73.f, 73.f, 53.f, 53.f, 0.f, 0.f, 0.f, -1.f}; + hb_vector_t deltas_2 {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 5.0, -3.0, 0.0, 1.0, 0.0, 5.0, -3.0, 0.0, 97.0, 97.0, 68.0, 68.0, 0.0, 0.0, 0.0, 5.0, 0.0, 0.0, 1.0, -1.0, 1.0, 7.0, -1.0, -5.0, 73.0, 73.0, 53.0, 53.0, 0.0, 0.0, 0.0, -1.0, 73.0, 73.0, 53.0, 53.0, 0.0, 0.0, 0.0, -1.0}; for (unsigned i = 0 ; i < 65; i++) { if (i < 23) @@ -92,10 +92,10 @@ test_decompile_cvar () /* partial instancing wght=300:800 */ hb_hashmap_t normalized_axes_location; - normalized_axes_location.set (axis_tag, Triple (-0.512817f, 0.f, 0.700012f)); + normalized_axes_location.set (axis_tag, Triple (-0.512817, 0.0, 0.700012)); hb_hashmap_t axes_triple_distances; - axes_triple_distances.set (axis_tag, TripleDistances (1.f, 1.f)); + axes_triple_distances.set (axis_tag, TripleDistances (1.0, 1.0)); tuple_variations.instantiate (normalized_axes_location, axes_triple_distances); @@ -103,12 +103,12 @@ test_decompile_cvar () assert (tuple_variations.tuple_vars[1].indices.length == 65); assert (!tuple_variations.tuple_vars[0].deltas_y); assert (!tuple_variations.tuple_vars[1].deltas_y); - assert (tuple_variations.tuple_vars[0].axis_tuples.get (axis_tag) == Triple (-1.f, -1.f, 0.f)); - assert (tuple_variations.tuple_vars[1].axis_tuples.get (axis_tag) == Triple (0.f, 1.f, 1.f)); + assert (tuple_variations.tuple_vars[0].axis_tuples.get (axis_tag) == Triple (-1.0, -1.0, 0.0)); + assert (tuple_variations.tuple_vars[1].axis_tuples.get (axis_tag) == Triple (0.0, 1.0, 1.0)); - hb_vector_t rounded_deltas_1 {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, -1, 0.f, -2, 1, 0.f, -1, 0.f, -2, 1, 0.f, -19, -19, -13, -13, 0.f, 0.f, 0.f, -2, 0.f, 0.f, 0.f, 0.f, 0.f, -2, 0.f, 1, -15, -15, -10.f, -10.f, 0.f, 0.f, 0.f, 1, -15, -15, -10.f, -10.f, 0.f, 0.f, 0.f, 1}; + hb_vector_t rounded_deltas_1 {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1, 0.0, -2, 1, 0.0, -1, 0.0, -2, 1, 0.0, -19, -19, -13, -13, 0.0, 0.0, 0.0, -2, 0.0, 0.0, 0.0, 0.0, 0.0, -2, 0.0, 1, -15, -15, -10.0, -10.0, 0.0, 0.0, 0.0, 1, -15, -15, -10.0, -10.0, 0.0, 0.0, 0.0, 1}; - hb_vector_t rounded_deltas_2 {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 1, 0.f, 4, -2, 0.f, 1, 0.f, 4, -2, 0.f, 68, 68, 48, 48, 0.f, 0.f, 0.f, 4, 0.f, 0.f, 1, -1, 1, 5, -1, -4, 51, 51, 37, 37, 0.f, 0.f, 0.f, -1, 51, 51, 37, 37, 0.f, 0.f, 0.f, -1}; + hb_vector_t rounded_deltas_2 {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, 0.0, 4, -2, 0.0, 1, 0.0, 4, -2, 0.0, 68, 68, 48, 48, 0.0, 0.0, 0.0, 4, 0.0, 0.0, 1, -1, 1, 5, -1, -4, 51, 51, 37, 37, 0.0, 0.0, 0.0, -1, 51, 51, 37, 37, 0.0, 0.0, 0.0, -1}; for (unsigned i = 0; i < 65; i++) { diff --git a/test/subset/data/expected/glyf_partial_instancing/Roboto-Variable.ABC.default.retain-all-codepoint.wght=200-300-500,wdth=80-90.iup_optimize.ttf b/test/subset/data/expected/glyf_partial_instancing/Roboto-Variable.ABC.default.retain-all-codepoint.wght=200-300-500,wdth=80-90.iup_optimize.ttf index a447b7ba556287ae285868250e3ba91976d3b4a3..edb34365f70b64c90ecda1084a674d1512fd177c 100644 GIT binary patch delta 106 zcmaFk{Kk2LGh_NhmpLqfE24QfK3T)a@;N#_d-D{ga7IRv&2N}zb28d&?%>sBWR#e^ zjZd3}pOZmk^HaXdj2bL|e|!OgAOE=orRAk1uUvh}A}FeCUzkFRw5#H!^c@ KYsBWR#q| zjZd3JfRjOV^HaXdj2f(ee|!OgAOE=orRAk1uUvh}A}FS8UzkFRw5#H!^c_ KZhj!ZBM1Ou3?-ca diff --git a/test/subset/data/expected/glyf_partial_instancing/Roboto-Variable.ABC.default.retain-all-codepoint.wght=200-300-500,wdth=80-90.ttf b/test/subset/data/expected/glyf_partial_instancing/Roboto-Variable.ABC.default.retain-all-codepoint.wght=200-300-500,wdth=80-90.ttf index 014cf5593ee7bb30032b6c468704e6bd10260b09..dc1e777a6d113136deae4373ed627595893aad29 100644 GIT binary patch delta 106 zcmZp1X>pn0%$PpWWey9+?CByKpR8eIX)SrKy?F{#I3uIT<~Piv>ckt>kGD=L| z%BRi3&&eRN`3c`UMh%v~KfVCLkN;eP((=-hSFXNf5foK6uml2KSzb=&msc2=8<{yc KHvbaf5(EGTEF|9m delta 106 zcmZp1X>pn0%$PCJWeyAXoS9-9pR8eIsV{o0x_JsyI3uIz<~Piv?ckt>kGD=R~ z%BRgDz{w!G`3c`UMh(`#KfVCLkN;eP((=-hSFXNf5foE4uml2KSzb=&msc2=8<{yd KH~$jg5(EGSASB-a diff --git a/test/subset/data/expected/glyf_partial_instancing/Roboto-Variable.composite.default.retain-all-codepoint.wght=200-300-500,wdth=80-90.iup_optimize.ttf b/test/subset/data/expected/glyf_partial_instancing/Roboto-Variable.composite.default.retain-all-codepoint.wght=200-300-500,wdth=80-90.iup_optimize.ttf index d659d83d1a034e1ddff70bbdd7f2d93a8097f137..fd7f157275bf4158a409e6aa437a4be1b2b0ee09 100644 GIT binary patch delta 43 zcmV+`0M!57I@~&t-~%n>IkDs60Rt1|>$ArK<^};Uv#tp;0S5s90m(N30kh`{brPx& B5V8OO delta 43 zcmV+`0M!57I@~&t-~%q@I9fZI<^};Vv#tp;0S5vA0m(N30<-4|brPxk B5V8OO diff --git a/test/subset/data/expected/glyf_partial_instancing/Roboto-Variable.composite.default.retain-all-codepoint.wght=200-300-500,wdth=80-90.ttf b/test/subset/data/expected/glyf_partial_instancing/Roboto-Variable.composite.default.retain-all-codepoint.wght=200-300-500,wdth=80-90.ttf index 8bfaadef0acee9b50e0889e665dc9bd30fc264e3..4983f0d82b79bf54cfd3ed97f10c4e01ce6c8989 100644 GIT binary patch delta 47 zcmV+~0MP%CJCHk&;RB|8Sh3{c0Rv%Wp|i*W`UU|ov%?8e0Sf_xfC9+?H-Ufv0ka?r Fa1z`c5m^8L delta 47 zcmV+~0MP%CJCHk&;RC0AS+V5d0RvxSpR>pU`UU|pv%?8e0Sf|yfC9+?H-Ufv0<$0s Fa1z`E5m^8L diff --git a/test/subset/data/tests/glyf_partial_instancing.tests b/test/subset/data/tests/glyf_partial_instancing.tests index faea3168d..ebb4566f1 100644 --- a/test/subset/data/tests/glyf_partial_instancing.tests +++ b/test/subset/data/tests/glyf_partial_instancing.tests @@ -15,7 +15,3 @@ wght=200:300:500,wdth=80:90 IUP_OPTIONS: Yes No - -OPTIONS: -no_fonttools -# TODO: re-enable fonttools once rounding issues are fixed (https://github.com/harfbuzz/harfbuzz/issues/4642)