Generic constructor which can build a `.FontProperties` from any of the following: - a `.FontProperties`: it is passed through as is; - `None`: a `.FontProperties` using rc values is used; - an `os.PathLike`: it is used as path to the font file; - a
(cls, arg)
| 837 | |
| 838 | @classmethod |
| 839 | def _from_any(cls, arg): |
| 840 | """ |
| 841 | Generic constructor which can build a `.FontProperties` from any of the |
| 842 | following: |
| 843 | |
| 844 | - a `.FontProperties`: it is passed through as is; |
| 845 | - `None`: a `.FontProperties` using rc values is used; |
| 846 | - an `os.PathLike`: it is used as path to the font file; |
| 847 | - a `str`: it is parsed as a fontconfig pattern; |
| 848 | - a `dict`: it is passed as ``**kwargs`` to `.FontProperties`. |
| 849 | """ |
| 850 | if arg is None: |
| 851 | return cls() |
| 852 | elif isinstance(arg, cls): |
| 853 | return arg |
| 854 | elif isinstance(arg, os.PathLike): |
| 855 | return cls(fname=arg) |
| 856 | elif isinstance(arg, str): |
| 857 | return cls(arg) |
| 858 | else: |
| 859 | return cls(**arg) |
| 860 | |
| 861 | def __hash__(self): |
| 862 | return hash(tuple(self.__dict__.values())) |
no outgoing calls
no test coverage detected