@@ -598,8 +598,10 @@ class FontProperties:
598598
599599 sans-serif, normal, normal, normal, normal, scalable.
600600
601- Alternatively, a font may be specified using an absolute path to a
602- .ttf file, by using the *fname* kwarg.
601+ Alternatively, a font may be specified using the absolute path to a font
602+ file, by using the *fname* kwarg. However, in this case, it is typically
603+ simpler to just pass the path (as a `pathlib.Path`, not a `str`) to the
604+ *font* kwarg of the `.Text` object.
603605
604606 The preferred usage of font sizes is to use the relative values,
605607 e.g., 'large', instead of absolute font sizes, e.g., 12. This
@@ -657,6 +659,17 @@ def __init__(self,
657659 self .set_file (fname )
658660 self .set_size (size )
659661
662+ @classmethod
663+ def _from_any (cls , arg ):
664+ if isinstance (arg , cls ):
665+ return arg
666+ elif isinstance (arg , os .PathLike ):
667+ return cls (fname = arg )
668+ elif isinstance (arg , str ):
669+ return cls (arg )
670+ else :
671+ return cls (** arg )
672+
660673 def __hash__ (self ):
661674 l = (tuple (self .get_family ()),
662675 self .get_slant (),
@@ -1230,8 +1243,7 @@ def findfont(self, prop, fontext='ttf', directory=None,
12301243 def _findfont_cached (self , prop , fontext , directory , fallback_to_default ,
12311244 rebuild_if_missing , rc_params ):
12321245
1233- if not isinstance (prop , FontProperties ):
1234- prop = FontProperties (prop )
1246+ prop = FontProperties ._from_any (prop )
12351247
12361248 fname = prop .get_file ()
12371249 if fname is not None :
0 commit comments