|
35 | 35 | from matplotlib.cbook import Bunch, is_string_like, \ |
36 | 36 | get_realpath_and_stat, is_writable_file_like, maxdict |
37 | 37 | from matplotlib.figure import Figure |
38 | | -from matplotlib.font_manager import findfont, is_opentype_cff_font |
| 38 | +from matplotlib.font_manager import findfont, is_opentype_cff_font, get_font |
39 | 39 | from matplotlib.afm import AFM |
40 | 40 | import matplotlib.type1font as type1font |
41 | 41 | import matplotlib.dviread as dviread |
42 | | -from matplotlib.ft2font import FT2Font, FIXED_WIDTH, ITALIC, LOAD_NO_SCALE, \ |
| 42 | +from matplotlib.ft2font import FIXED_WIDTH, ITALIC, LOAD_NO_SCALE, \ |
43 | 43 | LOAD_NO_HINTING, KERNING_UNFITTED |
44 | 44 | from matplotlib.mathtext import MathTextParser |
45 | 45 | from matplotlib.transforms import Affine2D, BboxBase |
@@ -757,7 +757,7 @@ def createType1Descriptor(self, t1font, fontfile): |
757 | 757 | if 0: |
758 | 758 | flags |= 1 << 18 |
759 | 759 |
|
760 | | - ft2font = FT2Font(fontfile) |
| 760 | + ft2font = get_font(fontfile) |
761 | 761 |
|
762 | 762 | descriptor = { |
763 | 763 | 'Type': Name('FontDescriptor'), |
@@ -817,7 +817,7 @@ def _get_xobject_symbol_name(self, filename, symbol_name): |
817 | 817 | def embedTTF(self, filename, characters): |
818 | 818 | """Embed the TTF font from the named file into the document.""" |
819 | 819 |
|
820 | | - font = FT2Font(filename) |
| 820 | + font = get_font(filename) |
821 | 821 | fonttype = rcParams['pdf.fonttype'] |
822 | 822 |
|
823 | 823 | def cvt(length, upe=font.units_per_EM, nearest=True): |
@@ -1526,7 +1526,6 @@ def writeTrailer(self): |
1526 | 1526 |
|
1527 | 1527 |
|
1528 | 1528 | class RendererPdf(RendererBase): |
1529 | | - truetype_font_cache = maxdict(50) |
1530 | 1529 | afm_font_cache = maxdict(50) |
1531 | 1530 |
|
1532 | 1531 | def __init__(self, file, image_dpi): |
@@ -2126,15 +2125,8 @@ def _get_font_afm(self, prop): |
2126 | 2125 | return font |
2127 | 2126 |
|
2128 | 2127 | def _get_font_ttf(self, prop): |
2129 | | - key = hash(prop) |
2130 | | - font = self.truetype_font_cache.get(key) |
2131 | | - if font is None: |
2132 | | - filename = findfont(prop) |
2133 | | - font = self.truetype_font_cache.get(filename) |
2134 | | - if font is None: |
2135 | | - font = FT2Font(filename) |
2136 | | - self.truetype_font_cache[filename] = font |
2137 | | - self.truetype_font_cache[key] = font |
| 2128 | + filename = findfont(prop) |
| 2129 | + font = get_font(filename) |
2138 | 2130 | font.clear() |
2139 | 2131 | font.set_size(prop.get_size_in_points(), 72) |
2140 | 2132 | return font |
|
0 commit comments