~ubuntu-branches/ubuntu/hardy/gnue-common/hardy

« back to all changes in this revision

Viewing changes to src/printing/barcodes/standard2of5.py

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Mitchell
  • Date: 2005-03-09 11:06:31 UTC
  • Revision ID: james.westby@ubuntu.com-20050309110631-8gvvn39q7tjz1kj6
Tags: upstream-0.5.14
ImportĀ upstreamĀ versionĀ 0.5.14

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# This file is part of GNU Enterprise.
 
3
#
 
4
# GNU Enterprise is free software; you can redistribute it
 
5
# and/or modify it under the terms of the GNU General Public
 
6
# License as published by the Free Software Foundation; either
 
7
# version 2, or (at your option) any later version.
 
8
#
 
9
# GNU Enterprise is distributed in the hope that it will be
 
10
# useful, but WITHOUT ANY WARRANTY; without even the implied
 
11
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 
12
# PURPOSE. See the GNU General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU General Public
 
15
# License along with program; see the file COPYING. If not,
 
16
# write to the Free Software Foundation, Inc., 59 Temple Place
 
17
# - Suite 330, Boston, MA 02111-1307, USA.
 
18
#
 
19
# Copyright 2004-2005 Free Software Foundation
 
20
#
 
21
# FILE:
 
22
# barcodes/code39.py
 
23
#
 
24
# DESCRIPTION:
 
25
"""
 
26
Implements the Standard 2 of 5 barcode spec
 
27
"""
 
28
#
 
29
 
 
30
from Base import Barcode
 
31
 
 
32
class Standard2of5(Barcode):
 
33
  chars = '0123456789'
 
34
  mapping = {
 
35
    '0': 'N0N0W0W0N0',
 
36
    '1': 'W0N0N0N0W0',
 
37
    '2': 'N0W0N0N0W0',
 
38
    '3': 'W0W0N0N0N0',
 
39
    '4': 'N0N0W0N0W0',
 
40
    '5': 'W0N0W0N0N0',
 
41
    '6': 'N0W0W0N0N0',
 
42
    '7': 'N0N0N0W0W0',
 
43
    '8': 'W0N0N0W0N0',
 
44
    '9': 'N0W0N0W0N0'
 
45
  }
 
46
 
 
47
  start = '0M0N0'
 
48
  stop  = 'M0N0M'
 
49
 
 
50
  encodingMap = {
 
51
         # Stroke?, X Multiplier, Y Multiplier
 
52
    '0': (False, 1, 1),   # Narrow Spaces
 
53
    'N': (True, 1, 1),    # Narrow bars
 
54
    'M': (True, 2, 1),    # Medium bars
 
55
    'W': (True, 3, 1)   # Wide bars
 
56
  }
 
57
 
 
58
  # calculateLineHeight = Barcode._calculate15 # Unsure of this
 
59
  lineWidth = 1 # points -- Unsure of this
 
60
  lineHeight = 18 # Actually dependent on the width
 
61
 
 
62
 
 
63
if __name__ == '__main__':
 
64
 
 
65
  testbar = Standard2of5()
 
66
 
 
67
  def test(value, format, file):
 
68
    f = open(file,'wb')
 
69
    testbar.generate(value,f, format)
 
70
    f.close()
 
71
 
 
72
#   test('0123456789','png','test1.png')
 
73
#   test('9876543210','tiff','test1.tif')
 
74
  test('0123456789','eps','s2of5-1.eps')