Skip to content

Commit

Permalink
Fix keepInFrame and addMapping which were suffering from a couple of …
Browse files Browse the repository at this point in the history
…problems.

KeepInFrame was suffering from the Courier-Bold bug mentioned in the
previous commit and needed it's flowable class updated for ReportLab
3.1.44.

The font mappings created by addMapping were never reset which caused
conflicts between tests.
  • Loading branch information
kylemacfarlane committed Jan 28, 2015
1 parent b54902e commit 1e577ec
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/z3c/rml/platypus.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
class KeepInFrame(reportlab.platypus.flowables.KeepInFrame):

def __init__(self, maxWidth, maxHeight, content=[], mergeSpace=1,
mode='shrink', name=''):
mode='shrink', name='', hAlign='LEFT', vAlign='BOTTOM',
fakeWidth=None):
self.name = name
self.maxWidth = maxWidth
self.maxHeight = maxHeight
Expand All @@ -36,7 +37,10 @@ def __init__(self, maxWidth, maxHeight, content=[], mergeSpace=1,
# '%s invalid maxHeight value %s' % (self.identity(),maxHeight)
if mergeSpace is None: mergeSpace = overlapAttachedSpace
self.mergespace = mergeSpace
self._content = content
self._content = content or []
self.vAlign = vAlign
self.hAlign = hAlign
self.fakeWidth = fakeWidth


class BaseFlowable(reportlab.platypus.flowables.Flowable):
Expand Down
7 changes: 7 additions & 0 deletions src/z3c/rml/rlfix.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@
"""ReportLab fixups.
"""
__docformat__ = "reStructuredText"
import copy
from reportlab.pdfbase import pdfform, pdfmetrics, ttfonts
from reportlab.pdfbase.pdfpattern import PDFPattern
from reportlab.graphics import testshapes
from reportlab.lib import fonts

_ps2tt_map_original = copy.deepcopy(fonts._ps2tt_map)
_tt2ps_map_original = copy.deepcopy(fonts._tt2ps_map)

def resetPdfForm():
pdfform.PDFDOCENC = PDFPattern(pdfform.PDFDocEncodingPattern)
Expand All @@ -38,6 +43,8 @@ def resetFonts():
'VeraBI'):
if f not in testshapes._FONTS:
testshapes._FONTS.append(f)
fonts._ps2tt_map = copy.deepcopy(_ps2tt_map_original)
fonts._tt2ps_map = copy.deepcopy(_tt2ps_map_original)

def setSideLabels():
from reportlab.graphics.charts import piecharts
Expand Down
Binary file modified src/z3c/rml/tests/expected/tag-keepInFrame.pdf
Binary file not shown.

0 comments on commit 1e577ec

Please sign in to comment.