On 10/6/10 11:02 AM, Jacek Kałucki wrote: > Użytkownik Paul McNett napisał: >> dabo Commit >> Revision 6076 >> Date: 2010-10-05 16:56:06 -0700 (Tue, 05 Oct 2010) >> Author: Paul >> Trac:http://trac.dabodev.com/changeset/6076 >> >> Changed: >> U trunk/dabo/lib/reportWriter.py >> U trunk/dabo/settings.py >> >> Log: >> ReportWriter patch by Jacek, that addresses unicode issues and adds a way to >> register >> TrueType Font files and directories. Thanks! Trac #1382 >> >> >> >> Diff: >> Modified: trunk/dabo/lib/reportWriter.py >> =================================================================== >> --- trunk/dabo/lib/reportWriter.py 2010-10-05 21:47:01 UTC (rev 6075) >> +++ trunk/dabo/lib/reportWriter.py 2010-10-05 23:56:06 UTC (rev 6076) >> @@ -56,6 +56,10 @@ >> from dabo.lib.caselessDict import CaselessDict >> from reportlab.lib.utils import ImageReader >> from dabo.lib.utils import ustr, resolvePathAndUpdate >> +from reportlab.pdfbase.pdfmetrics import registerFont >> +from reportlab.pdfbase.ttfonts import TTFont, TTFError >> +from reportlab.pdfbase.pdfmetrics import getRegisteredFontNames >> +from reportlab.rl_config import TTFSearchPath >> import Image as PILImage >> import reportUtils >> >> @@ -73,6 +77,28 @@ >> ParaClass = platypus.Paragraph >> >> >> +def addReportTTFontFilePath(paths): >> + if isinstance(paths, basestring): >> + paths = (paths,) >> + for path in paths: >> + TTFSearchPath.append(path) >> + >> + >> +if dabo.reportTTFontFilePath: >> + addReportTTFontFilePath(dabo.reportTTFontFilePath) >> + >> + >> +def addReportTTFontFilePath(paths): >> + if isinstance(paths, basestring): >> + paths = (paths,) >> + for path in paths: >> + TTFSearchPath.append(path) >> + >> + >> +if dabo.reportTTFontFilePath: >> + addReportTTFontFilePath(dabo.reportTTFontFilePath) >> + >> + >> ## Can't use None for uninitialized group values, because None >> ## could be a meaningful value in the dataset. >> UNINITIALIZED_VALUE = 'UNINITIALIZED_f49dc68b-1e4c-43ad-81c1-227c1e4f59e6' >> @@ -108,7 +134,29 @@ >> # callback to the rw to draw the cached pagecount strings >> self.__rw.drawPageCounts(page, len(self.__saved_page_states)) >> >> + def setFont(self, psfontname, size, leading=None): >> + if psfontname not in getRegisteredFontNames(): >> + if psfontname in dabo.reportTTFontFileMap: >> + psfontfile = >> dabo.reportTTFontFileMap[psfontname] >> + else: >> + psfontfile = "%s.ttf" % psfontname >> + try: >> + registerFont(TTFont(psfontname, psfontfile)) >> + except TTFError: >> + dabo.log.info(_("Font file can not be found: >> %s") % psfontfile) >> + canvas.Canvas.setFont(self, psfontname, size, leading) >> >> + def setFont(self, psfontname, size, leading=None): >> + if psfontname not in getRegisteredFontNames(): >> + if psfontname in dabo.reportTTFontFileMap: >> + psfontfile = >> dabo.reportTTFontFileMap[psfontname] >> + else: >> + psfontfile = "%s.ttf" % psfontname >> + try: >> + registerFont(TTFont(psfontname, psfontfile)) >> + except TTFError: >> + dabo.log.info(_("Font file can not be found: >> %s") % psfontfile) >> + canvas.Canvas.setFont(self, psfontname, size, leading) >> >> class ReportObjectCollection(list): >> """Abstract ordered list of things like variables, groups, and band >> objects.""" >> @@ -1330,13 +1378,18 @@ >> > > Look into your commit source changes, please. > Code is duplicated until @@ -1330,13 +1378,18 @@ tag. > My version of patch was correct.
Okay, not sure what happened. Fixed. Thanks! Paul _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev Searchable Archives: http://leafe.com/archives/search/dabo-dev This message: http://leafe.com/archives/byMID/[email protected]
