@@ -322,7 +322,13 @@ def render_glyph(self, ox, oy, info):
322322 self .image , ox , oy - info .metrics .ymax , info .glyph )
323323
324324 def render_rect_filled (self , x1 , y1 , x2 , y2 ):
325- self .image .draw_rect_filled (x1 , y1 , x2 , max (y2 - 1 , y1 ))
325+ height = max (int (y2 - y1 ) - 1 , 0 )
326+ if height == 0 :
327+ center = (y2 + y1 ) / 2.0
328+ y = int (center - (height + 1 ) / 2.0 )
329+ else :
330+ y = int (y1 )
331+ self .image .draw_rect_filled (int (x1 ), y , ceil (x2 ), y + height )
326332
327333 def get_results (self , box ):
328334 return (self .ox ,
@@ -481,8 +487,8 @@ def destroy(self):
481487 to be destroyed."""
482488 self .used_characters = None
483489
484- def get_kern (self , font1 , sym1 , fontsize1 ,
485- font2 , sym2 , fontsize2 , dpi ):
490+ def get_kern (self , font1 , fontclass1 , sym1 , fontsize1 ,
491+ font2 , fontclass2 , sym2 , fontsize2 , dpi ):
486492 """
487493 Get the kerning distance for font between sym1 and sym2.
488494
@@ -670,7 +676,8 @@ def get_kern(self, font1, fontclass1, sym1, fontsize1,
670676 info2 = self ._get_info (font2 , fontclass2 , sym2 , fontsize2 , dpi )
671677 font = info1 .font
672678 return font .get_kerning (info1 .num , info2 .num , KERNING_DEFAULT ) / 64.0
673- return 0.0
679+ return Fonts .get_kern (self , font1 , fontclass1 , sym1 , fontsize1 ,
680+ font2 , fontclass2 , sym2 , fontsize2 , dpi )
674681
675682class BakomaFonts (TruetypeFonts ):
676683 """
@@ -1123,7 +1130,8 @@ def get_kern(self, font1, fontclass1, sym1, fontsize1,
11231130 font = info1 .font
11241131 return (font .get_kern_dist (info1 .glyph , info2 .glyph )
11251132 * 0.001 * fontsize1 )
1126- return 0.0
1133+ return Fonts .get_kern (self , font1 , fontclass1 , sym1 , fontsize1 ,
1134+ font2 , fontclass2 , sym2 , fontsize2 , dpi )
11271135
11281136 def get_xheight (self , font , fontsize , dpi ):
11291137 cached_font = self ._get_font (font )
@@ -1433,6 +1441,19 @@ def kern(self):
14331441 new_children .append (kern )
14341442 self .children = new_children
14351443
1444+ # This is a failed experiment to fake cross-font kerning.
1445+ # def get_kerning(self, next):
1446+ # if len(self.children) >= 2 and isinstance(self.children[-2], Char):
1447+ # if isinstance(next, Char):
1448+ # print "CASE A"
1449+ # return self.children[-2].get_kerning(next)
1450+ # elif isinstance(next, Hlist) and len(next.children) and isinstance(next.children[0], Char):
1451+ # print "CASE B"
1452+ # result = self.children[-2].get_kerning(next.children[0])
1453+ # print result
1454+ # return result
1455+ # return 0.0
1456+
14361457 def hpack (self , w = 0. , m = 'additional' ):
14371458 """The main duty of hpack is to compute the dimensions of the
14381459 resulting boxes, and to adjust the glue if one of those dimensions is
@@ -2593,13 +2614,6 @@ def sqrt(self, s, loc, toks):
25932614 thickness = state .font_output .get_underline_thickness (
25942615 state .font , state .fontsize , state .dpi )
25952616
2596- if root is None :
2597- root = Box (0. , 0. , 0. )
2598- else :
2599- root = Hlist ([Char (x , state ) for x in root ])
2600- root .shrink ()
2601- root .shrink ()
2602-
26032617 # Determine the height of the body, and add a little extra to
26042618 # the height so it doesn't seem cramped
26052619 height = body .height - body .shift_amount + thickness * 5.0
@@ -2616,10 +2630,18 @@ def sqrt(self, s, loc, toks):
26162630 Fill (),
26172631 padded_body ])
26182632 # Stretch the glue between the hrule and the body
2619- rightside .vpack (height + 1.0 , depth , 'exactly' )
2633+ rightside .vpack (height + (state .fontsize * state .dpi ) / (100.0 * 12.0 ),
2634+ depth , 'exactly' )
26202635
26212636 # Add the root and shift it upward so it is above the tick.
26222637 # The value of 0.6 is a hard-coded hack ;)
2638+ if root is None :
2639+ root = Box (check .width * 0.5 , 0. , 0. )
2640+ else :
2641+ root = Hlist ([Char (x , state ) for x in root ])
2642+ root .shrink ()
2643+ root .shrink ()
2644+
26232645 root_vlist = Vlist ([Hlist ([root ])])
26242646 root_vlist .shift_amount = - height * 0.6
26252647
0 commit comments