Re: Embedded font problems

jsmith4332--- via reportlab-users <[email protected]>
Newsgroups gmane.comp.python.reportlab.user
Message-ID <[email protected]>
It does not. (Running this in a docker container if that matters) 

    On Monday, March 13, 2017 12:14 PM, Tim Roberts <[email protected]> wrote:
 

  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.
 
_______________________________________________
reportlab-users mailing list
[email protected]
https://pairlist2.pair.net/mailman/listinfo/reportlab-users
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.