@@ -246,7 +246,7 @@ def set_canvas_size(self, w, h):
246246
247247 def render_glyph (self , ox , oy , info ):
248248 info .font .draw_glyph_to_bitmap (
249- int ( ox ), int ( oy - info .metrics .ymax ) , info .glyph )
249+ ox , oy - info .metrics .ymax , info .glyph )
250250
251251 def render_rect_filled (self , x1 , y1 , x2 , y2 ):
252252 font = self .fonts_object .get_fonts ()[0 ]
@@ -297,7 +297,7 @@ def __init__(self):
297297 def render_glyph (self , ox , oy , info ):
298298 filename = info .font .fname
299299 oy = self .height - oy + info .offset
300-
300+
301301 self .pswriter .append (('glyph' , ox , oy , filename , info .fontsize , info .num ))
302302
303303 def render_rect_filled (self , x1 , y1 , x2 , y2 ):
@@ -865,15 +865,15 @@ def get_underline_thickness(self, font, fontsize, dpi):
865865# get any smaller
866866NUM_SIZE_LEVELS = 4
867867# Percentage of x-height of additional horiz. space after sub/superscripts
868- SCRIPT_SPACE = 0.3
868+ SCRIPT_SPACE = 0.2
869869# Percentage of x-height that sub/superscripts drop below the baseline
870870SUBDROP = 0.3
871871# Percentage of x-height that superscripts drop below the baseline
872872SUP1 = 0.7
873873# Percentage of x-height that subscripts drop below the baseline
874874SUB1 = 0.0
875875# Percentage of x-height that superscripts are offset relative to the subscript
876- DELTA = 0.25
876+ DELTA = 0.18
877877
878878class MathTextWarning (Warning ):
879879 pass
@@ -1101,19 +1101,20 @@ def kern(self):
11011101 list in the correct way."""
11021102 new_children = []
11031103 num_children = len (self .children )
1104- for i in range (num_children ):
1105- elem = self .children [i ]
1106- if i < num_children - 1 :
1107- next = self .children [i + 1 ]
1108- else :
1109- next = None
1104+ if num_children :
1105+ for i in range (num_children ):
1106+ elem = self .children [i ]
1107+ if i < num_children - 1 :
1108+ next = self .children [i + 1 ]
1109+ else :
1110+ next = None
11101111
1111- new_children .append (elem )
1112- kerning_distance = elem .get_kerning (next )
1113- if kerning_distance != 0. :
1114- kern = Kern (kerning_distance )
1115- new_children .append (kern )
1116- self .children = new_children
1112+ new_children .append (elem )
1113+ kerning_distance = elem .get_kerning (next )
1114+ if kerning_distance != 0. :
1115+ kern = Kern (kerning_distance )
1116+ new_children .append (kern )
1117+ self .children = new_children
11171118
11181119 def hpack (self , w = 0. , m = 'additional' ):
11191120 """The main duty of hpack is to compute the dimensions of the
@@ -1372,9 +1373,15 @@ def __init__(self):
13721373class HCentered (Hlist ):
13731374 """A convenience class to create an Hlist whose contents are centered
13741375 within its enclosing box."""
1375- def __init__ (self , elements ):
1376+ def __init__ (self , elements , is_accent = False ):
1377+ self .is_accent = is_accent
13761378 Hlist .__init__ (self , [SsGlue ()] + elements + [SsGlue ()])
13771379
1380+ def kern (self ):
1381+ Hlist .kern (self )
1382+ if not self .is_accent and isinstance (self .children [- 2 ], Kern ):
1383+ self .children = self .children [:- 2 ] + [SsGlue ()]
1384+
13781385class VCentered (Hlist ):
13791386 """A convenience class to create an Vlist whose contents are centered
13801387 within its enclosing box."""
@@ -1982,7 +1989,7 @@ def accent(self, s, loc, toks):
19821989 else :
19831990 accent = Accent (self ._accent_map [accent ], state )
19841991 shift_amount = accent ._metrics .xmin
1985- centered = HCentered ([accent ])
1992+ centered = HCentered ([accent ], is_accent = True )
19861993 centered .hpack (sym .width , 'exactly' )
19871994 centered .shift_amount = shift_amount
19881995 return Vlist ([
0 commit comments