[reportlab-users] Embedded font problems

jsmith4332 at yahoo.com jsmith4332 at yahoo.com
Mon Mar 13 08:09:47 EDT 2017


Hello,
Does anyone have troubleshooting tips for figuring out why an embedded TTF font does not work in reportlab (just shows rectangles)? I'm trying to use https://grandzebu.net/informatique/codbar/code128.ttf (yes, I would like to use a barcode font instead of the built in barcode generator due to quality issues when printing on a low DPI printer)
The relevant code is:
stylesheet = StyleSheet1()

stylesheet.add(
    ParagraphStyle(
        name='Normal',
        fontName='Helvetica',
        fontSize=12,
        leading=16,
        spaceBefore=8,
        spaceAfter=8,
    )
)

stylesheet.add(
    ParagraphStyle(
        name='Barcode',
        fontName='128',
        fontSize=12,
    )
)
pdfmetrics.registerFont(TTFont('128', os.path.join(os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__))), 'code128.ttf')))# story definition omitted...story.append(Paragraph('helloworld'), stylesheet['Barcode']))
Unfortunately, the resulting PDF has a bunch of squares instead of using the barcode font. When I switch to a different ttf, things seem to work. Furthermore, the code128 font referenced above seems to work fine in applications like Microsoft Word/Excel.

Any ideas?
Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/reportlab-users/attachments/20170313/d03c7eb2/attachment.html>


More information about the reportlab-users mailing list