Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e0fbf5d

Browse files
committed
Fixes #913. Paths that start with an "OFF" point should use their last point as an initial MOVETO. This is the SVG-specific corrolory to #905.
1 parent 6d9de3e commit e0fbf5d

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

src/ft2font.cpp

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ FT2Font::get_path()
513513
for (n = 0; n < outline.n_contours; n++)
514514
{
515515
int last; // index of last point in contour
516+
bool starts_with_last;
516517

517518
last = outline.contours[n];
518519
limit = outline.points + last;
@@ -531,13 +532,22 @@ FT2Font::get_path()
531532
{
532533
throw Py::RuntimeError("A contour cannot start with a cubic control point");
533534
}
535+
else if (tag == FT_CURVE_TAG_CONIC)
536+
{
537+
starts_with_last = true;
538+
} else {
539+
starts_with_last = false;
540+
}
534541

535542
count++;
536543

537544
while (point < limit)
538545
{
539-
point++;
540-
tags++;
546+
if (!starts_with_last) {
547+
point++;
548+
tags++;
549+
}
550+
starts_with_last = false;
541551

542552
tag = FT_CURVE_TAG(tags[0]);
543553
switch (tag)
@@ -633,7 +643,8 @@ FT2Font::get_path()
633643
first = 0;
634644
for (n = 0; n < outline.n_contours; n++)
635645
{
636-
int last; // index of last point in contour
646+
int last; // index of last point in contour
647+
bool starts_with_last;
637648

638649
last = outline.contours[n];
639650
limit = outline.points + last;
@@ -647,16 +658,29 @@ FT2Font::get_path()
647658
tags = outline.tags + first;
648659
tag = FT_CURVE_TAG(tags[0]);
649660

650-
double x = conv(v_start.x);
651-
double y = flip_y ? -conv(v_start.y) : conv(v_start.y);
661+
double x, y;
662+
if (tag != FT_CURVE_TAG_ON)
663+
{
664+
x = conv(v_last.x);
665+
y = flip_y ? -conv(v_last.y) : conv(v_last.y);
666+
starts_with_last = true;
667+
} else {
668+
x = conv(v_start.x);
669+
y = flip_y ? -conv(v_start.y) : conv(v_start.y);
670+
starts_with_last = false;
671+
}
672+
652673
*(outpoints++) = x;
653674
*(outpoints++) = y;
654675
*(outcodes++) = MOVETO;
655676

656677
while (point < limit)
657678
{
658-
point++;
659-
tags++;
679+
if (!starts_with_last) {
680+
point++;
681+
tags++;
682+
}
683+
starts_with_last = false;
660684

661685
tag = FT_CURVE_TAG(tags[0]);
662686
switch (tag)

0 commit comments

Comments
 (0)