[glabels] Autosize zint barcode when w == 0 && h == 0.
- From: Jim Evins <jimevins src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glabels] Autosize zint barcode when w == 0 && h == 0.
- Date: Tue, 18 May 2010 00:36:55 +0000 (UTC)
commit ee2801d56d29e847b90849f95a14e2cab518718d
Author: Jim Evins <evins snaught com>
Date: Mon May 17 20:34:26 2010 -0400
Autosize zint barcode when w == 0 && h == 0.
src/bc-zint.c | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/src/bc-zint.c b/src/bc-zint.c
index e938c71..5c8502c 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]