163
163
addMapping(name, 1, 0, name) #bold
164
164
addMapping(name, 1, 1, name) #italic and bold
166
def setTTFontMapping(self,face, fontname,filename, mode='all'):
167
from reportlab.lib.fonts import addMapping
168
from reportlab.pdfbase import pdfmetrics
169
from reportlab.pdfbase.ttfonts import TTFont
171
pdfmetrics.registerFont(TTFont(fontname, filename ))
173
addMapping(face, 0, 0, fontname) #normal
174
addMapping(face, 0, 1, fontname) #italic
175
addMapping(face, 1, 0, fontname) #bold
176
addMapping(face, 1, 1, fontname) #italic and bold
177
elif (mode== 'normal') or (mode == 'regular'):
178
addMapping(face, 0, 0, fontname) #normal
179
elif (mode == 'italic'):
180
addMapping(face, 0, 1, fontname) #italic
181
elif (mode == 'bold'):
182
addMapping(face, 1, 0, fontname) #bold
183
elif (mode == 'bolditalic'):
184
addMapping(face, 1, 1, fontname) #italic and bold
166
186
def _textual_image(self, node):
168
188
for n in node.getchildren():
775
795
def parseNode(rml, localcontext = {},fout=None, images={}, path='.',title=None):
776
796
node = etree.XML(rml)
777
797
r = _rml_doc(node, localcontext, images, path, title=title)
798
#try to override some font mappings
800
from customfonts import SetCustomFonts
778
804
fp = cStringIO.StringIO()
780
806
return fp.getvalue()
782
808
def parseString(rml, localcontext = {},fout=None, images={}, path='.',title=None):
783
809
node = etree.XML(rml)
784
810
r = _rml_doc(node, localcontext, images, path, title=title)
812
#try to override some font mappings
814
from customfonts import SetCustomFonts
786
820
fp = file(fout,'wb')