[reportlab-users] Problem with Type1 fonts and gs.

Mike Bernson mike at mlb.org
Tue Aug 18 12:38:20 EDT 2009

I am having a problem creating a pdf that will print.

I am running linux (ubuntu 9.04) with reportlab version 2.3 installed
by apt-get. The code look as close to the example in the doc as I can

The file is type 1 file from gs.

/usr/share/fonts/type1/gsfonts/n019003l.pfb: PostScript Type 1 font program data
/usr/share/fonts/type1/gsfonts/n019003l.afm: ASCII font metrics

The output from pdfinfo:
name type emb sub uni object ID
------------------------------------ ----------------- --- --- --- ---------
Helvetica Type 1 no no no 2 0
NimbusSanL-Regu Type 1 yes no no 5 0

both acroread and xpdf can both handle the font.

If on run gs on the pdf I get the following error:

mike at mike-laptop:~/src/myranch/report/report/reportgen 308> gs test.pdf
GPL Ghostscript 8.64 (2009-02-03)
Copyright (C) 2009 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 1.
Page 1
Loading NimbusSanL-Regu font from /var/lib/defoma/gs.d/dirs/fonts/n019003l.pfb... 3842416 1896651 10232952 8927311 3 done.
Error: /typecheck in --run--
Operand stack:
--nostringval-- --dict:8/17(L)-- F2 32 --dict:9/9(L)-- --dict:9/9(L)-- --nostringval-- --nostringval-- Encoding
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1862 1 3 %oparray_pop 1861 1 3 %oparray_pop 1845 1
3 %oparray_pop --nostringval-- --nostringval-- 2 1 1 --nostringval-- %for_pos_int_continue --nostringval-- --nostringval-- --nostringval-- --nostringval-- %array_continue --nostringval-- false 1 %stopped_push
--nostringval-- %loop_continue --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval--
Dictionary stack:
--dict:1147/1684(ro)(G)-- --dict:1/20(G)-- --dict:74/200(L)-- --dict:74/200(L)-- --dict:106/127(ro)(G)-- --dict:278/300(ro)(G)-- --dict:22/25(L)-- --dict:4/6(L)-- --dict:25/40(L)--
Current allocation mode is local
GPL Ghostscript 8.64: Unrecoverable error, exit code 1

Here is the code that created the pdf:
import os
import reportlab
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfgen import canvas

folder = '/usr/share/fonts/type1/gsfonts'
afmFile = os.path.join(folder, 'n019003l.afm')
pfbFile = os.path.join(folder, 'n019003l.pfb')
justFace = pdfmetrics.EmbeddedType1Face(afmFile, pfbFile)
faceName = 'NimbusSanL-Regu'
justFont = pdfmetrics.Font(faceName,

c = canvas.Canvas('test.pdf')
c.setFont(faceName, 32)
c.drawString(10, 150, 'This should be in')
c.drawString(10, 100, faceName)

More information about the reportlab-users mailing list