comparison mupdf-source/thirdparty/zint/extras/stroke.c @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 /*
2 * stroke.c
3 *
4 * This code uses Zint to encode data in QR Code and then output in
5 * the correct format to use StrokeScribe 2D font. This can be adapted
6 * to encode any matrix symbology using this font.
7 *
8 * The same code can also be used to resolve PDF417 symbols with the
9 * StrokeScribe 417 font and linear symbols with the StrokeScribe 1D
10 * font, all of which are available from the same souce.
11 *
12 * This code can be compiled with:
13 *
14 * gcc -o stroke stroke.c -lzint
15 *
16 * The fonts are available from:
17 *
18 * https://strokescribe.com/en/free-version-barcode-truetype-fonts.html
19 *
20 */
21
22 #include <stdio.h>
23 #include <zint.h>
24 #include <string.h>
25 int main(int argc, char **argv)
26 {
27 struct zint_symbol *my_symbol;
28 int error = 0;
29 int x, y, glyph, sub;
30
31 my_symbol = ZBarcode_Create();
32
33 my_symbol->symbology = BARCODE_QRCODE; // Change symbology here
34 my_symbol->output_options = OUT_BUFFER_INTERMEDIATE;
35
36 error = ZBarcode_Encode(my_symbol, argv[1], strlen(argv[1]));
37 if (error != 0)
38 {
39 printf("%s\n", my_symbol->errtxt);
40 }
41 if (error >= ZINT_ERROR_TOO_LONG)
42 {
43 ZBarcode_Delete(my_symbol);
44 return 1;
45 }
46
47 sub = 0;
48 glyph = 0;
49 for (y = 0; y < my_symbol->rows; y++) {
50 for (x = 0; x < my_symbol->width; x++) {
51 glyph *= 2;
52 if ((my_symbol->encoded_data[y][x / 8] >> (x % 8)) & 1) {
53 glyph += 1;
54 }
55 sub++;
56 if (sub == 5) {
57 if (glyph <= 25) {
58 printf("%c", glyph + 'A');
59 } else {
60 printf("%c", (glyph - 26) + 'a');
61 }
62 sub = 0;
63 glyph = 0;
64 }
65 }
66 if (sub == 4) {
67 printf("%c", glyph + 'g');
68 }
69 if (sub == 3) {
70 if (glyph <= 3) {
71 printf("%c", glyph + 'w');
72 } else {
73 printf("%c", (glyph - 4) + '0');
74 }
75 }
76 if (sub == 2) {
77 printf("%c", glyph + '4');
78 }
79 if (sub == 1) {
80 printf("%c", glyph + '8');
81 }
82 printf("\n");
83 sub = 0;
84 glyph = 0;
85 }
86
87 ZBarcode_Delete(my_symbol);
88 return 0;
89 }