From 896c86f349cdd809351663fb18a9e53448adf97a Mon Sep 17 00:00:00 2001 From: Paul Molodowitch Date: Mon, 23 Dec 2013 14:35:37 -0800 Subject: [PATCH] fix for spaces in names --- dominion_tabs.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/dominion_tabs.py b/dominion_tabs.py index df0835e..3091c97 100644 --- a/dominion_tabs.py +++ b/dominion_tabs.py @@ -278,15 +278,17 @@ class DominionTabs: else: h -= h/2 + words = line.split() if rightSide or not self.options.edge_align_name: w = textInset - name_parts = line.split() def drawWordPiece(text, fontSize): self.canvas.setFont('MinionPro-Regular',fontSize) if text != ' ': self.canvas.drawString(w,h,text) return pdfmetrics.stringWidth(text,'MinionPro-Regular',fontSize) - for word in name_parts: + for i, word in enumerate(words): + if i != 0: + w += drawWordPiece(' ', fontSize) w += drawWordPiece(word[0], fontSize) w += drawWordPiece(word[1:], fontSize-2) else: @@ -295,15 +297,17 @@ class DominionTabs: # space between text + set symbol w = self.tabLabelWidth - textInsetRight - 3 - name_parts = reversed(line.split()) + words.reverse() def drawWordPiece(text, fontSize): self.canvas.setFont('MinionPro-Regular',fontSize) if text != ' ': self.canvas.drawRightString(w,h,text) return -pdfmetrics.stringWidth(text,'MinionPro-Regular',fontSize) - for word in name_parts: + for i, word in enumerate(words): w += drawWordPiece(word[1:], fontSize-2) w += drawWordPiece(word[0], fontSize) + if i != len(words) - 1: + w += drawWordPiece(' ', fontSize) self.canvas.restoreState() def drawText(self, card, useExtra=False):