mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-23 16:01:07 +01:00
[hvgl] Avoid a div-by-zero
This commit is contained in:
1 parent
1b42d811a0
commit
5fa2c628ac
1 file changed
+2
-1
@@ -61,7 +61,8 @@ project_on_curve_to_tangent (const segment_t offcurve1,
|
||||
double dx = x2 - x1;
|
||||
double dy = y2 - y1;
|
||||
|
||||
double t = (dx * (x - x1) + dy * (y - y1)) / (dx * dx + dy * dy);
|
||||
double l2 = dx * dx + dy * dy;
|
||||
double t = l2 ? (dx * (x - x1) + dy * (y - y1)) / l2 : 0;
|
||||
|
||||
x = x1 + dx * t;
|
||||
y = y1 + dy * t;
|
||||
|
||||
Reference in new issue
Block a user