-
-
Notifications
You must be signed in to change notification settings - Fork 121
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
qrcode: fix vertical space check #2806
Conversation
looks good, thanks a lot! |
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.
hrmmm, what happens if 2x1 isn't available (i.e. we're in ASCII mode)?
in that case, |
i think i'm going to go ahead and add |
only the 2x1 blitter can generate the proper aspect ratio needed for qrcodes, so force its use with NCVISUAL_OPTION_NODEGRADE. see PR #2806.
only the 2x1 blitter can generate the proper aspect ratio needed for qrcodes, so force its use with NCVISUAL_OPTION_NODEGRADE. see PR #2806.
Hmm, hadn't thought about that actually.
I recompiled Notcurses to use NCBLIT_1x1 for QR codes, and while some tall stretched QR codes do seem to work depending on the scanning software, they’re inconsistent at best. Given that, and the rather wonky look, I agree that enforcing a 2x1 blitter should be fine. Most users likely don't expect tall stretched QR codes to function reliably, so that shouldn't break existing code. |
yep, i've gone ahead and implemented this requirement. thanks for the patch and causing me to look at this old-ass code. there are actually several things that ought be done to improve it, now that i look at it (for probably the first time since 2021 or so). |
This PR fixes an if check in Notcurses' QR code rendering function.
This particular if statement is responsible for ensuring atleast 21 rows of space is available, the height for the smallest (version 1) QR code.
However, since the QR code is drawn with the 2x1 blitter (which maps two visual rows to a single terminal row), the effective minimum height becomes 10.5 (well, 11) rows.
Hence, QR codes that can fit in less than 21 rows (versions 1 to 5) are unnecessarily blocked by the current check.
Video demonstrating the current behaviour:
https://github.com/user-attachments/assets/e65fbed3-3f75-4150-bee6-aa4bb48d8165
Video demonstrating the fixed behaviour:
https://github.com/user-attachments/assets/55a3374c-a372-4216-b01d-1cabc31bd19b
Sample code used for the above demos: