[barcode] proposed code change

Alessandro Rubini rubini@gnu.org
Fri, 16 Aug 2002 09:15:06 +0200


Hi. Thanks for your message.

Actually, the idea of adding text labels is pretty old. I received a patch
by Rob Seace in March 2000. He modified the input format in this way:

  <BC>:1111111111                                                                 
  BOGUS TITLE ONE                                                                 
  Our Price: $11.11                                                               
  Bogus Bookstores, Inc.                                                          
  <BC>:2222222222                                                                 
  BOGUS TITLE TWO                                                                 
  Our Price: $22.22                                                               
  Bogus Bookstores, Inc.                                                          

He only changed the cmdline frontend, not the backend. I didn't integrate
the patch mainly for the same reasons I detail below. Plus, it's not compatible
with current behaviour and making it compatible is boring.

> When the barcode program reads input from a file or from stdin, if that
> input is comma delimited and the part before the comma is a valid EAN-8,
> EAN-13 or UPC code, the part after the comma will be treated as "extra text"
> to be printed in ASCII.

I like this, as it is compatible, but there are drawbacks. I list
them one-paragraph-each.

Some encodings (although not the UPC/EAN sets) can use the
comma. Actually, all 7-bit ASCII symbols can be encoded so we can't
choose a separator that always works (short of going to 8-bit codes,
but these may be hairy to represent and their meaning varies according
to localization.  Otherwise, a rob-seace-like approach may be better, using
the "<" as a sign that this is tagged input. A literal less-than can be
escaped as "\<"; missing the "<" at start-of-input, the old behaviour is used.

If text is included in the output, there should be some control on it. Where
is it located, what font and what size. Missing that, the thing is more
like a hack than a serious tool. While you make a good suggestion for
the internal representation (using textinfo), the external one must be defined.
Similarly, more than one string must be allowed (Rob Seace needed two), so
probably a more structured item should be better.

The official GNU barcode now supports PCL output, so things should be
ported to PCL as well (Andrea Scopece: that's homeworks for you :).

Using EPS as output format requires the bounding-box to be known. This
is not a difficult problem to solve, but still it's something more to
consider. Actually, EPS is included exactly to ease adding custom text
to the output.


> Let me know if there's anything else you think I should do (e.g. only
> activating the above code with an environment variable or a command line
> option) or if you think this implementation won't fit in with what you're
> doing - obviously I'd like if my changes could be merged into some future
> version.

Activating by command-line is fine, although being this an interesting
feature it could well be in by default (provided it doesn't turn out
too incompatible).  However, I still think using an external script
(perl or whatever) might be best. Or even a different frontend
altogether.  I'd see this tool as a postscript-only tool that doesn't
touch the internals of the library and uses libbarcode (or the barcode
frontend) to generate barcodes, while doing by itself when text is
needed. Being a different tool, we don't need to offer EPS and PCL as
additional outputs. Being different, it can use its own input format
(I'd use tagged, as it's extensible, *ml-like or whatever). If it's
interpreted, it can even be lazy in the amount of external
configuration and documentation, provided the code has all
customization concentrated at the head and well commented.

I'd be happy to have such a tool in the distribution. Although, actually,
it's only slightly easier than writing postscript directly.

foobar: Fancy Output Organizer with BAR codes.

/alessandro