diff --git a/src/apps/icon-o-matic/import_export/styled_text/StyledTextImporter.cpp b/src/apps/icon-o-matic/import_export/styled_text/StyledTextImporter.cpp index 67be882933..d7be47dba8 100644 --- a/src/apps/icon-o-matic/import_export/styled_text/StyledTextImporter.cpp +++ b/src/apps/icon-o-matic/import_export/styled_text/StyledTextImporter.cpp @@ -1,9 +1,10 @@ /* - * Copyright 2008-2009, Haiku, Inc. All rights reserved. + * Copyright 2008-2009, 2023, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: * François Revol + * Zardshard */ #include "StyledTextImporter.h" @@ -112,16 +113,33 @@ ShapeIterator::IterateBezierTo(int32 bezierCount, BPoint *bezierPts) CALLED(); if (!CurrentPath()) return B_ERROR; - BPoint start(bezierPts[0]); - if (fHasLastPoint) - start = fLastPoint; - while (bezierCount--) { - fPath->AddPoint(fOffset + bezierPts[0], - fLastPoint, fOffset + bezierPts[1], true); - fLastPoint = fOffset + bezierPts[2]; - bezierPts += 3; + + BPoint firstPoint(fLastPoint); + fLastPoint = fOffset + bezierPts[bezierCount * 3 - 1]; + + // first point + if (firstPoint == fLastPoint) { + // combine the first and the last point + fPath->AddPoint(firstPoint, + fOffset + bezierPts[bezierCount * 3 - 2], fOffset + bezierPts[0], false); + // Mark the points as disconnected for now. CleanUp will change this if necessary. + fPath->SetClosed(true); + } else { + fPath->AddPoint(firstPoint, firstPoint, fOffset + bezierPts[0], false); } - fPath->AddPoint(fLastPoint); + + // middle points + for (int i = 1; i + 2 < bezierCount * 3; i += 3) { + fPath->AddPoint(fOffset + bezierPts[i + 1], + fOffset + bezierPts[i + 0], fOffset + bezierPts[i + 2], false); + } + + // last point + if (firstPoint != fLastPoint) { + fPath->AddPoint(fLastPoint, + fOffset + bezierPts[bezierCount * 3 - 2], fLastPoint, false); + } + fHasLastPoint = true; return B_OK; } @@ -154,6 +172,7 @@ ShapeIterator::NextPath() { CALLED(); if (fPath) { + fPath->CleanUp(); fIcon->Paths()->AddItem(fPath); fShape->Paths()->AddItem(fPath); } diff --git a/src/servers/app/ServerFont.cpp b/src/servers/app/ServerFont.cpp index 36122bfc56..182e526134 100644 --- a/src/servers/app/ServerFont.cpp +++ b/src/servers/app/ServerFont.cpp @@ -74,8 +74,8 @@ ConicToFunc(const FT_Vector *control, const FT_Vector *to, void *user) BPoint controls[3]; controls[0] = VectorToPoint(control); - controls[1] = VectorToPoint(to); - controls[2] = controls[1]; + controls[1] = controls[0]; + controls[2] = VectorToPoint(to); ((BShape *)user)->BezierTo(controls); return 0;