Fixed edge coloring not restored if lost during preprocessing

This commit is contained in:
Chlumsky 2021-11-13 15:26:29 +01:00
parent 22b3055247
commit f1797ada88
2 changed files with 10 additions and 13 deletions

View File

@ -24,19 +24,12 @@ void shapeToSkiaPath(SkPath &skPath, const Shape &shape) {
if (!contour->edges.empty()) {
skPath.moveTo(pointToSkiaPoint(contour->edges.front()->point(0)));
for (std::vector<EdgeHolder>::const_iterator edge = contour->edges.begin(); edge != contour->edges.end(); ++edge) {
{
const LinearSegment *linearSegment = dynamic_cast<const LinearSegment *>(&**edge);
if (linearSegment)
skPath.lineTo(pointToSkiaPoint(linearSegment->p[1]));
} {
const QuadraticSegment *quadraticSegment = dynamic_cast<const QuadraticSegment *>(&**edge);
if (quadraticSegment)
skPath.quadTo(pointToSkiaPoint(quadraticSegment->p[1]), pointToSkiaPoint(quadraticSegment->p[2]));
} {
const CubicSegment *cubicSegment = dynamic_cast<const CubicSegment *>(&**edge);
if (cubicSegment)
skPath.cubicTo(pointToSkiaPoint(cubicSegment->p[1]), pointToSkiaPoint(cubicSegment->p[2]), pointToSkiaPoint(cubicSegment->p[3]));
}
if (const LinearSegment *linearSegment = dynamic_cast<const LinearSegment *>(&**edge))
skPath.lineTo(pointToSkiaPoint(linearSegment->p[1]));
else if (const QuadraticSegment *quadraticSegment = dynamic_cast<const QuadraticSegment *>(&**edge))
skPath.quadTo(pointToSkiaPoint(quadraticSegment->p[1]), pointToSkiaPoint(quadraticSegment->p[2]));
else if (const CubicSegment *cubicSegment = dynamic_cast<const CubicSegment *>(&**edge))
skPath.cubicTo(pointToSkiaPoint(cubicSegment->p[1]), pointToSkiaPoint(cubicSegment->p[2]), pointToSkiaPoint(cubicSegment->p[3]));
}
}
}

View File

@ -876,6 +876,10 @@ int main(int argc, const char * const *argv) {
#ifdef MSDFGEN_USE_SKIA
if (!resolveShapeGeometry(shape))
puts("Shape geometry preprocessing failed, skipping.");
else if (skipColoring) {
skipColoring = false;
puts("Note: Input shape coloring won't be preserved due to geometry preprocessing");
}
#else
ABORT("Shape geometry preprocessing (-preprocess) is not available in this version because the Skia library is not present.");
#endif