-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bitmap label cuts off part of text #201
Comments
Of course could just be garden variety bugs, but I’ll take a guess here, since I thought I dealt with many of the issues with ascenders and descenders (see discord discussion about typeface “Fayette” from Prof. Mia Connelly at Univ Kentucky). First thing to check is whether the font header information that sets up the dimensions is accurate for the typeface glyphs in the file. |
This fixes the bounding box, but not the shift: diff --git a/adafruit_display_text/bitmap_label.py b/adafruit_display_text/bitmap_label.py
index d25b3fd..5dd5bd6 100755
--- a/adafruit_display_text/bitmap_label.py
+++ b/adafruit_display_text/bitmap_label.py
@@ -290,13 +290,17 @@ class Label(LabelBase):
) -> Tuple[int, int, int, int, int, int]:
# pylint: disable=too-many-locals
- ascender_max, descender_max = self._ascent, self._descent
+ bbox = font.get_bounding_box()
+ print(bbox, self._ascent, self._descent)
+ if len(bbox) == 4:
+ ascender_max, descender_max = bbox[1], -bbox[3]
+ else:
+ ascender_max, descender_max = self._ascent, self._descent
lines = 1
- xposition = (
- x_start
- ) = yposition = y_start = 0 # starting x and y position (left margin)
+ # starting x and y position (left margin)
+ xposition = x_start = yposition = y_start = 0
left = None
right = x_start From what I can tell there's a distinction between the ascent/descent of a font and the bounding box of the glyphs. ascent/descent help you lay out text in rows, but a font can exceed the ascent & descent values. As Microsoft puts it, "if it proves convenient, portions of glyphs may extend outside the em square" Microsoft's example (the top and bottom bounds are understood to be the font's ascent and descent): the if/else is necessary because |
Compare the rendering of some text in the "font_league_script_number_one_webfont_72_latin1" (from the circuitpython font bundle) using bitmap and traditional label:
Code for test (qualia + 320x820 bar display)
The text was updated successfully, but these errors were encountered: