173 const int maxLen = 255;
177 if (str->startsWith(QLatin1Char(
'-'))) {
180 }
else if (str->startsWith(QLatin1Char(
'+'))) {
183 while (!str->isEmpty() && isDigit(str->first().unicode()) && pos < maxLen) {
184 temp[pos++] = str->first().toLatin1();
187 if (str->startsWith(QLatin1Char(
'.')) && pos < maxLen) {
191 while (!str->isEmpty() && isDigit(str->first().unicode()) && pos < maxLen) {
192 temp[pos++] = str->first().toLatin1();
195 bool exponent =
false;
196 if ((str->startsWith(QLatin1Char(
'e')) || str->startsWith(QLatin1Char(
'E'))) && pos < maxLen) {
200 if ((str->startsWith(QLatin1Char(
'-')) || str->startsWith(QLatin1Char(
'+')))
202 temp[pos++] = str->first().toLatin1();
205 while (!str->isEmpty() && isDigit(str->first().unicode()) && pos < maxLen) {
206 temp[pos++] = str->first().toLatin1();
214 if (!exponent && pos < 10) {
216 const char *t = temp;
222 while (*t && *t !=
'.') {
236 val = ((qreal)ival)/((qreal)div);
243 val = QByteArray::fromRawData(temp, pos).toDouble();
245 if (qFpClassify(
float(val)) != FP_NORMAL)
370 const size_t patternLen = qstrlen(pattern);
371 while (!str->isEmpty() && str->first().isSpace())
374 || str->startsWith(QLatin1Char(
'-')) || str->startsWith(QLatin1Char(
'+'))
375 || str->startsWith(QLatin1Char(
'.'))) {
377 if (patternLen && pattern[points.size() % patternLen] ==
'f') {
379 if (!str->startsWith(QLatin1Char(
'0')) && !str->startsWith(QLatin1Char(
'1')))
381 points.append(str->startsWith(QLatin1Char(
'0')) ? 0.0 : 1.0);
384 points.append(QSvgUtils::toDouble(str));
387 while (!str->isEmpty() && str->first().isSpace())
389 if (str->startsWith(QLatin1Char(
',')))
393 while (!str->isEmpty() && str->first().isSpace())
400 if (dataStr.isEmpty())
403 const int maxElementCount = 0x7fff;
404 qreal x0 = 0, y0 = 0;
410 while (!dataStr.isEmpty()) {
411 while (dataStr.first().isSpace() && dataStr.length() > 1)
413 QChar pathElem = dataStr.first();
415 const char *pattern =
nullptr;
416 if (pathElem == QLatin1Char(
'a') || pathElem == QLatin1Char(
'A'))
418 QVarLengthArray<qreal, 8> arg;
419 parseNumbersArray(&dataStr, arg, pattern);
420 if (pathElem == QLatin1Char(
'z') || pathElem == QLatin1Char(
'Z'))
422 const qreal *num = arg.constData();
423 int count = arg.size();
427 switch (pathElem.unicode()) {
431 x = x0 = num[0] + offsetX;
432 y = y0 = num[1] + offsetY;
440 pathElem = QLatin1Char(
'l');
456 pathElem = QLatin1Char(
'L');
472 x = num[0] + offsetX;
473 y = num[1] + offsetY;
492 x = num[0] + offsetX;
506 y = num[0] + offsetY;
523 QPointF c1(num[0] + offsetX, num[1] + offsetY);
524 QPointF c2(num[2] + offsetX, num[3] + offsetY);
525 QPointF e(num[4] + offsetX, num[5] + offsetY);
528 path.cubicTo(c1, c2, e);
538 QPointF c1(num[0], num[1]);
539 QPointF c2(num[2], num[3]);
540 QPointF e(num[4], num[5]);
543 path.cubicTo(c1, c2, e);
554 if (lastMode ==
'c' || lastMode ==
'C' ||
555 lastMode ==
's' || lastMode ==
'S')
556 c1 = QPointF(2*x-ctrlPt.x(), 2*y-ctrlPt.y());
559 QPointF c2(num[0] + offsetX, num[1] + offsetY);
560 QPointF e(num[2] + offsetX, num[3] + offsetY);
563 path.cubicTo(c1, c2, e);
574 if (lastMode ==
'c' || lastMode ==
'C' ||
575 lastMode ==
's' || lastMode ==
'S')
576 c1 = QPointF(2*x-ctrlPt.x(), 2*y-ctrlPt.y());
579 QPointF c2(num[0], num[1]);
580 QPointF e(num[2], num[3]);
583 path.cubicTo(c1, c2, e);
593 QPointF c(num[0] + offsetX, num[1] + offsetY);
594 QPointF e(num[2] + offsetX, num[3] + offsetY);
607 QPointF c(num[0], num[1]);
608 QPointF e(num[2], num[3]);
621 QPointF e(num[0] + offsetX, num[1] + offsetY);
625 if (lastMode ==
'q' || lastMode ==
'Q' ||
626 lastMode ==
't' || lastMode ==
'T')
627 c = QPointF(2*x-ctrlPt.x(), 2*y-ctrlPt.y());
640 QPointF e(num[0], num[1]);
644 if (lastMode ==
'q' || lastMode ==
'Q' ||
645 lastMode ==
't' || lastMode ==
'T')
646 c = QPointF(2*x-ctrlPt.x(), 2*y-ctrlPt.y());
661 qreal xAxisRotation = (*num++);
662 qreal largeArcFlag = (*num++);
663 qreal sweepFlag = (*num++);
664 qreal ex = (*num++) + offsetX;
665 qreal ey = (*num++) + offsetY;
669 pathArc(path, rx, ry, xAxisRotation,
int(largeArcFlag),
670 int(sweepFlag), ex, ey, curx, cury);
682 qreal xAxisRotation = (*num++);
683 qreal largeArcFlag = (*num++);
684 qreal sweepFlag = (*num++);
690 pathArc(path, rx, ry, xAxisRotation,
int(largeArcFlag),
691 int(sweepFlag), ex, ey, curx, cury);
700 lastMode = pathElem.toLatin1();
701 if (limitLength && path.elementCount() > maxElementCount)