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

Skip to content

Commit 5496805

Browse files
authored
Merge pull request #8028 from QuLogic/font-contour-close
Correctly close glyph contours that use curves.
2 parents 371b8b1 + 2b3e043 commit 5496805

File tree

15 files changed

+916
-414
lines changed

15 files changed

+916
-414
lines changed
Binary file not shown.

lib/matplotlib/tests/baseline_images/test_patheffects/collection.svg

Lines changed: 639 additions & 239 deletions
Loading
Binary file not shown.

lib/matplotlib/tests/baseline_images/test_patheffects/patheffect1.svg

Lines changed: 51 additions & 47 deletions
Loading
Binary file not shown.

lib/matplotlib/tests/baseline_images/test_patheffects/patheffect2.svg

Lines changed: 89 additions & 69 deletions
Loading
Binary file not shown.

lib/matplotlib/tests/baseline_images/test_patheffects/patheffect3.svg

Lines changed: 107 additions & 55 deletions
Loading

lib/matplotlib/tests/test_patheffects.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,34 @@ def test_patheffect3():
8484
t.set_path_effects(pe)
8585

8686

87+
@image_comparison(baseline_images=['stroked_text'], extensions=['png'])
88+
def test_patheffects_stroked_text():
89+
text_chunks = [
90+
'A B C D E F G H I J K L',
91+
'M N O P Q R S T U V W',
92+
'X Y Z a b c d e f g h i j',
93+
'k l m n o p q r s t u v',
94+
'w x y z 0123456789',
95+
r"!@#$%^&*()-=_+[]\;'",
96+
',./{}|:"<>?'
97+
]
98+
font_size = 50
99+
100+
ax = plt.axes([0, 0, 1, 1])
101+
for i, chunk in enumerate(text_chunks):
102+
text = ax.text(x=0.01, y=(0.9 - i * 0.13), s=chunk,
103+
fontdict={'ha': 'left', 'va': 'center',
104+
'size': font_size, 'color': 'white'})
105+
106+
text.set_path_effects([path_effects.Stroke(linewidth=font_size / 10,
107+
foreground='black'),
108+
path_effects.Normal()])
109+
110+
ax.set_xlim(0, 1)
111+
ax.set_ylim(0, 1)
112+
ax.axis('off')
113+
114+
87115
@cleanup
88116
@knownfailureif(True)
89117
def test_PathEffect_points_to_pixels():

src/ft2font.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,8 @@ int FT2Font::get_path_count()
280280
}
281281
}
282282

283-
count++;
284-
285283
Count_Close:
284+
count++;
286285
first = last + 1;
287286
}
288287

@@ -478,11 +477,10 @@ void FT2Font::get_path(double *outpoints, unsigned char *outcodes)
478477
}
479478
}
480479

480+
Close:
481481
(*outpoints++) = 0.0;
482482
(*outpoints++) = 0.0;
483483
(*outcodes++) = ENDPOLY;
484-
485-
Close:
486484
first = last + 1;
487485
}
488486
}

0 commit comments

Comments
 (0)