Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3a3c27f

Browse files
committed
Fix missing font file error.
svn path=/trunk/matplotlib/; revision=4557
1 parent 3e5aaff commit 3a3c27f

1 file changed

Lines changed: 30 additions & 12 deletions

File tree

lib/matplotlib/mathtext.py

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,18 @@
1616
1717
s = r'$\mathcal{R}\prod_{i=\alpha\mathcal{B}}^\infty a_i\sin(2 \pi f x_i)$'
1818
19-
The fonts \cal, \rm, \it, and \tt are allowed.
19+
Different fonts may be selected:
20+
\mathcal Calligraphic fonts
21+
\mathrm Roman (upright) font
22+
\mathit Italic font
23+
\mathtt Typewriter (monospaced) font, similar to Courier
24+
25+
Additionally, if using the STIX fonts:
26+
\mathbb Blackboard (double-struck) font
27+
\mathcircled Circled characters
28+
\mathfrak Fraktur (Gothic-style) font
29+
\mathscr Script (cursive) font
30+
\mathsf Sans-serif font
2031
2132
The following accents are provided: \hat, \breve, \grave, \bar,
2233
\acute, \tilde, \vec, \dot, \ddot. All of them have the same
@@ -541,10 +552,7 @@ def _get_font(self, font):
541552

542553
cached_font = self._fonts.get(basename)
543554
if cached_font is None:
544-
try:
545-
font = FT2Font(basename)
546-
except RuntimeError:
547-
return None
555+
font = FT2Font(basename)
548556
cached_font = self.CachedFont(font)
549557
self._fonts[basename] = cached_font
550558
self._fonts[font.postscript_name] = cached_font
@@ -652,13 +660,20 @@ def _get_glyph(self, fontname, font_class, sym, fontsize):
652660
if fontname in self.fontmap and latex_to_bakoma.has_key(sym):
653661
basename, num = latex_to_bakoma[sym]
654662
slanted = (basename == "cmmi10") or sym in self._slanted_symbols
655-
cached_font = self._get_font(basename)
656-
symbol_name = cached_font.font.get_glyph_name(num)
657-
num = cached_font.glyphmap[num]
663+
try:
664+
cached_font = self._get_font(basename)
665+
except RuntimeError:
666+
pass
667+
else:
668+
symbol_name = cached_font.font.get_glyph_name(num)
669+
num = cached_font.glyphmap[num]
658670
elif len(sym) == 1:
659671
slanted = (fontname == "it")
660-
cached_font = self._get_font(fontname)
661-
if cached_font is not None:
672+
try:
673+
cached_font = self._get_font(fontname)
674+
except RuntimeError:
675+
pass
676+
else:
662677
num = ord(sym)
663678
gid = cached_font.charmap.get(num)
664679
if gid is not None:
@@ -795,9 +810,12 @@ def _get_glyph(self, fontname, font_class, sym, fontsize):
795810
new_fontname = 'rm'
796811

797812
slanted = (new_fontname == 'it') or sym in self._slanted_symbols
798-
cached_font = self._get_font(new_fontname)
799813
found_symbol = False
800-
if cached_font is not None:
814+
try:
815+
cached_font = self._get_font(new_fontname)
816+
except RuntimeError:
817+
pass
818+
else:
801819
try:
802820
glyphindex = cached_font.charmap[uniindex]
803821
found_symbol = True

0 commit comments

Comments
 (0)