gbarcode 0.98.16-mswin32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +3 -0
- data/COPYING +0 -0
- data/README +199 -0
- data/Rakefile +109 -0
- data/ext/barcode.h +119 -0
- data/ext/barcode_wrap.c +3192 -0
- data/ext/codabar.c +182 -0
- data/ext/code128.c +607 -0
- data/ext/code39.c +173 -0
- data/ext/code93.c +213 -0
- data/ext/ean.c +774 -0
- data/ext/extconf.rb +6 -0
- data/ext/i25.c +164 -0
- data/ext/library.c +244 -0
- data/ext/msi.c +155 -0
- data/ext/pcl.c +200 -0
- data/ext/plessey.c +164 -0
- data/ext/ps.c +272 -0
- data/ext/svg.c +174 -0
- data/extras/mingw-rbconfig.rb +176 -0
- data/lib/gbarcode.so +0 -0
- data/test/assets/gb-code128b.eps +44 -0
- data/test/gbarcode_test.rb +48 -0
- data/test/test_helper.rb +2 -0
- metadata +77 -0
data/ext/svg.c
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
/*
|
2
|
+
* svg.c -- print out the barcode SVG-style
|
3
|
+
*
|
4
|
+
* Copyright (c) 2001 David J. Humphreys (humphrd@tcd.ie)
|
5
|
+
*
|
6
|
+
* This program is free software; you can redistribute it and/or modify
|
7
|
+
* it under the terms of the GNU General Public License as published by
|
8
|
+
* the Free Software Foundation; either version 2 of the License, or
|
9
|
+
* (at your option) any later version.
|
10
|
+
*
|
11
|
+
* This program is distributed in the hope that it will be useful,
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
* GNU General Public License for more details.
|
15
|
+
*
|
16
|
+
* You should have received a copy of the GNU General Public License
|
17
|
+
* along with this program; if not, write to the Free Software
|
18
|
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19
|
+
*
|
20
|
+
*
|
21
|
+
* http://www.onefour.net/barcode/
|
22
|
+
*
|
23
|
+
* Made with a mac! (Tested under os X, 10.1)
|
24
|
+
*
|
25
|
+
* I wanted to output barcodes as SVG for some art work.
|
26
|
+
* This will output everything as an SVG file. This file can
|
27
|
+
* then be inserted into another SVG file.
|
28
|
+
*
|
29
|
+
* I don't want to get into the specifics of SVG files here. I
|
30
|
+
* suppose there will be a few specifics on my website (above) along
|
31
|
+
* with a few examples.
|
32
|
+
*/
|
33
|
+
|
34
|
+
#include <stdio.h>
|
35
|
+
#include <stdlib.h>
|
36
|
+
#include <string.h>
|
37
|
+
#include <ctype.h>
|
38
|
+
#include <errno.h>
|
39
|
+
|
40
|
+
#include "barcode.h"
|
41
|
+
|
42
|
+
/* If there is any need to print out a comment,
|
43
|
+
* then this is the method */
|
44
|
+
int svg_comment(char *Message, FILE *f){
|
45
|
+
fprintf(f, "<!-- %s -->\n",Message);
|
46
|
+
return 0;
|
47
|
+
}
|
48
|
+
|
49
|
+
/* Prints the title (bc->ascii) and the
|
50
|
+
* desc(ription) */
|
51
|
+
int svg_desc(struct Barcode_Item *bc, FILE *f){
|
52
|
+
fprintf(f, "<title>%s</title>\n",bc->ascii);
|
53
|
+
fprintf(f, "<desc>\n");
|
54
|
+
fprintf(f, "\t%s:\t%s\n",bc->encoding,bc->ascii);
|
55
|
+
fprintf(f, "\tGNU-barcode:\t%s\n",BARCODE_VERSION);
|
56
|
+
fprintf(f, "\tbarcode:\thttp://www.gnu.org/\n");
|
57
|
+
fprintf(f, "\tsvg-code:\thttp://www.onefour.net/barcode\n");
|
58
|
+
fprintf(f, "</desc>\n");
|
59
|
+
return 0;
|
60
|
+
}
|
61
|
+
|
62
|
+
/* print out the start of the svg file,
|
63
|
+
* with some xml voodoo. There are a
|
64
|
+
* lot of \"s in this code.
|
65
|
+
* It bounds the svg file by
|
66
|
+
* bc->width or 104 and
|
67
|
+
* bc->height or 100
|
68
|
+
* The title of the file is bc->ascii
|
69
|
+
* NOTE: margins and scale are ignored
|
70
|
+
* the user can simply insert the
|
71
|
+
* svg file into another and then
|
72
|
+
* specify scale and margin.*/
|
73
|
+
int svg_start( struct Barcode_Item *bc, FILE *f){
|
74
|
+
if(bc->height == 0) bc->height = 100;
|
75
|
+
if(bc->width == 0) bc->width = 104;
|
76
|
+
fprintf(f, "<?xml version=\"1.0\" standalone=\"no\"?>\n");
|
77
|
+
fprintf(f, "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0//EN\" \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">\n");
|
78
|
+
fprintf(f, "<svg width=\"%i\" height=\"%i\">\n",bc->width ,bc->height);
|
79
|
+
svg_desc(bc,f);
|
80
|
+
return 0;
|
81
|
+
}
|
82
|
+
|
83
|
+
/* just close the svg file */
|
84
|
+
int svg_end(FILE *f){
|
85
|
+
fprintf(f, "</svg>\n");
|
86
|
+
return 0;
|
87
|
+
}
|
88
|
+
|
89
|
+
/* prints out the code for the bars.
|
90
|
+
* the bars are drawn with rect(angles)
|
91
|
+
* rather than lines. The mathematics
|
92
|
+
* for placing a line then setting the
|
93
|
+
* stroke width gets messy. */
|
94
|
+
int svg_bars(struct Barcode_Item *bc, FILE *f){
|
95
|
+
int
|
96
|
+
i = 0, /* Loop counter */
|
97
|
+
height = 70, /* Each box is 70 pixels in hieght */
|
98
|
+
xpos = 0; /* Where the current box is drawn */
|
99
|
+
int current; /* The current character in partial */
|
100
|
+
int is_bar = 0;
|
101
|
+
|
102
|
+
fprintf(f, "<g fill=\"black\">\n");
|
103
|
+
|
104
|
+
for(i = 0; i < strlen(bc->partial); i++){
|
105
|
+
current = (int)bc->partial[i] - 48;
|
106
|
+
if(current > 9){
|
107
|
+
height = 75; /* Guide bar */
|
108
|
+
current = (int)bc->partial[++i] - 48;
|
109
|
+
i++; /* Skip the following 'a' */
|
110
|
+
}
|
111
|
+
else
|
112
|
+
height = 70;
|
113
|
+
if(is_bar == 1){
|
114
|
+
fprintf(f, "\t<rect x=\"%i\" y=\"0\" ",xpos); /* all bars start at y=0 */
|
115
|
+
fprintf(f, "height=\"%i\" width=\"%i\" stroke-width=\"0\"/>\n",height,current);
|
116
|
+
is_bar = 0;
|
117
|
+
}
|
118
|
+
else
|
119
|
+
is_bar = 1;
|
120
|
+
xpos += current;
|
121
|
+
}
|
122
|
+
fprintf(f, "</g>\n");
|
123
|
+
return 0;
|
124
|
+
}
|
125
|
+
|
126
|
+
/* positions the characters that will
|
127
|
+
* be printed. This assumes they will
|
128
|
+
* be under the barcode.*/
|
129
|
+
int svg_text(struct Barcode_Item *bc, FILE *f){
|
130
|
+
unsigned
|
131
|
+
i = 0,
|
132
|
+
j = 0,
|
133
|
+
infosz = strlen(bc->textinfo),
|
134
|
+
xpos = 0,
|
135
|
+
prev_x = 0,
|
136
|
+
correction = 0; /* This correction seems to be needed to align text properly */
|
137
|
+
double dub1, dub2;
|
138
|
+
char printer;
|
139
|
+
char *temp_info = malloc(infosz);
|
140
|
+
if(!temp_info)
|
141
|
+
return -1;
|
142
|
+
fprintf(f, "<g font-family=\"Helvitica\" font-size=\"12\">\n");
|
143
|
+
|
144
|
+
while(i < infosz){
|
145
|
+
for(j = 0; bc->textinfo[i + j + 1] != ' ' &&
|
146
|
+
bc->textinfo[i + j + 1] != '\0';j++); /* Empty loop, just increment j */
|
147
|
+
|
148
|
+
j ++;
|
149
|
+
strncpy(temp_info, (bc->textinfo + i),j);
|
150
|
+
sscanf(temp_info, "%lf:%lf:%c", &dub1, &dub2, &printer);
|
151
|
+
i += j;
|
152
|
+
|
153
|
+
xpos = (int)dub1;
|
154
|
+
if((xpos - prev_x) >= 10)
|
155
|
+
correction += 2;
|
156
|
+
|
157
|
+
prev_x = xpos;
|
158
|
+
fprintf(f, "\t<text x=\"%i\" y=\"%i\">%c</text>\n",(xpos - correction),80,printer);
|
159
|
+
}
|
160
|
+
fprintf(f, "</g>\n");
|
161
|
+
free(temp_info);
|
162
|
+
return 0;
|
163
|
+
}
|
164
|
+
|
165
|
+
/* This is the function to call. It calls the
|
166
|
+
* functions above in order. Thers is no real
|
167
|
+
* error detection in this code. */
|
168
|
+
int Barcode_svg_print(struct Barcode_Item *bc, FILE *f){
|
169
|
+
svg_start(bc,f);
|
170
|
+
svg_bars(bc,f);
|
171
|
+
svg_text(bc,f); /* Should test for text output bit in flags */
|
172
|
+
svg_end(f);
|
173
|
+
return 0;
|
174
|
+
}
|
@@ -0,0 +1,176 @@
|
|
1
|
+
|
2
|
+
# This rbconfig.rb corresponds to a Ruby installation for win32 cross-compiled
|
3
|
+
# with mingw under i686-linux. It can be used to cross-compile extensions for
|
4
|
+
# win32 using said toolchain.
|
5
|
+
#
|
6
|
+
# This file assumes that a cross-compiled mingw32 build (compatible with the
|
7
|
+
# mswin32 builds) is installed under $HOME/ruby-mingw32.
|
8
|
+
|
9
|
+
module Config
|
10
|
+
#RUBY_VERSION == "1.8.5" or
|
11
|
+
# raise "ruby lib version (1.8.5) doesn't match executable version (#{RUBY_VERSION})"
|
12
|
+
|
13
|
+
mingw32 = ENV['MINGW32_RUBY'] || "#{ENV["HOME"]}/ruby-mingw32"
|
14
|
+
mingwpre = ENV['MINGW32_PREFIX']
|
15
|
+
TOPDIR = File.dirname(__FILE__).chomp!("/lib/ruby/1.8/i386-mingw32")
|
16
|
+
DESTDIR = '' unless defined? DESTDIR
|
17
|
+
CONFIG = {}
|
18
|
+
CONFIG["DESTDIR"] = DESTDIR
|
19
|
+
CONFIG["INSTALL"] = "/usr/bin/install -c"
|
20
|
+
CONFIG["prefix"] = (TOPDIR || DESTDIR + mingw32)
|
21
|
+
CONFIG["EXEEXT"] = ".exe"
|
22
|
+
CONFIG["ruby_install_name"] = "ruby"
|
23
|
+
CONFIG["RUBY_INSTALL_NAME"] = "ruby"
|
24
|
+
CONFIG["RUBY_SO_NAME"] = "msvcrt-ruby18"
|
25
|
+
CONFIG["SHELL"] = "/bin/sh"
|
26
|
+
CONFIG["PATH_SEPARATOR"] = ":"
|
27
|
+
CONFIG["PACKAGE_NAME"] = ""
|
28
|
+
CONFIG["PACKAGE_TARNAME"] = ""
|
29
|
+
CONFIG["PACKAGE_VERSION"] = ""
|
30
|
+
CONFIG["PACKAGE_STRING"] = ""
|
31
|
+
CONFIG["PACKAGE_BUGREPORT"] = ""
|
32
|
+
CONFIG["exec_prefix"] = "$(prefix)"
|
33
|
+
CONFIG["bindir"] = "$(exec_prefix)/bin"
|
34
|
+
CONFIG["sbindir"] = "$(exec_prefix)/sbin"
|
35
|
+
CONFIG["libexecdir"] = "$(exec_prefix)/libexec"
|
36
|
+
CONFIG["datadir"] = "$(prefix)/share"
|
37
|
+
CONFIG["sysconfdir"] = "$(prefix)/etc"
|
38
|
+
CONFIG["sharedstatedir"] = "$(prefix)/com"
|
39
|
+
CONFIG["localstatedir"] = "$(prefix)/var"
|
40
|
+
CONFIG["libdir"] = "$(exec_prefix)/lib"
|
41
|
+
CONFIG["includedir"] = "$(prefix)/include"
|
42
|
+
CONFIG["oldincludedir"] = "/usr/include"
|
43
|
+
CONFIG["infodir"] = "$(prefix)/info"
|
44
|
+
CONFIG["mandir"] = "$(prefix)/man"
|
45
|
+
CONFIG["build_alias"] = "i686-linux"
|
46
|
+
CONFIG["host_alias"] = "#{mingwpre}"
|
47
|
+
CONFIG["target_alias"] = "i386-mingw32"
|
48
|
+
CONFIG["ECHO_C"] = ""
|
49
|
+
CONFIG["ECHO_N"] = "-n"
|
50
|
+
CONFIG["ECHO_T"] = ""
|
51
|
+
CONFIG["LIBS"] = "-lwsock32 "
|
52
|
+
CONFIG["MAJOR"] = "1"
|
53
|
+
CONFIG["MINOR"] = "8"
|
54
|
+
CONFIG["TEENY"] = "4"
|
55
|
+
CONFIG["build"] = "i686-pc-linux"
|
56
|
+
CONFIG["build_cpu"] = "i686"
|
57
|
+
CONFIG["build_vendor"] = "pc"
|
58
|
+
CONFIG["build_os"] = "linux"
|
59
|
+
CONFIG["host"] = "i586-pc-mingw32msvc"
|
60
|
+
CONFIG["host_cpu"] = "i586"
|
61
|
+
CONFIG["host_vendor"] = "pc"
|
62
|
+
CONFIG["host_os"] = "mingw32msvc"
|
63
|
+
CONFIG["target"] = "i386-pc-mingw32"
|
64
|
+
CONFIG["target_cpu"] = "i386"
|
65
|
+
CONFIG["target_vendor"] = "pc"
|
66
|
+
CONFIG["target_os"] = "mingw32"
|
67
|
+
CONFIG["CC"] = "#{mingwpre}-gcc"
|
68
|
+
CONFIG["CFLAGS"] = "-g -O2 "
|
69
|
+
CONFIG["LDFLAGS"] = ""
|
70
|
+
CONFIG["CPPFLAGS"] = ""
|
71
|
+
CONFIG["OBJEXT"] = "o"
|
72
|
+
CONFIG["CPP"] = "#{mingwpre}-gcc -E"
|
73
|
+
CONFIG["EGREP"] = "grep -E"
|
74
|
+
CONFIG["GNU_LD"] = "yes"
|
75
|
+
CONFIG["CPPOUTFILE"] = "-o conftest.i"
|
76
|
+
CONFIG["OUTFLAG"] = "-o "
|
77
|
+
CONFIG["YACC"] = "bison -y"
|
78
|
+
CONFIG["RANLIB"] = "#{mingwpre}-ranlib"
|
79
|
+
CONFIG["AR"] = "#{mingwpre}-ar"
|
80
|
+
CONFIG["NM"] = "#{mingwpre}-nm"
|
81
|
+
CONFIG["WINDRES"] = "#{mingwpre}-windres"
|
82
|
+
CONFIG["DLLWRAP"] = "#{mingwpre}-dllwrap"
|
83
|
+
CONFIG["OBJDUMP"] = "#{mingwpre}-objdump"
|
84
|
+
CONFIG["LN_S"] = "ln -s"
|
85
|
+
CONFIG["SET_MAKE"] = ""
|
86
|
+
CONFIG["INSTALL_PROGRAM"] = "$(INSTALL)"
|
87
|
+
CONFIG["INSTALL_SCRIPT"] = "$(INSTALL)"
|
88
|
+
CONFIG["INSTALL_DATA"] = "$(INSTALL) -m 644"
|
89
|
+
CONFIG["RM"] = "rm -f"
|
90
|
+
CONFIG["CP"] = "cp"
|
91
|
+
CONFIG["MAKEDIRS"] = "mkdir -p"
|
92
|
+
CONFIG["LIBOBJS"] = " fileblocks$(U).o crypt$(U).o flock$(U).o acosh$(U).o win32$(U).o"
|
93
|
+
CONFIG["ALLOCA"] = ""
|
94
|
+
CONFIG["DLDFLAGS"] = " -Wl,--enable-auto-import,--export-all"
|
95
|
+
CONFIG["ARCH_FLAG"] = ""
|
96
|
+
CONFIG["STATIC"] = ""
|
97
|
+
CONFIG["CCDLFLAGS"] = ""
|
98
|
+
CONFIG["LDSHARED"] = "#{mingwpre}-gcc -shared -s"
|
99
|
+
CONFIG["DLEXT"] = "so"
|
100
|
+
CONFIG["DLEXT2"] = "dll"
|
101
|
+
CONFIG["LIBEXT"] = "a"
|
102
|
+
CONFIG["LINK_SO"] = ""
|
103
|
+
CONFIG["LIBPATHFLAG"] = " -L\"%s\""
|
104
|
+
CONFIG["RPATHFLAG"] = ""
|
105
|
+
CONFIG["LIBPATHENV"] = ""
|
106
|
+
CONFIG["TRY_LINK"] = ""
|
107
|
+
CONFIG["STRIP"] = "strip"
|
108
|
+
CONFIG["EXTSTATIC"] = ""
|
109
|
+
CONFIG["setup"] = "Setup"
|
110
|
+
CONFIG["MINIRUBY"] = "ruby -rfake"
|
111
|
+
CONFIG["PREP"] = "fake.rb"
|
112
|
+
CONFIG["RUNRUBY"] = "$(MINIRUBY) -I`cd $(srcdir)/lib; pwd`"
|
113
|
+
CONFIG["EXTOUT"] = ".ext"
|
114
|
+
CONFIG["ARCHFILE"] = ""
|
115
|
+
CONFIG["RDOCTARGET"] = ""
|
116
|
+
CONFIG["XCFLAGS"] = " -DRUBY_EXPORT"
|
117
|
+
CONFIG["XLDFLAGS"] = " -Wl,--stack,0x02000000 -L."
|
118
|
+
CONFIG["LIBRUBY_LDSHARED"] = "#{mingwpre}-gcc -shared -s"
|
119
|
+
CONFIG["LIBRUBY_DLDFLAGS"] = " -Wl,--enable-auto-import,--export-all -Wl,--out-implib=$(LIBRUBY)"
|
120
|
+
CONFIG["rubyw_install_name"] = "rubyw"
|
121
|
+
CONFIG["RUBYW_INSTALL_NAME"] = "rubyw"
|
122
|
+
CONFIG["LIBRUBY_A"] = "lib$(RUBY_SO_NAME)-static.a"
|
123
|
+
CONFIG["LIBRUBY_SO"] = "$(RUBY_SO_NAME).dll"
|
124
|
+
CONFIG["LIBRUBY_ALIASES"] = ""
|
125
|
+
CONFIG["LIBRUBY"] = "lib$(LIBRUBY_SO).a"
|
126
|
+
CONFIG["LIBRUBYARG"] = "$(LIBRUBYARG_SHARED)"
|
127
|
+
CONFIG["LIBRUBYARG_STATIC"] = "-l$(RUBY_SO_NAME)-static"
|
128
|
+
CONFIG["LIBRUBYARG_SHARED"] = "-l$(RUBY_SO_NAME)"
|
129
|
+
CONFIG["SOLIBS"] = "$(LIBS)"
|
130
|
+
CONFIG["DLDLIBS"] = ""
|
131
|
+
CONFIG["ENABLE_SHARED"] = "yes"
|
132
|
+
CONFIG["MAINLIBS"] = ""
|
133
|
+
CONFIG["COMMON_LIBS"] = "m"
|
134
|
+
CONFIG["COMMON_MACROS"] = ""
|
135
|
+
CONFIG["COMMON_HEADERS"] = "windows.h winsock.h"
|
136
|
+
CONFIG["EXPORT_PREFIX"] = ""
|
137
|
+
CONFIG["MINIOBJS"] = "dmydln.o"
|
138
|
+
CONFIG["MAKEFILES"] = "Makefile GNUmakefile"
|
139
|
+
CONFIG["arch"] = "i386-mingw32"
|
140
|
+
CONFIG["sitearch"] = "i386-msvcrt"
|
141
|
+
CONFIG["sitedir"] = "$(prefix)/lib/ruby/site_ruby"
|
142
|
+
CONFIG["configure_args"] = "'--host=#{mingwpre}' '--target=i386-mingw32' '--build=i686-linux' '--prefix=#{mingw32}' 'build_alias=i686-linux' 'host_alias=#{mingwpre}' 'target_alias=i386-mingw32'"
|
143
|
+
CONFIG["NROFF"] = "/usr/bin/nroff"
|
144
|
+
CONFIG["MANTYPE"] = "doc"
|
145
|
+
CONFIG["LTLIBOBJS"] = " fileblocks$(U).lo crypt$(U).lo flock$(U).lo acosh$(U).lo win32$(U).lo"
|
146
|
+
CONFIG["ruby_version"] = "$(MAJOR).$(MINOR)"
|
147
|
+
CONFIG["rubylibdir"] = "$(libdir)/ruby/$(ruby_version)"
|
148
|
+
CONFIG["archdir"] = "$(rubylibdir)/$(arch)"
|
149
|
+
CONFIG["sitelibdir"] = "$(sitedir)/$(ruby_version)"
|
150
|
+
CONFIG["sitearchdir"] = "$(sitelibdir)/$(sitearch)"
|
151
|
+
CONFIG["topdir"] = File.dirname(__FILE__)
|
152
|
+
MAKEFILE_CONFIG = {}
|
153
|
+
CONFIG.each{|k,v| MAKEFILE_CONFIG[k] = v.dup}
|
154
|
+
def Config::expand(val, config = CONFIG)
|
155
|
+
val.gsub!(/\$\$|\$\(([^()]+)\)|\$\{([^{}]+)\}/) do |var|
|
156
|
+
if !(v = $1 || $2)
|
157
|
+
'$'
|
158
|
+
elsif key = config[v = v[/\A[^:]+(?=(?::(.*?)=(.*))?\z)/]]
|
159
|
+
pat, sub = $1, $2
|
160
|
+
config[v] = false
|
161
|
+
Config::expand(key, config)
|
162
|
+
config[v] = key
|
163
|
+
key = key.gsub(/#{Regexp.quote(pat)}(?=\s|\z)/n) {sub} if pat
|
164
|
+
key
|
165
|
+
else
|
166
|
+
var
|
167
|
+
end
|
168
|
+
end
|
169
|
+
val
|
170
|
+
end
|
171
|
+
CONFIG.each_value do |val|
|
172
|
+
Config::expand(val)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
RbConfig = Config # compatibility for ruby-1.9
|
176
|
+
CROSS_COMPILING = nil unless defined? CROSS_COMPILING
|
data/lib/gbarcode.so
ADDED
Binary file
|
@@ -0,0 +1,44 @@
|
|
1
|
+
%!PS-Adobe-2.0 EPSF-1.2
|
2
|
+
%%Creator: libbarcode
|
3
|
+
%%BoundingBox: 0 0 143 100
|
4
|
+
%%EndComments
|
5
|
+
% Printing barcode for "Gbarcode", scaled 1.00, encoded using "code 128-B"
|
6
|
+
% The space/bar succession is represented by the following widths (space first):
|
7
|
+
% 02112142113131214211211241212411411221341111412211122143141112331112
|
8
|
+
[
|
9
|
+
% height xpos ypos width height xpos ypos width
|
10
|
+
[75.00 11.00 15.00 1.85] [75.00 13.50 15.00 0.85]
|
11
|
+
[75.00 16.50 15.00 0.85] [70.00 22.00 20.00 1.85]
|
12
|
+
[70.00 24.50 20.00 0.85] [70.00 28.50 20.00 0.85]
|
13
|
+
[70.00 32.50 20.00 0.85] [70.00 35.50 20.00 0.85]
|
14
|
+
[70.00 41.00 20.00 1.85] [70.00 43.50 20.00 0.85]
|
15
|
+
[70.00 46.50 20.00 0.85] [70.00 49.00 20.00 1.85]
|
16
|
+
[70.00 54.50 20.00 0.85] [70.00 57.50 20.00 0.85]
|
17
|
+
[70.00 62.00 20.00 3.85] [70.00 65.50 20.00 0.85]
|
18
|
+
[70.00 70.50 20.00 0.85] [70.00 73.00 20.00 1.85]
|
19
|
+
[70.00 76.50 20.00 0.85] [70.00 82.00 20.00 3.85]
|
20
|
+
[70.00 85.50 20.00 0.85] [70.00 87.50 20.00 0.85]
|
21
|
+
[70.00 92.50 20.00 0.85] [70.00 96.00 20.00 1.85]
|
22
|
+
[70.00 98.50 20.00 0.85] [70.00 101.00 20.00 1.85]
|
23
|
+
[70.00 104.50 20.00 0.85] [70.00 110.50 20.00 2.85]
|
24
|
+
[70.00 115.00 20.00 3.85] [70.00 118.50 20.00 0.85]
|
25
|
+
[75.00 121.00 15.00 1.85] [75.00 126.50 15.00 2.85]
|
26
|
+
[75.00 129.50 15.00 0.85] [75.00 132.00 15.00 1.85]
|
27
|
+
|
28
|
+
] { {} forall setlinewidth moveto 0 exch rlineto stroke} bind forall
|
29
|
+
[
|
30
|
+
% char xpos ypos fontsize
|
31
|
+
[(G) 21.00 10.00 12.00]
|
32
|
+
[(b) 32.00 10.00 0.00]
|
33
|
+
[(a) 43.00 10.00 0.00]
|
34
|
+
[(r) 54.00 10.00 0.00]
|
35
|
+
[(c) 65.00 10.00 0.00]
|
36
|
+
[(o) 76.00 10.00 0.00]
|
37
|
+
[(d) 87.00 10.00 0.00]
|
38
|
+
[(e) 98.00 10.00 0.00]
|
39
|
+
] { {} forall dup 0.00 ne {
|
40
|
+
/Helvetica findfont exch scalefont setfont
|
41
|
+
} {pop} ifelse
|
42
|
+
moveto show} bind forall
|
43
|
+
% End barcode for "Gbarcode"
|
44
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class GbarcodeTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@@BC_TEXT = "Gbarcode"
|
7
|
+
@@BC = Gbarcode.barcode_create(@@BC_TEXT)
|
8
|
+
Gbarcode.barcode_encode(@@BC, Gbarcode::BARCODE_128B)
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
Gbarcode.barcode_delete(@@BC)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_barcode_create
|
16
|
+
assert(@@BC != nil, "BC not created")
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_barcode_delete
|
20
|
+
r = Gbarcode.barcode_delete(Gbarcode.barcode_create(@@BC_TEXT))
|
21
|
+
assert(r == 0, "barcode_delete failed")
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_ascii
|
25
|
+
assert_equal(@@BC.ascii, "Gbarcode")
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_barcode_encode
|
29
|
+
b = Gbarcode.barcode_create("1234")
|
30
|
+
r = Gbarcode.barcode_encode(b, Gbarcode::BARCODE_39)
|
31
|
+
assert(r == 0, "encoding unsuccessful")
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_encoding
|
35
|
+
assert_equal(@@BC.encoding, "code 128-B")
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_barcode_print
|
39
|
+
r,w = File.pipe
|
40
|
+
Gbarcode.barcode_print(@@BC,w,0)
|
41
|
+
w.close()
|
42
|
+
b = r.readlines().join("\n")
|
43
|
+
r.close()
|
44
|
+
f = File.open(File.dirname(__FILE__) + "/ assets/gb-code128b.eps").readlines.join("\n")
|
45
|
+
assert_equal(b,f)
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
data/test/test_helper.rb
ADDED