aboutsummaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd_qr.c
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-08-06 22:18:53 +0530
committerFlorian Dold <florian.dold@gmail.com>2020-08-06 22:18:53 +0530
commitb4fd96d263b0c71cc6b13a46c477cd96fe0af186 (patch)
tree72ba7b0f766fa883485604870080da1506392872 /src/backend/taler-merchant-httpd_qr.c
parent36e616c4d63e1e945f75b3f0d80fd4d44b678f7e (diff)
implement QR code SVG rendering (fixed #6454)
Diffstat (limited to 'src/backend/taler-merchant-httpd_qr.c')
-rw-r--r--src/backend/taler-merchant-httpd_qr.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/backend/taler-merchant-httpd_qr.c b/src/backend/taler-merchant-httpd_qr.c
index 367a61f5..ddb73167 100644
--- a/src/backend/taler-merchant-httpd_qr.c
+++ b/src/backend/taler-merchant-httpd_qr.c
@@ -72,27 +72,27 @@ TMH_create_qrcode (const char *uri)
return NULL;
}
QRinput_free (qri);
- /* FIXME-Dold: generate <img> with inline SVG instead of <pre> here! */
- GNUNET_buffer_write_str (&buf,
- "<p class=\"qrtext\"><br>\n<br>\n<br>\n<br>\n");
+ GNUNET_buffer_write_fstr (&buf,
+ "<svg width='100mm' height='100mm' viewBox='0 0 %u %u' "
+ "version='1.1' xmlns='http://www.w3.org/2000/svg' "
+ "style='shape-rendering: crispedges;'>\n",
+ qrc->width,
+ qrc->width);
for (unsigned int y = 0; y<qrc->width; y++)
{
- GNUNET_buffer_write_str (&buf,
- "&nbsp;&nbsp;&nbsp;&nbsp;");
for (unsigned int x = 0; x<qrc->width; x++)
{
unsigned int off = x + y * qrc->width;
+ if (0 == (qrc->data[off] & 1))
+ continue;
GNUNET_buffer_write_fstr (&buf,
- "%s",
- (0 != (qrc->data[off] & 1))
- ? "██"
- : "&nbsp;&nbsp;");
+ " <rect x=%u y=%u width=1 height=1 />\n",
+ x,
+ y);
}
- GNUNET_buffer_write_str (&buf,
- "&nbsp;&nbsp;&nbsp;&nbsp;<br>");
}
GNUNET_buffer_write_str (&buf,
- "<br>\n<br>\n<br>\n<br>\n</p>");
+ "</svg>");
QRcode_free (qrc);
return GNUNET_buffer_reap_str (&buf);
}