@@ -771,7 +771,11 @@ def _get_glyph(self, fontname, font_class, sym, fontsize):
771771 ('\leftbrace' , '{' ),
772772 ('\r ightbrace' , '}' ),
773773 ('\leftbracket' , '[' ),
774- ('\r ightbracket' , ']' )]:
774+ ('\r ightbracket' , ']' ),
775+ (r'\{' , '{' ),
776+ (r'\}' , '}' ),
777+ (r'\[' , '[' ),
778+ (r'\]' , ']' )]:
775779 _size_alternatives [alias ] = _size_alternatives [target ]
776780
777781 def get_sized_alternatives_for_symbol (self , fontname , sym ):
@@ -970,6 +974,9 @@ def _map_virtual_font(self, fontname, font_class, uniindex):
970974
971975 _size_alternatives = {}
972976 def get_sized_alternatives_for_symbol (self , fontname , sym ):
977+ fixes = {'\{' : '{' , '\}' : '}' , '\[' : '[' , '\]' : ']' }
978+ sym = fixes .get (sym , sym )
979+
973980 alternatives = self ._size_alternatives .get (sym )
974981 if alternatives :
975982 return alternatives
@@ -1829,7 +1836,7 @@ class AutoHeightChar(Hlist):
18291836 fonts), the correct glyph will be selected, otherwise this will
18301837 always just return a scaled version of the glyph.
18311838 """
1832- def __init__ (self , c , height , depth , state , always = False ):
1839+ def __init__ (self , c , height , depth , state , always = False , factor = None ):
18331840 alternatives = state .font_output .get_sized_alternatives_for_symbol (
18341841 state .font , c )
18351842
@@ -1841,7 +1848,8 @@ def __init__(self, c, height, depth, state, always=False):
18411848 if char .height + char .depth >= target_total :
18421849 break
18431850
1844- factor = target_total / (char .height + char .depth )
1851+ if factor is None :
1852+ factor = target_total / (char .height + char .depth )
18451853 state .fontsize *= factor
18461854 char = Char (sym , state )
18471855
@@ -2114,9 +2122,9 @@ class Parser(object):
21142122 | \| / \backslash \uparrow \downarrow \updownarrow \Uparrow
21152123 \Downarrow \Updownarrow .""" .split ())
21162124
2117- _left_delim = set (r"( [ { < \lfloor \langle \lceil" .split ())
2125+ _left_delim = set (r"( \[ \ { < \lfloor \langle \lceil" .split ())
21182126
2119- _right_delim = set (r") ] } > \rfloor \rangle \rceil" .split ())
2127+ _right_delim = set (r") \] \ } > \rfloor \rangle \rceil" .split ())
21202128
21212129 def __init__ (self ):
21222130 # All forward declarations are here
@@ -2772,8 +2780,6 @@ def _genfrac(self, ldelim, rdelim, rule, style, num, den):
27722780 ldelim = '.'
27732781 if rdelim == '' :
27742782 rdelim = '.'
2775- elif rdelim == r'\}' :
2776- rdelim = '}'
27772783 return self ._auto_sized_delimiter (ldelim , result , rdelim )
27782784 return result
27792785
@@ -2883,16 +2889,18 @@ def _auto_sized_delimiter(self, front, middle, back):
28832889 if len (middle ):
28842890 height = max ([x .height for x in middle ])
28852891 depth = max ([x .depth for x in middle ])
2892+ factor = None
28862893 else :
28872894 height = 0
28882895 depth = 0
2896+ factor = 1.0
28892897 parts = []
28902898 # \left. and \right. aren't supposed to produce any symbols
28912899 if front != '.' :
2892- parts .append (AutoHeightChar (front , height , depth , state ))
2900+ parts .append (AutoHeightChar (front , height , depth , state , factor = factor ))
28932901 parts .extend (middle )
28942902 if back != '.' :
2895- parts .append (AutoHeightChar (back , height , depth , state ))
2903+ parts .append (AutoHeightChar (back , height , depth , state , factor = factor ))
28962904 hlist = Hlist (parts )
28972905 return hlist
28982906
0 commit comments