[reportlab-users] TTF Problem
Robin Becker
robin at reportlab.com
Mon Feb 27 05:54:51 EST 2006
Ian, your character set uses a fairly odd set of code points so you need to use
that in calls to drawString etc. I used the following code to grab hold of the
relevant small set of code points
##########################################
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.pdfgen.canvas import Canvas
fontName = "APP6A01"
ttf = TTFont(fontName, fontName+".TTF")
K = ttf.face.charToGlyph.keys()
registerFont(ttf)
c = Canvas('test%s.pdf' % fontName)
c.setFont('Helvetica', 30)
c.drawString(100,700, 'TrueType Font '+fontName)
y0 = 680
x0 = 72
y = y0
x = x0
dx0 = stringWidth('12345:', 'Courier', 10)
dx = dx0+20
dy = 20
for i, k in enumerate(K):
c.setFont('Courier', 10)
c.drawString(x,y,'%5d: ' % k )
c.setFont(fontName, 10)
c.drawString(x+dx0,y,unichr(k).encode('utf8'))
x += dx
if x-x0>6*72:
x = x0
y -= dy
c.showPage()
c.save()
##########################################
What this means in practice is that you cannot use the simple A-9 chars to get
at your glyphs. In this font all the standard ASCII code points are unassigned.
--
Robin Becker
More information about the reportlab-users
mailing list