mirror of
https://github.com/harfbuzz/harfbuzz.git
synced 2025-04-14 17:13:40 +00:00
[instancer_solver] port solver fix: where axisDef < lower and upper < axisMax
Port from f1e56cd757
This commit is contained in:
parent
64305568d7
commit
80cb6b580f
2 changed files with 15 additions and 3 deletions
|
@ -168,12 +168,14 @@ _solve (Triple tent, Triple axisLimit, bool negative = false)
|
|||
* |
|
||||
* crossing
|
||||
*/
|
||||
if (gain > outGain)
|
||||
if (gain >= outGain)
|
||||
{
|
||||
// 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);
|
||||
|
||||
Triple loc{axisDef, peak, crossing};
|
||||
Triple loc{hb_max (lower, axisDef), peak, crossing};
|
||||
float scalar = 1.f;
|
||||
|
||||
// The part before the crossing point.
|
||||
|
@ -253,7 +255,7 @@ _solve (Triple tent, Triple axisLimit, bool negative = false)
|
|||
* axisDef axisMax
|
||||
*/
|
||||
float newUpper = peak + (1 - gain) * (upper - peak);
|
||||
assert (axisMax <= newUpper); // Because outGain >= gain
|
||||
assert (axisMax <= newUpper); // Because outGain > gain
|
||||
if (newUpper <= axisDef + (axisMax - axisDef) * 2)
|
||||
{
|
||||
upper = newUpper;
|
||||
|
|
|
@ -411,5 +411,15 @@ main (int argc, char **argv)
|
|||
assert (out[0].first == 1.f);
|
||||
assert (out[0].second == Triple (0.5f, 1.f, 1.f));
|
||||
}
|
||||
|
||||
{
|
||||
Triple tent (0.6f, 0.7f, 0.8f);
|
||||
Triple axis_range (-1.f, 0.2f, 1.f);
|
||||
TripleDistances axis_distances{1.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, 0.625f, 0.75f));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue