Beispiel #1
0
 def test_line_path_from_text_path(self):
     mpath = self.to_mpath('abc')
     paths = list(path.from_matplotlib_path(mpath, curves=False))
     path0 = paths[0]
     assert all((cmd.type == path.Command.LINE_TO
                 for cmd in path0)), "expected only LINE_TO commands"
     assert len(paths) == 5  # 2xa 2xb 1xc
    def test_curve_path_from_text_path(self):
        mpath = self.to_mpath('obc')
        paths = list(path.from_matplotlib_path(mpath))

        # Last command is a LINE_TO created by CLOSEPOLY:
        assert paths[0][-1].type == \
               path.Command.LINE_TO, "expected LINE_TO as last command"

        commands = paths[0][:-1]
        assert all((cmd.type == path.Command.CURVE3_TO
                    for cmd in commands)), "expected only CURVE3_TO commands"
        assert len(paths) == 5  # 2xo 2xb 1xc
Beispiel #3
0
def _str_to_paths(s: str, fp: FontProperties, size: float = 1.0) -> List[Path]:
    text_path = TextPath((0, 0), s, size=size, prop=fp, usetex=False)
    return list(path.from_matplotlib_path(text_path))