From f20053aaedf6a46b516a4b516000000aab4a2cfc Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Thu, 24 Mar 2011 20:16:18 +0100 Subject: Extensions. Datamatrix barcode improvement (see Bug #738108, Inkscape UI can pass invalid values to Datamatrix extension). Fixed bugs: - https://launchpad.net/bugs/738108 (bzr r10127) --- share/extensions/render_barcode_datamatrix.inx | 34 +++++++++++++++++-- share/extensions/render_barcode_datamatrix.py | 47 ++++++++++++++++++++++++-- 2 files changed, 77 insertions(+), 4 deletions(-) diff --git a/share/extensions/render_barcode_datamatrix.inx b/share/extensions/render_barcode_datamatrix.inx index 58699e4a9..ede179e24 100644 --- a/share/extensions/render_barcode_datamatrix.inx +++ b/share/extensions/render_barcode_datamatrix.inx @@ -5,8 +5,38 @@ render_barcode_datamatrix.py inkex.py Inkscape - 10 - 10 + + 10x10 + 12x12 + 14x14 + 16x16 + 18x18 + 20x20 + 22x22 + 24x24 + 26x26 + 32x32 + 36x36 + 40x40 + 44x44 + 48x48 + 52x52 + 64x64 + 72x72 + 80x80 + 88x88 + 96x96 + 104x104 + 120x120 + 132x132 + 144x144 + 8x18 + 8x32 + 12x26 + 12x36 + 16x36 + 16x48 + 4 all diff --git a/share/extensions/render_barcode_datamatrix.py b/share/extensions/render_barcode_datamatrix.py index 785d7de56..20bcf94dc 100644 --- a/share/extensions/render_barcode_datamatrix.py +++ b/share/extensions/render_barcode_datamatrix.py @@ -57,6 +57,39 @@ import inkex, simplestyle import gettext _ = gettext.gettext +symbols = { + 'sq10': (10, 10), + 'sq12': (12, 12), + 'sq14': (14, 14), + 'sq16': (16, 16), + 'sq18': (18, 18), + 'sq20': (20, 20), + 'sq22': (22, 22), + 'sq24': (24, 24), + 'sq26': (26, 26), + 'sq32': (32, 32), + 'sq36': (36, 36), + 'sq40': (40, 40), + 'sq44': (44, 44), + 'sq48': (48, 48), + 'sq52': (52, 52), + 'sq64': (64, 64), + 'sq72': (72, 72), + 'sq80': (80, 80), + 'sq88': (88, 88), + 'sq96': (96, 96), + 'sq104': (104, 104), + 'sq120': (120, 120), + 'sq132': (132, 132), + 'sq144': (144, 144), + 'rect8x18': (8, 18), + 'rect8x32': (8, 32), + 'rect12x26': (12, 26), + 'rect12x36': (12, 36), + 'rect16x36': (16, 36), + 'rect16x48': (16, 48), +} + #ENCODING ROUTINES =================================================== # Take an input string and convert it to a sequence (or sequences) # of codewords as specified in ISO/IEC 16022:2006 (section 5.2.3) @@ -167,6 +200,7 @@ def get_parameters(nrow, ncol): #RETURN ERROR else: inkex.errormsg(_('Unrecognised DataMatrix size')) + exit(0) return None @@ -616,6 +650,9 @@ class DataMatrix(inkex.Effect): self.OptionParser.add_option("--text", action="store", type="string", dest="TEXT", default='Inkscape') + self.OptionParser.add_option("--symbol", + action="store", type="string", + dest="SYMBOL", default='') self.OptionParser.add_option("--rows", action="store", type="int", dest="ROWS", default=10) @@ -630,6 +667,12 @@ class DataMatrix(inkex.Effect): so = self.options + rows = so.ROWS + cols = so.COLS + if (so.SYMBOL != '' and (so.SYMBOL in symbols)): + rows = symbols[so.SYMBOL][0] + cols = symbols[so.SYMBOL][1] + if so.TEXT == '': #abort if converting blank text inkex.errormsg(_('Please enter an input string')) else: @@ -644,8 +687,8 @@ class DataMatrix(inkex.Effect): grp = inkex.etree.SubElement(self.current_layer, 'g', grp_attribs)#the group to put everything in #GENERATE THE DATAMATRIX - encoded = encode( so.TEXT, (so.ROWS, so.COLS) ) #get the pattern of squares - render_data_matrix( encoded, so.SIZE, so.COLS*so.SIZE*1.5, grp ) # generate the SVG elements + encoded = encode( so.TEXT, (rows, cols) ) #get the pattern of squares + render_data_matrix( encoded, so.SIZE, cols*so.SIZE*1.5, grp ) # generate the SVG elements if __name__ == '__main__': e = DataMatrix() -- cgit v1.2.3