From 03b4e87ccaa474025481e523ecf9659b7a1aa9a2 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Tue, 23 Nov 2010 17:11:24 +0200 Subject: [PATCH] report customFonts: have debugging logs for fonts mapped. Since this is platform-dependant, it is good to be able to debug if that algorithm worked and located our TTF fonts. bzr revid: p_christ@hol.gr-20101123151124-wk5r5fac00kpu3f4 --- bin/report/render/rml2pdf/customfonts.py | 4 +++- bin/report/render/rml2pdf/trml2pdf.py | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/report/render/rml2pdf/customfonts.py b/bin/report/render/rml2pdf/customfonts.py index 11c35749d4c..ad97fec756b 100644 --- a/bin/report/render/rml2pdf/customfonts.py +++ b/bin/report/render/rml2pdf/customfonts.py @@ -21,6 +21,7 @@ from reportlab import rl_config import os +import logging """This module allows the mapping of some system-available TTF fonts to the reportlab engine. @@ -61,6 +62,7 @@ def FindCustomFonts(): meanwhile, the server must be restarted eventually. """ dirpath = [] + log = logging.getLogger('report.fonts') global __foundFonts for dirname in rl_config.TTFSearchPath: abp = os.path.abspath(dirname) @@ -72,7 +74,7 @@ def FindCustomFonts(): continue for d in dirpath: if os.path.exists(os.path.join(d, fname)): - # print "found font %s in %s" % (fname, d) + log.debug("Found font %s in %s as %s", fname, d, name) __foundFonts.append(fname) break diff --git a/bin/report/render/rml2pdf/trml2pdf.py b/bin/report/render/rml2pdf/trml2pdf.py index e9969fa4e52..bfb53fa2a16 100644 --- a/bin/report/render/rml2pdf/trml2pdf.py +++ b/bin/report/render/rml2pdf/trml2pdf.py @@ -31,6 +31,7 @@ import cStringIO import utils import color import os +import logging from lxml import etree import base64 from reportlab.platypus.doctemplate import ActionFlowable @@ -909,7 +910,11 @@ def parseNode(rml, localcontext = {},fout=None, images={}, path='.',title=None): try: from customfonts import SetCustomFonts SetCustomFonts(r) + except ImportError: + # means there is no custom fonts mapping in this system. + pass except Exception: + logging.getLogger('report').warning('Cannot set font mapping', exc_info=True) pass fp = cStringIO.StringIO() r.render(fp)