Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
qrcode: force 2x1 blitter
Browse files Browse the repository at this point in the history
only the 2x1 blitter can generate the proper aspect ratio
needed for qrcodes, so force its use with
NCVISUAL_OPTION_NODEGRADE. see PR #2806.
dankamongmen committed Nov 16, 2024
1 parent fc2636a commit 1adcf61
Showing 3 changed files with 10 additions and 0 deletions.
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
2 changes: 2 additions & 0 deletions include/notcurses/notcurses.h
Original file line number Diff line number Diff line change
@@ -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)));
3 changes: 3 additions & 0 deletions src/lib/fill.c
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 1adcf61

Please sign in to comment.