[instancer-solver] port solver fix (#4519)

* [instancer-solver] port solver fix

from https://github.com/fonttools/fonttools/pull/3374
pull/4522/head
Qunxin Liu 1 year ago committed by GitHub
parent bf84135edd
commit df735213a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/hb-subset-instancer-solver.cc
  2. 18
      src/test-subset-instancer-solver.cc
  3. BIN
      test/subset/data/expected/mvar_partial_instance/NotoSans-VF.abc.default.retain-all-codepoint.wght=500-800.ttf

@ -256,7 +256,10 @@ _solve (Triple tent, Triple axisLimit, bool negative = false)
*/
float newUpper = peak + (1 - gain) * (upper - peak);
assert (axisMax <= newUpper); // Because outGain > gain
if (newUpper <= axisDef + (axisMax - axisDef) * 2)
/* Disabled because ots doesn't like us:
* https://github.com/fonttools/fonttools/issues/3350 */
if (false && (newUpper <= axisDef + (axisMax - axisDef) * 2))
{
upper = newUpper;
if (!negative && axisDef + (axisMax - axisDef) * MAX_F2DOT14 < upper)

@ -95,9 +95,11 @@ 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, default_axis_distances);
assert (out.length == 1);
assert (out.length == 2);
assert (out[0].first == 1.f);
assert (out[0].second == Triple (0.f, 0.25f, 1.25f));
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));
}
/* Case 3 boundary */
@ -105,9 +107,11 @@ 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, default_axis_distances);
assert (out.length == 1);
assert (out.length == 2);
assert (out[0].first == 1.f);
assert (out[0].second == Triple (0.f, 0.8f, 32767/(float) (1 << 14)));
assert (out[0].second == Triple (0.f, 0.8f, 1.f));
assert (out[1].first == 2.5f/3);
assert (out[1].second == Triple (0.8f, 1.f, 1.f));
}
/* Case 4 */
@ -353,9 +357,11 @@ 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, default_axis_distances);
assert (out.length == 1);
assert (out.length == 2);
assert (out[0].first == 1.f);
assert (out[0].second == Triple (0.f, 0.4f, 32767/(float) (1 << 14)));
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));
}

Loading…
Cancel
Save