diff --git a/examples/showcase/firefox.py b/examples/showcase/firefox.py index 0f597812fa8f..713809b8292d 100644 --- a/examples/showcase/firefox.py +++ b/examples/showcase/firefox.py @@ -22,50 +22,38 @@ def svg_parse(path): 'Q': (Path.CURVE3,)*2, 'C': (Path.CURVE4,)*3, 'Z': (Path.CLOSEPOLY,)} - path_re = re.compile(r'([MLHVCSQTAZ])([^MLHVCSQTAZ]+)', re.IGNORECASE) - float_re = re.compile(r'(?:[\s,]*)([+-]?\d+(?:\.\d+)?)') vertices = [] codes = [] - last = (0, 0) - for cmd, values in path_re.findall(path): - points = [float(v) for v in float_re.findall(values)] - points = np.array(points).reshape((len(points)//2, 2)) + cmd_values = re.split("([A-Za-z])", path)[1:] # Split over commands. + for cmd, values in zip(cmd_values[::2], cmd_values[1::2]): + # Numbers are separated either by commas, or by +/- signs (but not at + # the beginning of the string). + points = ([*map(float, re.split(",|(?