-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
displayio arg validation tweaking #7867
Conversation
I'm realizing the only reason I hesitated adding the test for the 0 width/height object for the border wrap issue is that I don't know how to call a micropython max() function. Is there a way to call something like i.e.
rather than:
|
|
Thanks @dhalbert! I'm pretty sure you already pointed me at those macros a while back, sorry for may poor memory 😢. I really appreciate all the support you've given me over the past couple years 😁 |
I don't think 0 width or 0 height blitting should be valid. It should always have some pixels to blit. The client code shouldn't try it. |
I kind of disagree, since it makes some client-side algorithms easier for the edge cases. Similar to how drawing things off the edges are OK, |
The decision about blitting zero width or height bitmaps is above my pay grade 😁 but in case it helps I poked around the libraries for awhile. I believe the MagTag issue stems from this code fragment in the adafruit_bitmap_font.pcf libarary:
It seems that PCF font space characters have a calculated width and height of zero but the character_width is non-zero. I was able to modify the adafruit_bitmap_font and adafruit_display_text libraries so that they didn't attempt to blit the space character but in order to keep track of the spacing I ended up storing a "space holder" glyph with the bitmap set to None. This solution felt like a hack and I'm sure there's a better way to handle it. I don't know if there are other library modules that blit 0 by 0 bitmaps when they want to move the current position forward though. The changes I made were: ADAFRUIT_BITMAP_FONT.PCF
ADAFRUIT_DISPLAY_TEXT.BITMAP_LABEL
|
Ok, makes sense. 0 width or height is fine with me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
The Magtag Google Calendar from the learning guide uses some Arial PCF fonts that apparently contain bitmap elements with a width and height of 0. The DisplayIO argument validations introduced in #7548 cause the example code to fail.
This PR increases the valid range for width and height from 1-32767 to 0-32767 and increases the maximum valid value for x, y, x1 and y1 in the
displayio_bitmap_obj_blit
function by 1 (I believe this was how it was validated prior to #7548). This prevents a bitmap object of width or height of zero from being validated against a range of 0 to -1.In looking through the original issue #7540, it looks like the
displayio_bitmap_obj_blit
function change might have been introduced to cause a crash with a useful error message rather than incorrectly wrapping the display, but I didn't know if it was worth throwing in the extra code to identify the 0 width and/or height case and validating it separately from the potential wrap case. I also have not actually tested if the border wrap occurs.