Skip to content

Commit 79deb35

Browse files
committed
Merge pull request #927 from mdboom/svg-freesans
SVG Freesans rendering
2 parents 3c4a7a6 + 1928306 commit 79deb35

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

src/ft2font.cpp

+31-7
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,7 @@ FT2Font::get_path()
536536
for (n = 0; n < outline.n_contours; n++)
537537
{
538538
int last; // index of last point in contour
539+
bool starts_with_last;
539540

540541
last = outline.contours[n];
541542
limit = outline.points + last;
@@ -554,13 +555,22 @@ FT2Font::get_path()
554555
{
555556
throw Py::RuntimeError("A contour cannot start with a cubic control point");
556557
}
558+
else if (tag == FT_CURVE_TAG_CONIC)
559+
{
560+
starts_with_last = true;
561+
} else {
562+
starts_with_last = false;
563+
}
557564

558565
count++;
559566

560567
while (point < limit)
561568
{
562-
point++;
563-
tags++;
569+
if (!starts_with_last) {
570+
point++;
571+
tags++;
572+
}
573+
starts_with_last = false;
564574

565575
tag = FT_CURVE_TAG(tags[0]);
566576
switch (tag)
@@ -656,7 +666,8 @@ FT2Font::get_path()
656666
first = 0;
657667
for (n = 0; n < outline.n_contours; n++)
658668
{
659-
int last; // index of last point in contour
669+
int last; // index of last point in contour
670+
bool starts_with_last;
660671

661672
last = outline.contours[n];
662673
limit = outline.points + last;
@@ -670,16 +681,29 @@ FT2Font::get_path()
670681
tags = outline.tags + first;
671682
tag = FT_CURVE_TAG(tags[0]);
672683

673-
double x = conv(v_start.x);
674-
double y = flip_y ? -conv(v_start.y) : conv(v_start.y);
684+
double x, y;
685+
if (tag != FT_CURVE_TAG_ON)
686+
{
687+
x = conv(v_last.x);
688+
y = flip_y ? -conv(v_last.y) : conv(v_last.y);
689+
starts_with_last = true;
690+
} else {
691+
x = conv(v_start.x);
692+
y = flip_y ? -conv(v_start.y) : conv(v_start.y);
693+
starts_with_last = false;
694+
}
695+
675696
*(outpoints++) = x;
676697
*(outpoints++) = y;
677698
*(outcodes++) = MOVETO;
678699

679700
while (point < limit)
680701
{
681-
point++;
682-
tags++;
702+
if (!starts_with_last) {
703+
point++;
704+
tags++;
705+
}
706+
starts_with_last = false;
683707

684708
tag = FT_CURVE_TAG(tags[0]);
685709
switch (tag)

0 commit comments

Comments
 (0)