@@ -768,21 +768,25 @@ def __init__(self, *args, **kwargs):
768
768
def _map_virtual_font (self , fontname , font_class , uniindex ):
769
769
# Handle these "fonts" that are actually embedded in
770
770
# other fonts.
771
- mapping = stix_virtual_fonts .get (fontname )
772
- if (self ._sans and mapping is None
771
+ font_mapping = stix_virtual_fonts .get (fontname )
772
+ if (self ._sans and font_mapping is None
773
773
and fontname not in ('regular' , 'default' )):
774
- mapping = stix_virtual_fonts ['sf' ]
774
+ font_mapping = stix_virtual_fonts ['sf' ]
775
775
doing_sans_conversion = True
776
776
else :
777
777
doing_sans_conversion = False
778
778
779
- if mapping is not None :
780
- if isinstance (mapping , dict ):
781
- try :
782
- mapping = mapping [font_class ]
783
- except KeyError :
784
- mapping = mapping ['rm' ]
779
+ if isinstance (font_mapping , dict ):
780
+ try :
781
+ mapping = font_mapping [font_class ]
782
+ except KeyError :
783
+ mapping = font_mapping ['rm' ]
784
+ elif isinstance (font_mapping , list ):
785
+ mapping = font_mapping
786
+ else :
787
+ mapping = None
785
788
789
+ if mapping is not None :
786
790
# Binary search for the source glyph
787
791
lo = 0
788
792
hi = len (mapping )
@@ -1965,11 +1969,14 @@ def csnames(group, names):
1965
1969
ends_with_alpha .append (name )
1966
1970
else :
1967
1971
ends_with_nonalpha .append (name )
1968
- return Regex (r"\\(?P<{}>(?:{})(?![A-Za-z]){})" .format (
1969
- group ,
1970
- "|" .join (map (re .escape , ends_with_alpha )),
1971
- "" .join (f"|{ s } " for s in map (re .escape , ends_with_nonalpha )),
1972
- ))
1972
+ return Regex (
1973
+ r"\\(?P<{group}>(?:{alpha})(?![A-Za-z]){additional}{nonalpha})" .format (
1974
+ group = group ,
1975
+ alpha = "|" .join (map (re .escape , ends_with_alpha )),
1976
+ additional = "|" if ends_with_nonalpha else "" ,
1977
+ nonalpha = "|" .join (map (re .escape , ends_with_nonalpha )),
1978
+ )
1979
+ )
1973
1980
1974
1981
p .float_literal = Regex (r"[-+]?([0-9]+\.?[0-9]*|\.[0-9]+)" )
1975
1982
p .space = oneOf (self ._space_widths )("space" )
@@ -2458,9 +2465,9 @@ def subsuper(self, s, loc, toks):
2458
2465
hlist .hpack (width , 'exactly' )
2459
2466
vlist .extend ([Vbox (0 , vgap ), hlist ])
2460
2467
shift = hlist .height + vgap + nucleus .depth
2461
- vlist = Vlist (vlist )
2462
- vlist .shift_amount = shift
2463
- result = Hlist ([vlist ])
2468
+ vlt = Vlist (vlist )
2469
+ vlt .shift_amount = shift
2470
+ result = Hlist ([vlt ])
2464
2471
return [result ]
2465
2472
2466
2473
# We remove kerning on the last character for consistency (otherwise
@@ -2781,20 +2788,20 @@ def substack(self, toks):
2781
2788
parts = toks ["parts" ]
2782
2789
state = self .get_state ()
2783
2790
thickness = state .get_current_underline_thickness ()
2784
- vlist = []
2785
2791
2786
2792
hlist = [Hlist (k ) for k in parts [0 ]]
2787
2793
max_width = max (map (lambda c : c .width , hlist ))
2788
2794
2795
+ vlist = []
2789
2796
for sub in hlist :
2790
2797
cp = HCentered ([sub ])
2791
2798
cp .hpack (max_width , 'exactly' )
2792
2799
vlist .append (cp )
2793
2800
2794
- vlist = [val for pair in zip ( vlist ,
2795
- [Vbox (0 , thickness * 2 )] *
2796
- len ( vlist )) for val in pair ]
2797
- del vlist [- 1 ]
2798
- vlt = Vlist (vlist )
2801
+ stack = [val
2802
+ for pair in zip ( vlist , [Vbox (0 , thickness * 2 )] * len ( vlist ))
2803
+ for val in pair ]
2804
+ del stack [- 1 ]
2805
+ vlt = Vlist (stack )
2799
2806
result = [Hlist ([vlt ])]
2800
2807
return result
0 commit comments