File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -478,13 +478,31 @@ def _place_text(
478478 ) # for type BuiltinFont, this creates the x-offset in the glyph bitmap.
479479 # for BDF loaded fonts, this should equal 0
480480
481+ y_blit_target = yposition - my_glyph .height - my_glyph .dy
482+
483+ # Clip glyph y-direction if outside the font ascent/descent metrics.
484+ # Note: bitmap.blit will automatically clip the bottom of the glyph.
485+ y_clip = 0
486+ if (y_blit_target ) < 0 :
487+ y_clip = - (y_blit_target ) # clip this amount from top of bitmap
488+ y_blit_target = 0 # draw the clipped bitmap at y=0
489+
490+ print (
491+ 'Warning: Glyph exceeds Ascent/Descent properties: "{}"' .format (
492+ char
493+ )
494+ )
495+
481496 self ._blit (
482497 bitmap ,
483498 xposition + my_glyph .dx ,
484- yposition - my_glyph .height - my_glyph .dy ,
499+ y_clip
500+ + yposition
501+ - my_glyph .height
502+ - my_glyph .dy , ##### ******
485503 my_glyph .bitmap ,
486504 x_1 = glyph_offset_x ,
487- y_1 = 0 ,
505+ y_1 = y_clip ,
488506 x_2 = glyph_offset_x + my_glyph .width ,
489507 y_2 = 0 + my_glyph .height ,
490508 skip_index = skip_index , # do not copy over any 0 background pixels
You can’t perform that action at this time.
0 commit comments