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

Skip to content

Commit cba5610

Browse files
committed
TST: Re-generate SVG files that use fonttype='none'
We currently special-case the SVG converter depending on if it used fonttype='none', and use one that has our base fonts available. However, this is not based on the rcParam setting (because we don't have that at conversion time), but on whether the SVG text contains the font styling [1]. This check for styling uses the _current_ version, which was changed way back in #19253. These files were never re-generated though, and used the old version of the style, meaning the expected images never triggered the special converter. The result images are written with the current style, and _do_ trigger the special conveter. Evidentally, this never was a problem for most developers, because everyone had DejaVu Sans installed globally, so the expected images matched. However, on the clean macOS CI, it's not installed globally, so the expected images get converted with the wrong font, and the test fails. [1] https://github.com/matplotlib/matplotlib/blob/de1102668dbc0694e98653bd17641e9d99394e57/lib/matplotlib/testing/compare.py#L303
1 parent ad40092 commit cba5610

File tree

4 files changed

+125
-95
lines changed

4 files changed

+125
-95
lines changed

lib/matplotlib/backends/backend_svg.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,10 @@ def _draw_text_as_path(self, gc, x, y, s, prop, angle, ismath, mtext=None):
10851085
writer.end('g')
10861086

10871087
def _draw_text_as_text(self, gc, x, y, s, prop, angle, ismath, mtext=None):
1088+
# NOTE: If you change the styling, then be sure the check in
1089+
# `lib/matplotlib/testing/compare.py::convert` remains in sync. Also be sure to
1090+
# re-generate any SVG using this mode, or else such tests will fail to use the
1091+
# right converter for the expected images, and they will fail strangely.
10881092
writer = self.writer
10891093

10901094
color = rgb2hex(gc.get_rgb())

lib/matplotlib/testing/compare.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,10 @@ def convert(filename, cache):
300300
convert = converter[path.suffix[1:]]
301301
if path.suffix == ".svg":
302302
contents = path.read_text()
303+
# NOTE: This check should be kept in sync with font styling in
304+
# `lib/matplotlib/backends/backend_svg.py`. If it changes, then be sure to
305+
# re-generate any SVG using this mode, or else such tests will fail to use
306+
# the converter for the expected images, and they will fail strangely.
303307
if 'style="font:' in contents:
304308
# for svg.fonttype = none, we explicitly patch the font search
305309
# path so that fonts shipped by Matplotlib are found.

0 commit comments

Comments
 (0)