[reportlab-users] single font for document

Something Special dailylama at gmail.com
Mon Feb 12 15:07:46 EST 2007


# -*- coding: utf-8 -*-
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.platypus import *
from reportlab.lib import colors


# Allow encodings
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.lib.fonts import addMapping

pdfmetrics.registerFont(TTFont('Times', 'Times.ttf'))
pdfmetrics.registerFont(TTFont('TimesI', 'TimesI.TTF'))
pdfmetrics.registerFont(TTFont('TimesB', 'TimesBD.TTF'))
pdfmetrics.registerFont(TTFont('TimesBI', 'TimesBI.TTF'))

addMapping('Times', 0, 0, 'Times')
addMapping('Times', 0, 1, 'TimesI')
addMapping('Times', 1, 0, 'TimesB')
addMapping('Times', 1, 1, 'TimesBI')





elements = []
styles = getSampleStyleSheet()
doc = SimpleDocTemplate('enc.pdf')

def ft(text):
return Paragraph("<font name=Times>%s</font>"%text, styles['Normal'])

data = [
["ABC", "АБЦ", "ĀBČ"],
[ft("ABC"), ft("АБЦ"), ft("ĀBČ")]
]

table = Table(data)
elements.append(table)
doc.build(elements)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: reportlab-encodings.png
Type: image/png
Size: 28919 bytes
Desc: not available
Url : http://two.pairlist.net/pipermail/reportlab-users/attachments/20070212/f4cded78/attachment-0001.png


More information about the reportlab-users mailing list