From: Jim Evins Date: Tue, 18 May 2010 00:34:26 +0000 (-0400) Subject: Autosize zint barcode when w == 0 && h == 0. X-Git-Tag: glabels-2_3_0~29 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ee2801d56d29e847b90849f95a14e2cab518718d;p=glabels Autosize zint barcode when w == 0 && h == 0. --- diff --git a/src/bc-zint.c b/src/bc-zint.c index e938c717..5c8502c5 100644 --- a/src/bc-zint.c +++ b/src/bc-zint.c @@ -35,8 +35,8 @@ /*========================================================*/ /* Private macros and constants. */ /*========================================================*/ -#define SHRINK_AMOUNT 0.15 /* shrink bars to account for ink spreading */ -#define FONT_SCALE 0.95 /* Shrink fonts just a hair */ +#define DEFAULT_W 144 +#define DEFAULT_H 72 /*===========================================*/ @@ -51,7 +51,7 @@ gint module_is_set(struct zint_symbol *symbol, gint y_coord, gint x_coord); /* Generate intermediate representation of barcode. */ /*****************************************************************************/ glBarcode * -gl_barcode_zint_new (const gchar *id, +gl_barcode_zint_new (const gchar *id, gboolean text_flag, gboolean checksum_flag, gdouble w, @@ -65,6 +65,13 @@ gl_barcode_zint_new (const gchar *id, symbol = ZBarcode_Create(); + /* Auto set to default size */ + if ( (w == 0) && (h == 0) ) + { + w = DEFAULT_W; + h = DEFAULT_H; + } + /* Assign type flag. Pre-filter by length for subtypes. */ if (g_ascii_strcasecmp (id, "GS1-128") == 0) { symbol->symbology = BARCODE_EAN128; @@ -259,7 +266,7 @@ static glBarcode *render_zint(struct zint_symbol *symbol, gboolean text_flag) { xoffset -= (strlen(symbol->text) / 2) * 5.0; for (p = symbol->text; *p != 0; p++) { - if (p != symbol->text && *p == '(') xoffset += 3.0; + if (p != (gchar *)symbol->text && *p == '(') xoffset += 3.0; bchar = g_new0 (glBarcodeChar, 1); bchar->x = (textpos + xoffset) * scaler; bchar->y = default_text_posn;