MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / StixFonts

Class StixFonts

lib/matplotlib/_mathtext.py:785–901  ·  view source on GitHub ↗

A font handling class for the STIX fonts. In addition to what UnicodeFonts provides, this class: - supports "virtual fonts" which are complete alpha numeric character sets with different font styles at special Unicode code points, such as "Blackboard". - handles sized

Source from the content-addressed store, hash-verified

783
784
785class StixFonts(UnicodeFonts):
786 """
787 A font handling class for the STIX fonts.
788
789 In addition to what UnicodeFonts provides, this class:
790
791 - supports "virtual fonts" which are complete alpha numeric
792 character sets with different font styles at special Unicode
793 code points, such as "Blackboard".
794
795 - handles sized alternative characters for the STIXSizeX fonts.
796 """
797 _fontmap = {
798 'rm': 'STIXGeneral',
799 'it': 'STIXGeneral:italic',
800 'bf': 'STIXGeneral:weight=bold',
801 'bfit': 'STIXGeneral:italic:bold',
802 'nonunirm': 'STIXNonUnicode',
803 'nonuniit': 'STIXNonUnicode:italic',
804 'nonunibf': 'STIXNonUnicode:weight=bold',
805 '0': 'STIXGeneral',
806 '1': 'STIXSizeOneSym',
807 '2': 'STIXSizeTwoSym',
808 '3': 'STIXSizeThreeSym',
809 '4': 'STIXSizeFourSym',
810 '5': 'STIXSizeFiveSym',
811 }
812 _fallback_font = None
813 _sans = False
814
815 def __init__(self, default_font_prop: FontProperties, load_glyph_flags: LoadFlags):
816 TruetypeFonts.__init__(self, default_font_prop, load_glyph_flags)
817 for key, name in self._fontmap.items():
818 fullpath = findfont(name)
819 self.fontmap[key] = fullpath
820 self.fontmap[name] = fullpath
821
822 def _map_virtual_font(self, fontname: str, font_class: str,
823 uniindex: CharacterCodeType) -> tuple[str, CharacterCodeType]:
824 # Handle these "fonts" that are actually embedded in
825 # other fonts.
826 font_mapping = stix_virtual_fonts.get(fontname)
827 if (self._sans and font_mapping is None
828 and fontname not in ('regular', 'default')):
829 font_mapping = stix_virtual_fonts['sf']
830 doing_sans_conversion = True
831 else:
832 doing_sans_conversion = False
833
834 if isinstance(font_mapping, dict):
835 try:
836 mapping = font_mapping[font_class]
837 except KeyError:
838 mapping = font_mapping['rm']
839 elif isinstance(font_mapping, list):
840 mapping = font_mapping
841 else:
842 mapping = None

Callers 2

__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…