fix fill 1 to right
[Printer-Zebra.git] / ZPL2pbm.pl
index 860f28b..692fb66 100755 (executable)
@@ -31,12 +31,11 @@ while( $line ) {
 
                warn "# ~DG$1 => [$name] t=$t w=$w\n";
 
-               my $data;
-               read $in, $data, $t;
+               my $data = <$in>;
 
                my $out;
                # ZPL decompress
-               my $repeat = 1;
+               my $repeat = 0;
                foreach my $p ( 0 .. length($data) - 1 ) {
                        my $c = substr($data,$p,1);
                        if ( $c eq ',' ) {
@@ -44,9 +43,14 @@ while( $line ) {
                                $l = $w * 2 if $l == 0;
                                warn "# $p ZERO-to-EOL $c [$l]\n";
                                $out .= "0" x $l;
+                       } elsif ( $c eq '!' ) {
+                               my $l = ( $w * 2 ) - length($out) % ( $w * 2 );
+                               $l = $w * 2 if $l == 0;
+                               warn "# $p ONE-to-EOL $c [$l]\n";
+                               $out .= "F" x $l;
                        } elsif ( $c eq ':' ) {
                                $out .= length($out) > $w ? substr($out,-$w*2) : "00" x $w;
-                               warn "# $p :\n";
+                               warn "# $p repeat last line\n";
                        } elsif ( $c eq 'z' ) {
                                $repeat += 400;
                        } elsif ( $c ge 'g' && $c le 'y' ) {