-
Notifications
You must be signed in to change notification settings - Fork 38
Should setting background_tight=True change the label's bounding box? #103
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
Comments
I found a property of adafruit_bitmap_font.bdf called ascent which is: The number of pixels above the baseline of a typical ascender. The ascender property solves my layout problem nicely although when I try to print font.ascent i get "AttributeError: 'BDF' object has no attribute 'ascent'" |
|
Here's the Adobe BDF spec |
There are actually 3 issues here.
|
@kmatch98 This is great. I'm now able to position the text on the right relative to the text on the left. I can tweak the position of the text on the left and the text on the right goes to the correct location without any additional edits. That's the main thing I was trying to do here. However, I notice that the bounding box still doesn't change when you toggle background_tight. I don't depend on the bonding box any more but it does seem like a bug that should probably be fixed. I caught the end of foamyguy's #livebroadcastchat today where people were discussing Jose David M.'s pull request and that seems like the real solution. It sounds like it will let you align two labels along the baseline by setting a property. Here's the way I did it with the latest CP and libraries that I installed last night.
|
@endico HAve you tested the new feature in the library, I would like to hear your input regarding this. Thanks |
It works great, thanks! |
It looks like the new baseline alignment features solved the core of this issue. Closing for now. We can re-open or make a new one in the future if there is further discussion around the |
I have two labels with different sized fonts which I would like to place next to each other along the same baseline. My solution was to place the one on the right in relation to the one on the left using the information in the left's bounding box. This is still a bit off though because the labels have different font sizes so each label has a different amount of padding at the bottom (where the descenders go).
These labels have a contrasting background color and I noticed that when I set background_tight on a label containing numerals that the padding at the bottom disappears and the bottom of the label seems to coincide with the font's baseline. Unfortunately, doing this doesn't change the bounding box. If it did, that would make laying out my numerals a lot easier. And the code would still work after changing the font, adjusting margins or possibly dragging multiple labels around with a touchscreen.
FoamyGuy helped me with a workaround that works fine in my app but this seems useful. I guess the downside is that it won't be very useful for text since a lot of it will have descenders.
Maybe its not worth the trouble? I guess this is more hacky than I originally thought and maybe it would break existing code. However, it does seem to make sense that the bounding box should move when the padding changes.
The text was updated successfully, but these errors were encountered: