2222
2323import os
2424from math import ceil
25+ import types
2526import unicodedata
2627from warnings import warn
2728from functools import lru_cache
3738
3839from matplotlib import _png , colors as mcolors , get_data_path , rcParams
3940from matplotlib .afm import AFM
40- from matplotlib .cbook import Bunch , get_realpath_and_stat
41+ from matplotlib .cbook import get_realpath_and_stat
4142from matplotlib .ft2font import FT2Image , KERNING_DEFAULT , LOAD_NO_HINTING
4243from matplotlib .font_manager import findfont , FontProperties , get_font
4344from matplotlib ._mathtext_data import (latex_to_bakoma , latex_to_standard ,
@@ -312,8 +313,8 @@ def render_rect_filled(self, x1, y1, x2, y2):
312313
313314 def get_results (self , box , used_characters ):
314315 ship (0 , 0 , box )
315- svg_elements = Bunch (svg_glyphs = self .svg_glyphs ,
316- svg_rects = self .svg_rects )
316+ svg_elements = types . SimpleNamespace (svg_glyphs = self .svg_glyphs ,
317+ svg_rects = self .svg_rects )
317318 return (self .width ,
318319 self .height + self .depth ,
319320 self .depth ,
@@ -587,7 +588,7 @@ def _get_info(self, fontname, font_class, sym, fontsize, dpi, math=True):
587588
588589 xmin , ymin , xmax , ymax = [val / 64.0 for val in glyph .bbox ]
589590 offset = self ._get_offset (font , glyph , fontsize , dpi )
590- metrics = Bunch (
591+ metrics = types . SimpleNamespace (
591592 advance = glyph .linearHoriAdvance / 65536.0 ,
592593 height = glyph .height / 64.0 ,
593594 width = glyph .width / 64.0 ,
@@ -600,7 +601,7 @@ def _get_info(self, fontname, font_class, sym, fontsize, dpi, math=True):
600601 slanted = slanted
601602 )
602603
603- result = self .glyphd [key ] = Bunch (
604+ result = self .glyphd [key ] = types . SimpleNamespace (
604605 font = font ,
605606 fontsize = fontsize ,
606607 postscript_name = font .postscript_name ,
@@ -1167,7 +1168,7 @@ def _get_info (self, fontname, font_class, sym, fontsize, dpi, math=True):
11671168
11681169 xmin , ymin , xmax , ymax = [val * scale
11691170 for val in font .get_bbox_char (glyph )]
1170- metrics = Bunch (
1171+ metrics = types . SimpleNamespace (
11711172 advance = font .get_width_char (glyph ) * scale ,
11721173 width = font .get_width_char (glyph ) * scale ,
11731174 height = font .get_height_char (glyph ) * scale ,
@@ -1180,7 +1181,7 @@ def _get_info (self, fontname, font_class, sym, fontsize, dpi, math=True):
11801181 slanted = slanted
11811182 )
11821183
1183- self .glyphd [key ] = Bunch (
1184+ self .glyphd [key ] = types . SimpleNamespace (
11841185 font = font ,
11851186 fontsize = fontsize ,
11861187 postscript_name = font .get_fontname (),
@@ -2290,7 +2291,7 @@ class Parser(object):
22902291 _right_delim = set (r") ] \} > \rfloor \rangle \rceil" .split ())
22912292
22922293 def __init__ (self ):
2293- p = Bunch ()
2294+ p = types . SimpleNamespace ()
22942295 # All forward declarations are here
22952296 p .accent = Forward ()
22962297 p .ambi_delim = Forward ()
0 commit comments