[reportlab-users] once again with external fonts in pythonpoint

Paul Okop paul_okop at mail.ru
Fri Apr 18 06:35:15 EDT 2008


Thanks to everyone, problem solved!

Here is my manual, how to use external fonts into pythonpoint

To use you font with Pythonpoint:

0) get the font-files into the RL's /fonts/ folder

1) make a copy of standard.py in /styles/ folder, name it

2) edit you new style, first, in the beginning of "getParagraphStyles()":

...
def getParagraphStyles():

"""Returns a dictionary of styles to get you started.



We will provide a way to specify a module of these. Note that

this just includes TableStyles as well as ParagraphStyles for any

tables you wish to use.

"""


from reportlab.pdfbase import pdfmetrics <-- add this line

your_font=pdfmetrics.findFontAndRegister('your_font_name') <-- this should be added, using font name instead of your_font_name

your_font.encName='coding' <-- define you font encoding, in my case(for Cyrillic) it was 'cp1251' - how to define, wht encoding is used for you font? - I don't really know, just try...



stylesheet = {}

ParagraphStyle = styles.ParagraphStyle
...

3) edit your new stylesheet, defining you new font like this:
para.fontName = 'your_font_name'

4) in you XML define the stylesheet:
<stylesheet module="your_new_stylesheet" function="getParagraphStyles"/>

enjoy!) your new font will be build-in your pdf's
_________
Paul Okop


More information about the reportlab-users mailing list