Skip to content

Commit

Permalink
[instancer-solver] port solver fix from fonttools
Browse files Browse the repository at this point in the history
  • Loading branch information
qxliu76 committed May 30, 2023
1 parent ff326fb commit 7381306
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/hb-subset-instancer-solver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ _solve (Triple tent, Triple axisLimit, bool negative = false)
// Crossing point on the axis.
float crossing = peak + ((1 - gain) * (upper - peak) / (1 - outGain));

Triple loc{peak, peak, crossing};
Triple loc{axisDef, peak, crossing};
float scalar = 1.f;

// The part before the crossing point.
Expand Down
18 changes: 18 additions & 0 deletions src/test-subset-instancer-solver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,24 @@ main (int argc, char **argv)
assert (out[0].second == Triple (0.f, 0.4f, 32767/(float) (1 << 14)));
}


{
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);
assert (out.length == 5);
assert (out[0].first == 0.5f);
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));
}

{
Triple tent (0.5f, 0.5f, 0.5f);
Triple axis_range (0.f, 0.5f, 1.f);
Expand Down

0 comments on commit 7381306

Please sign in to comment.