Skip to content

Commit c1451dd

Browse files
committed
add separate check for descent clipping
1 parent cc09489 commit c1451dd

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

adafruit_display_text/bitmap_label.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -488,23 +488,27 @@ def _place_text(
488488
y_blit_target = 0 # draw the clipped bitmap at y=0
489489

490490
print(
491-
'Warning: Glyph exceeds Ascent/Descent properties: "{}"'.format(
491+
'Warning: Glyph clipped, exceeds Ascent property: "{}"'.format(
492+
char
493+
)
494+
)
495+
496+
if (y_blit_target + my_glyph.height) > bitmap.height:
497+
print(
498+
'Warning: Glyph clipped, exceeds descent property: "{}"'.format(
492499
char
493500
)
494501
)
495502

496503
self._blit(
497504
bitmap,
498505
xposition + my_glyph.dx,
499-
y_clip
500-
+ yposition
501-
- my_glyph.height
502-
- my_glyph.dy, ##### ******
506+
y_blit_target,
503507
my_glyph.bitmap,
504508
x_1=glyph_offset_x,
505509
y_1=y_clip,
506510
x_2=glyph_offset_x + my_glyph.width,
507-
y_2=0 + my_glyph.height,
511+
y_2=my_glyph.height,
508512
skip_index=skip_index, # do not copy over any 0 background pixels
509513
)
510514

0 commit comments

Comments
 (0)