Re: Embedded font problems

Tim Roberts <[email protected]>
Newsgroups gmane.comp.python.reportlab.user
Organization Providenza & Boekelheide, Inc.
Message-ID <[email protected]>
jsmith4332--- via reportlab-users wrote:
>
> 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)

Odd.  I just tried this, and it worked perfectly:

    from reportlab.pdfgen import canvas
    from reportlab.lib.pagesizes import LETTER
    from reportlab.pdfbase import pdfmetrics
    from reportlab.pdfbase.ttfonts import TTFont

    pdfmetrics.registerFont( TTFont( 'code128', '/tmp/code128.ttf'))

    canv = canvas.Canvas( 'code.pdf', pagesize=LETTER )
    canv.setPageCompression( 0 )
    canv.setFont( 'code128', 14 )
    canv.drawString( 100, 100, "0123456789" )
    canv.showPage()
    canv.save()

Does it work for you?

-- 
Tim Roberts, [email protected]
Providenza & Boekelheide, Inc.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.