From 9371c046e68c2cf797bd310928384cd36cb08e85 Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Mon, 29 Jan 2024 10:06:04 +0900 Subject: [PATCH] loader/svg: Fix zero check of arc's rx and ry Please refer to the specifications. https://www.w3.org/TR/SVG/paths.html#ArcOutOfRangeParameters If either rx or ry is 0, then this arc is treated as a straight line segment(a "lineto") joining the endpoints. --- src/loaders/svg/tvgSvgPath.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/loaders/svg/tvgSvgPath.cpp b/src/loaders/svg/tvgSvgPath.cpp index 2c9c0615..67c87ba1 100644 --- a/src/loaders/svg/tvgSvgPath.cpp +++ b/src/loaders/svg/tvgSvgPath.cpp @@ -51,7 +51,6 @@ #define _USE_MATH_DEFINES //Math Constants are not defined in Standard C/C++. #include -#include #include #include "tvgMath.h" #include "tvgShape.h" @@ -472,13 +471,12 @@ static bool _processCommand(Array* cmds, Array* pts, char cm } case 'a': case 'A': { - if (arr[0] < FLT_EPSILON || arr[1] < FLT_EPSILON) { + if (mathZero(arr[0]) || mathZero(arr[1])) { Point p = {arr[5], arr[6]}; cmds->push(PathCommand::LineTo); pts->push(p); *cur = {arr[5], arr[6]}; - } - else if (!mathEqual(cur->x, arr[5]) || !mathEqual(cur->y, arr[6])) { + } else if (!mathEqual(cur->x, arr[5]) || !mathEqual(cur->y, arr[6])) { _pathAppendArcTo(cmds, pts, cur, curCtl, arr[5], arr[6], fabsf(arr[0]), fabsf(arr[1]), arr[2], arr[3], arr[4]); *cur = *curCtl = {arr[5], arr[6]}; *isQuadratic = false;