|
16 | 16 |
|
17 | 17 | s = r'$\mathcal{R}\prod_{i=\alpha\mathcal{B}}^\infty a_i\sin(2 \pi f x_i)$' |
18 | 18 |
|
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 |
20 | 31 |
|
21 | 32 | The following accents are provided: \hat, \breve, \grave, \bar, |
22 | 33 | \acute, \tilde, \vec, \dot, \ddot. All of them have the same |
@@ -541,10 +552,7 @@ def _get_font(self, font): |
541 | 552 |
|
542 | 553 | cached_font = self._fonts.get(basename) |
543 | 554 | if cached_font is None: |
544 | | - try: |
545 | | - font = FT2Font(basename) |
546 | | - except RuntimeError: |
547 | | - return None |
| 555 | + font = FT2Font(basename) |
548 | 556 | cached_font = self.CachedFont(font) |
549 | 557 | self._fonts[basename] = cached_font |
550 | 558 | self._fonts[font.postscript_name] = cached_font |
@@ -652,13 +660,20 @@ def _get_glyph(self, fontname, font_class, sym, fontsize): |
652 | 660 | if fontname in self.fontmap and latex_to_bakoma.has_key(sym): |
653 | 661 | basename, num = latex_to_bakoma[sym] |
654 | 662 | 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] |
658 | 670 | elif len(sym) == 1: |
659 | 671 | 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: |
662 | 677 | num = ord(sym) |
663 | 678 | gid = cached_font.charmap.get(num) |
664 | 679 | if gid is not None: |
@@ -795,9 +810,12 @@ def _get_glyph(self, fontname, font_class, sym, fontsize): |
795 | 810 | new_fontname = 'rm' |
796 | 811 |
|
797 | 812 | slanted = (new_fontname == 'it') or sym in self._slanted_symbols |
798 | | - cached_font = self._get_font(new_fontname) |
799 | 813 | 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: |
801 | 819 | try: |
802 | 820 | glyphindex = cached_font.charmap[uniindex] |
803 | 821 | found_symbol = True |
|
0 commit comments