@@ -771,7 +771,11 @@ def _get_glyph(self, fontname, font_class, sym, fontsize):
771
771
('\leftbrace' , '{' ),
772
772
('\r ightbrace' , '}' ),
773
773
('\leftbracket' , '[' ),
774
- ('\r ightbracket' , ']' )]:
774
+ ('\r ightbracket' , ']' ),
775
+ (r'\{' , '{' ),
776
+ (r'\}' , '}' ),
777
+ (r'\[' , '[' ),
778
+ (r'\]' , ']' )]:
775
779
_size_alternatives [alias ] = _size_alternatives [target ]
776
780
777
781
def get_sized_alternatives_for_symbol (self , fontname , sym ):
@@ -970,6 +974,9 @@ def _map_virtual_font(self, fontname, font_class, uniindex):
970
974
971
975
_size_alternatives = {}
972
976
def get_sized_alternatives_for_symbol (self , fontname , sym ):
977
+ fixes = {'\{' : '{' , '\}' : '}' , '\[' : '[' , '\]' : ']' }
978
+ sym = fixes .get (sym , sym )
979
+
973
980
alternatives = self ._size_alternatives .get (sym )
974
981
if alternatives :
975
982
return alternatives
@@ -1829,7 +1836,7 @@ class AutoHeightChar(Hlist):
1829
1836
fonts), the correct glyph will be selected, otherwise this will
1830
1837
always just return a scaled version of the glyph.
1831
1838
"""
1832
- def __init__ (self , c , height , depth , state , always = False ):
1839
+ def __init__ (self , c , height , depth , state , always = False , factor = None ):
1833
1840
alternatives = state .font_output .get_sized_alternatives_for_symbol (
1834
1841
state .font , c )
1835
1842
@@ -1841,7 +1848,8 @@ def __init__(self, c, height, depth, state, always=False):
1841
1848
if char .height + char .depth >= target_total :
1842
1849
break
1843
1850
1844
- factor = target_total / (char .height + char .depth )
1851
+ if factor is None :
1852
+ factor = target_total / (char .height + char .depth )
1845
1853
state .fontsize *= factor
1846
1854
char = Char (sym , state )
1847
1855
@@ -2114,9 +2122,9 @@ class Parser(object):
2114
2122
| \| / \backslash \uparrow \downarrow \updownarrow \Uparrow
2115
2123
\Downarrow \Updownarrow .""" .split ())
2116
2124
2117
- _left_delim = set (r"( [ { < \lfloor \langle \lceil" .split ())
2125
+ _left_delim = set (r"( [ \ { < \lfloor \langle \lceil" .split ())
2118
2126
2119
- _right_delim = set (r") ] } > \rfloor \rangle \rceil" .split ())
2127
+ _right_delim = set (r") ] \ } > \rfloor \rangle \rceil" .split ())
2120
2128
2121
2129
def __init__ (self ):
2122
2130
# All forward declarations are here
@@ -2772,8 +2780,6 @@ def _genfrac(self, ldelim, rdelim, rule, style, num, den):
2772
2780
ldelim = '.'
2773
2781
if rdelim == '' :
2774
2782
rdelim = '.'
2775
- elif rdelim == r'\}' :
2776
- rdelim = '}'
2777
2783
return self ._auto_sized_delimiter (ldelim , result , rdelim )
2778
2784
return result
2779
2785
@@ -2883,16 +2889,18 @@ def _auto_sized_delimiter(self, front, middle, back):
2883
2889
if len (middle ):
2884
2890
height = max ([x .height for x in middle ])
2885
2891
depth = max ([x .depth for x in middle ])
2892
+ factor = None
2886
2893
else :
2887
2894
height = 0
2888
2895
depth = 0
2896
+ factor = 1.0
2889
2897
parts = []
2890
2898
# \left. and \right. aren't supposed to produce any symbols
2891
2899
if front != '.' :
2892
- parts .append (AutoHeightChar (front , height , depth , state ))
2900
+ parts .append (AutoHeightChar (front , height , depth , state , factor = factor ))
2893
2901
parts .extend (middle )
2894
2902
if back != '.' :
2895
- parts .append (AutoHeightChar (back , height , depth , state ))
2903
+ parts .append (AutoHeightChar (back , height , depth , state , factor = factor ))
2896
2904
hlist = Hlist (parts )
2897
2905
return hlist
2898
2906
0 commit comments