Issues

ZF-9170: Add Code128 object to Zend_Barcode

Description

Add Code128 object to Zend_Barcode (A, B and C)

Comments

I've found a small bug in the _isDigit. In some cases when switching to C the function returned wrong values.

This should fix the bug:

protected static function _isDigit($string, $pos, $length = 2) { if ($pos + $length > strlen($string)) { return false; }

for ($i = $pos; $i < $pos + $length; $i++) {
  if (!is_numeric($string[$i])) {
    return false;
  }
}
return true;

}

Hi Stephan, Can you give example of errors to be able to add a unit test to cover it? Thanks in advance

The error was this:

When a number like -123, where $string[$pos] == '-', was given to _isDigit it returned true because the '-' sign was interpreted as part of the number. If _isDigit returns true for this example the code-table is changed to C, but C does not contain '-'. The lookup fails and depending on the php-configuration a wrong or no barcode is generated.

I hope this explains the bug.

Perfectly, thanks!

Implemented with r22998

I need to draw a barcode with code128. I'm using Code128.php ZF 1.11.0rc1 because I found out that in earlier stable ZF versions Code128 is not included.

When I don't set any options and draw a code128 barcode image it looks okay. When I set the barThickWidth => 6 and barThinWidth => 2, the image gets twice as wide while the bar widths are exactly the same as with the default 3 and 1 widths. Only the total image gets twice as wide, but not the actual bars. The left side of the image gets filled with the bars and the right side is just plain white.

Can someone help me to fix this?

@Laurens: i will look to this problem rapidly but can you open a new issue for this, please? Thanks in advance.