Make EAN and UPC symbols resizable in glabels in accordance with EN 797:1996

Reported by Sebastien Marie, thanks!
Fix from upstream (3aeb1ea70a5f5b7c9a235ee29bdd708663f4d1f6)
This commit is contained in:
kirby 2018-02-02 15:08:09 +00:00
parent 9b76bc8f59
commit 9c59161937
2 changed files with 49 additions and 1 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.12 2018/01/10 15:12:08 kirby Exp $
# $OpenBSD: Makefile,v 1.13 2018/02/02 15:08:09 kirby Exp $
COMMENT-main = library for encoding data in several barcode variants
COMMENT-x11 = graphical interface for the zint barcode generator
@ -7,6 +7,7 @@ V = 2.6.2
DISTNAME = zint-${V}.src
PKGNAME-main = zint-${V}
PKGNAME-x11 = zint-gui-${V}
REVISION = 0
SHARED_LIBS += QZint 1.0 # 2.6
SHARED_LIBS += zint 1.0 # 2.6

View File

@ -0,0 +1,47 @@
$OpenBSD: patch-backend_render_c,v 1.1 2018/02/02 15:08:09 kirby Exp $
Make EAN and UPC symbols resizable in glabels in accordance with EN 797:1996
https://github.com/woo-j/zint/commit/3aeb1ea70a5f5b7c9a235ee29bdd708663f4d1f6
Index: backend/render.c
--- backend/render.c.orig
+++ backend/render.c
@@ -267,27 +267,34 @@ int render_plot(struct zint_symbol *symbol, float widt
/* The X-dimension of UPC/EAN symbols is fixed at 0.330mm */
/* The phrase before is questionable. It may scale in certain percentages (80% - 200%).
see https://internationalbarcodes.com/ean-13-specifications/ */
+ // Can now cope with sizes between 80% and 200%, enforces correct aspect ratio
/* NOTE: This code will need adjustment before it correctly deals with composite symbols */
- x_dimension = 0.330;
- width = 0.330 * GL_CONST * total_area_width_x;
- /* The height is also fixed */
+ //x_dimension = 0.330;
+ if (x_dimension < 0.26) {
+ x_dimension = 0.26;
+ }
+ if (x_dimension > 0.66) {
+ x_dimension = 0.66;
+ }
+ width = x_dimension * GL_CONST * total_area_width_x;
+
switch (upceanflag) {
case 6:
case 12:
case 13:
/* UPC-A, UPC-E and EAN-13 */
/* Height of bars should be 22.85mm */
- height = ((0.330 * ((2 * symbol->border_width) + text_offset + text_height)) + 22.85) * GL_CONST;
+ height = ((x_dimension * ((2 * symbol->border_width) + text_offset + text_height)) + (22.85 * (x_dimension / 0.33))) * GL_CONST;
break;
case 8:
/* EAN-8 */
/* Height of bars should be 18.23mm */
- height = ((0.330 * ((2 * symbol->border_width) + text_offset + text_height)) + 18.23) * GL_CONST;
+ height = ((x_dimension * ((2 * symbol->border_width) + text_offset + text_height)) + (18.23 * (x_dimension / 0.33))) * GL_CONST;
break;
default:
/* EAN-2 and EAN-5 */
/* Height of bars should be 21.10mm */
- height = ((0.330 * ((2 * symbol->border_width) + text_offset + text_height)) + 21.10) * GL_CONST;
+ height = ((x_dimension * ((2 * symbol->border_width) + text_offset + text_height)) + (21.10 * (x_dimension / 0.33))) * GL_CONST;
}
}