Previous: , Up: The Barcode Object  


2.2 The Intermediate Representation

The encoding functions print their output into the partial and texinfo fields of the barcode data structure. Those fields, together with position information, are then used to generate actual output. This is an informal description of the intermediate format.

The first char in partial tells how much extra space to add to the left of the bars. For EAN-13, it is used to leave space to print the first digit, other codes may have ’0’ for no-extra-space-needed.

The next characters are alternating bars and spaces, as multiples of the base dimension which is 1 unless the code is rescaled. Rescaling is calculated as the ratio from the requested width and the calculated width. Digits represent bar/space dimensions. Lower-case letters represent those bars that should extend lower than the others: ’a’ is equivalent to ’1’, ’b’ is ’2’ and so on up to ’i’ which is equivalent to ’9’. Other letters will be used for encoding-specific meanings, as soon as I implement them.

The textinfo string is made up of fields %lf:%lf:%c separated by blank space. The first integer is the x position of the character, the second is the font size (before rescaling) and the char item is the character to be printed.

Both the partial and textinfo strings may include “-” or “+” as special characters (in textinfo the char should be a stand-alone word). They state where the text should be printed: below the bars (“-”, default) or above the bars. This is used, for example, to print the add-5 and add-2 codes to the right of UPC or EAN codes (the add-5 extension is mostly used in ISBN codes).


Previous: , Up: The Barcode Object