Select a font based on fontprop and return a name suitable for ``Op.selectfont``. If fontprop is a string, it will be interpreted as the filename of the font.
(self, fontprop, subset=0)
| 888 | self.writeObject(annotsObject, annotations) |
| 889 | |
| 890 | def fontName(self, fontprop, subset=0): |
| 891 | """ |
| 892 | Select a font based on fontprop and return a name suitable for |
| 893 | ``Op.selectfont``. If fontprop is a string, it will be interpreted |
| 894 | as the filename of the font. |
| 895 | """ |
| 896 | |
| 897 | if isinstance(fontprop, FontPath): |
| 898 | filenames = [fontprop] |
| 899 | elif isinstance(fontprop, str): |
| 900 | filenames = [FontPath(fontprop, 0)] |
| 901 | elif mpl.rcParams['pdf.use14corefonts']: |
| 902 | filenames = _fontManager._find_fonts_by_props( |
| 903 | fontprop, fontext='afm', directory=RendererPdf._afm_font_dir |
| 904 | ) |
| 905 | else: |
| 906 | filenames = _fontManager._find_fonts_by_props(fontprop) |
| 907 | first_Fx = None |
| 908 | for fname in filenames: |
| 909 | Fx = self._fontNames.get((fname, subset)) |
| 910 | if not first_Fx: |
| 911 | first_Fx = Fx |
| 912 | if Fx is None: |
| 913 | Fx = next(self._internal_font_seq) |
| 914 | self._fontNames[(fname, subset)] = Fx |
| 915 | _log.debug('Assigning font %s (subset %d) = %r', Fx, subset, fname) |
| 916 | if not first_Fx: |
| 917 | first_Fx = Fx |
| 918 | |
| 919 | # find_fontsprop's first value always adheres to |
| 920 | # findfont's value, so technically no behaviour change |
| 921 | return first_Fx |
| 922 | |
| 923 | def dviFontName(self, dvifont): |
| 924 | """ |
no test coverage detected