UPCA.py revision 1ef3c8b1b935901dd133c337031a7300334db424
200N/A#
200N/A# Copyright (C) 2007 Martin Owens
200N/A#
0N/A# This program is free software; you can redistribute it and/or modify
200N/A# it under the terms of the GNU General Public License as published by
200N/A# the Free Software Foundation; either version 2 of the License, or
200N/A# (at your option) any later version.
0N/A#
200N/A# This program is distributed in the hope that it will be useful,
200N/A# but WITHOUT ANY WARRANTY; without even the implied warranty of
200N/A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
200N/A# GNU General Public License for more details.
0N/A#
200N/A# You should have received a copy of the GNU General Public License
200N/A# along with this program; if not, write to the Free Software
200N/A# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
200N/A#
200N/A"""
200N/APython barcode renderer for UPCA barcodes. Designed for use with Inkscape.
0N/A"""
200N/A
200N/Afrom BaseEan import EanBarcode
200N/A
200N/Aclass Object(EanBarcode):
200N/A """Provides a renderer for EAN12 aka UPC-A Barcodes"""
200N/A name = 'upca'
200N/A lengths = [ 11 ]
0N/A checks = [ 12 ]
200N/A
200N/A def _encode(self, n):
200N/A """Encode for a UPC-A Barcode"""
0N/A self.label = self.space(n[0:1], 3, n[1:6], 4, n[6:11], 3, n[11:])
200N/A return self.enclose(self.encode_left(n[0:6]), self.encode_right(n[6:12]))
200N/A
200N/A def fontSize(self):
200N/A """We need a bigger barcode"""
200N/A return 10
200N/A