68
68
##############################################################################
69
69
# FONTS
70
70
71
- def get_unicode_index (symbol , non_math = False ):
71
+ def get_unicode_index (symbol , math = True ):
72
72
"""get_unicode_index(symbol, [bool]) -> integer
73
73
74
74
Return the integer index (from the Unicode table) of symbol. *symbol*
75
75
can be a single unicode character, a TeX command (i.e. r'\pi'), or a
76
76
Type1 symbol name (i.e. 'phi').
77
- If non_math is True , the current symbol should be treated as a non-math symbol.
77
+ If math is False , the current symbol should be treated as a non-math symbol.
78
78
"""
79
79
# for a non-math symbol, simply return its unicode index
80
- if non_math :
80
+ if not math :
81
81
return ord (symbol )
82
82
# From UTF #25: U+2212 minus sign is the preferred
83
83
# representation of the unary and binary minus sign rather than
@@ -442,7 +442,7 @@ def get_kern(self, font1, fontclass1, sym1, fontsize1,
442
442
"""
443
443
return 0.
444
444
445
- def get_metrics (self , font , font_class , sym , fontsize , dpi , non_math = False ):
445
+ def get_metrics (self , font , font_class , sym , fontsize , dpi , math = True ):
446
446
"""
447
447
*font*: one of the TeX font names::
448
448
@@ -456,7 +456,7 @@ def get_metrics(self, font, font_class, sym, fontsize, dpi, non_math=False):
456
456
457
457
*dpi*: current dots-per-inch
458
458
459
- *non_math *: whether sym is a non- math character
459
+ *math *: whether sym is a math character
460
460
461
461
Returns an object with the following attributes:
462
462
@@ -472,7 +472,7 @@ def get_metrics(self, font, font_class, sym, fontsize, dpi, non_math=False):
472
472
the glyph. This corresponds to TeX's definition of
473
473
"height".
474
474
"""
475
- info = self ._get_info (font , font_class , sym , fontsize , dpi , non_math )
475
+ info = self ._get_info (font , font_class , sym , fontsize , dpi , math )
476
476
return info .metrics
477
477
478
478
def set_canvas_size (self , w , h , d ):
@@ -588,14 +588,14 @@ def _get_offset(self, font, glyph, fontsize, dpi):
588
588
return ((glyph .height / 64.0 / 2.0 ) + (fontsize / 3.0 * dpi / 72.0 ))
589
589
return 0.
590
590
591
- def _get_info (self , fontname , font_class , sym , fontsize , dpi , non_math = False ):
591
+ def _get_info (self , fontname , font_class , sym , fontsize , dpi , math = True ):
592
592
key = fontname , font_class , sym , fontsize , dpi
593
593
bunch = self .glyphd .get (key )
594
594
if bunch is not None :
595
595
return bunch
596
596
597
597
font , num , symbol_name , fontsize , slanted = \
598
- self ._get_glyph (fontname , font_class , sym , fontsize , non_math )
598
+ self ._get_glyph (fontname , font_class , sym , fontsize , math )
599
599
600
600
font .set_size (fontsize , dpi )
601
601
glyph = font .load_char (
@@ -685,7 +685,7 @@ def __init__(self, *args, **kwargs):
685
685
686
686
_slanted_symbols = set (r"\int \oint" .split ())
687
687
688
- def _get_glyph (self , fontname , font_class , sym , fontsize , non_math = False ):
688
+ def _get_glyph (self , fontname , font_class , sym , fontsize , math = True ):
689
689
symbol_name = None
690
690
font = None
691
691
if fontname in self .fontmap and sym in latex_to_bakoma :
@@ -705,7 +705,7 @@ def _get_glyph(self, fontname, font_class, sym, fontsize, non_math=False):
705
705
706
706
if symbol_name is None :
707
707
return self ._stix_fallback ._get_glyph (
708
- fontname , font_class , sym , fontsize , non_math )
708
+ fontname , font_class , sym , fontsize , math )
709
709
710
710
return font , num , symbol_name , fontsize , slanted
711
711
@@ -802,7 +802,7 @@ def __init__(self, *args, **kwargs):
802
802
def _map_virtual_font (self , fontname , font_class , uniindex ):
803
803
return fontname , uniindex
804
804
805
- def _get_glyph (self , fontname , font_class , sym , fontsize , non_math = False ):
805
+ def _get_glyph (self , fontname , font_class , sym , fontsize , math = True ):
806
806
found_symbol = False
807
807
808
808
if self .use_cmex :
@@ -813,7 +813,7 @@ def _get_glyph(self, fontname, font_class, sym, fontsize, non_math=False):
813
813
814
814
if not found_symbol :
815
815
try :
816
- uniindex = get_unicode_index (sym , non_math )
816
+ uniindex = get_unicode_index (sym , math )
817
817
found_symbol = True
818
818
except ValueError :
819
819
uniindex = ord ('?' )
@@ -906,11 +906,11 @@ def __init__(self, *args, **kwargs):
906
906
self .fontmap [key ] = fullpath
907
907
self .fontmap [name ] = fullpath
908
908
909
- def _get_glyph (self , fontname , font_class , sym , fontsize , non_math = False ):
909
+ def _get_glyph (self , fontname , font_class , sym , fontsize , math = True ):
910
910
""" Override prime symbol to use Bakoma """
911
911
if sym == r'\prime' :
912
912
return self .bakoma ._get_glyph (fontname ,
913
- font_class , sym , fontsize , non_math )
913
+ font_class , sym , fontsize , math )
914
914
else :
915
915
# check whether the glyph is available in the display font
916
916
uniindex = get_unicode_index (sym )
@@ -919,10 +919,10 @@ def _get_glyph(self, fontname, font_class, sym, fontsize, non_math=False):
919
919
glyphindex = font .get_char_index (uniindex )
920
920
if glyphindex != 0 :
921
921
return super (DejaVuFonts , self )._get_glyph ('ex' ,
922
- font_class , sym , fontsize , non_math )
922
+ font_class , sym , fontsize , math )
923
923
# otherwise return regular glyph
924
924
return super (DejaVuFonts , self )._get_glyph (fontname ,
925
- font_class , sym , fontsize , non_math )
925
+ font_class , sym , fontsize , math )
926
926
927
927
928
928
class DejaVuSerifFonts (DejaVuFonts ):
@@ -1130,7 +1130,7 @@ def _get_font(self, font):
1130
1130
self .fonts [cached_font .get_fontname ()] = cached_font
1131
1131
return cached_font
1132
1132
1133
- def _get_info (self , fontname , font_class , sym , fontsize , dpi , non_math = False ):
1133
+ def _get_info (self , fontname , font_class , sym , fontsize , dpi , math = True ):
1134
1134
'load the cmfont, metrics and glyph with caching'
1135
1135
key = fontname , sym , fontsize , dpi
1136
1136
tup = self .glyphd .get (key )
@@ -1456,15 +1456,15 @@ class Char(Node):
1456
1456
from width) must be converted into a :class:`Kern` node when the
1457
1457
:class:`Char` is added to its parent :class:`Hlist`.
1458
1458
"""
1459
- def __init__ (self , c , state , non_math = False ):
1459
+ def __init__ (self , c , state , math = True ):
1460
1460
Node .__init__ (self )
1461
1461
self .c = c
1462
1462
self .font_output = state .font_output
1463
1463
self .font = state .font
1464
1464
self .font_class = state .font_class
1465
1465
self .fontsize = state .fontsize
1466
1466
self .dpi = state .dpi
1467
- self .non_math = non_math
1467
+ self .math = math
1468
1468
# The real width, height and depth will be set during the
1469
1469
# pack phase, after we know the real fontsize
1470
1470
self ._update_metrics ()
@@ -1474,7 +1474,7 @@ def __internal_repr__(self):
1474
1474
1475
1475
def _update_metrics (self ):
1476
1476
metrics = self ._metrics = self .font_output .get_metrics (
1477
- self .font , self .font_class , self .c , self .fontsize , self .dpi , self .non_math )
1477
+ self .font , self .font_class , self .c , self .fontsize , self .dpi , self .math )
1478
1478
if self .c == ' ' :
1479
1479
self .width = metrics .advance
1480
1480
else :
@@ -2596,7 +2596,7 @@ def math(self, s, loc, toks):
2596
2596
def non_math (self , s , loc , toks ):
2597
2597
#~ print "non_math", toks
2598
2598
s = toks [0 ].replace (r'\$' , '$' )
2599
- symbols = [Char (c , self .get_state (), non_math = True ) for c in s ]
2599
+ symbols = [Char (c , self .get_state (), math = False ) for c in s ]
2600
2600
hlist = Hlist (symbols )
2601
2601
# We're going into math now, so set font to 'it'
2602
2602
self .push_state ()
0 commit comments