Skip to content
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: force 2x1 blitter #2808

Merged
merged 1 commit into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
This document attempts to list user-visible changes and any major internal
rearrangements of Notcurses.

* 3.0.12 (not yet released)
* Fixed a bug when rendering QR codes into a small area. QR codes now
require NCBLIT_2x1, as that is the only blitter which can generate a
proper aspect ratio. It thus no longer works in an ASCII environment.

* 3.0.11 (2024-10-02)
* We now normalize the return of `nl_langinfo()` according to the behavior
of glibc's `_nl_normalize_charset()`, supporting some atypical synonyms
Expand Down
2 changes: 2 additions & 0 deletions include/notcurses/notcurses.h
Original file line number Diff line number Diff line change
Expand Up @@ -4591,6 +4591,8 @@ API int ncsubproc_destroy(struct ncsubproc* n);
// returned. Otherwise, the QR code "version" (size) is returned. The QR code
// is (version * 4 + 17) columns wide, and ⌈version * 4 + 17⌉ rows tall (the
// properly-scaled values are written back to '*ymax' and '*xmax').
// NCBLIT_2x1 is always used, and the call will fail if it is not available,
// as only this blitter can generate a proper aspect ratio.
API int ncplane_qrcode(struct ncplane* n, unsigned* ymax, unsigned* xmax,
const void* data, size_t len)
__attribute__ ((nonnull (1, 4)));
Expand Down
3 changes: 3 additions & 0 deletions src/lib/fill.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,9 +619,12 @@ int ncplane_qrcode(ncplane* n, unsigned* ymax, unsigned* xmax, const void* data,
free(rgba);
if(ncv){
ret = square;
// we don't allow degredation because 2x1 is the only blitter which
// can generate a qrcode with proper aspect ratio. ascii is thus out.
struct ncvisual_options vopts = {
.n = n,
.blitter = blitfxn,
.flags = NCVISUAL_OPTION_NODEGRADE,
};
if(ncvisual_blit(ncplane_notcurses(n), ncv, &vopts) == n){
ret = square;
Expand Down
Loading