Esempio n. 1
0
    def __init__(self,filename,fontName="Courier",**kw):
        FileTextPrinter.__init__(self,filename,pageSize=A4,**kw)

        fontfiles=FONTFILES[fontName]
        pdfmetrics.registerFont(TTFont(fontName, fontfiles[0]))
        if len(fontfiles) == 1:
            self._can_bold=False
        else:
            self._can_bold=True
            pdfmetrics.registerFont(TTFont(fontName+"-Bold", fontfiles[1]))
            pdfmetrics.registerFont(TTFont(fontName+"-Oblique", fontfiles[2]))
            pdfmetrics.registerFont(TTFont(fontName+"-BoldOblique", fontfiles[3]))
        

##         try:
## ##             font=TTFont("Courier", "cour.ttf")
## ##             print "pdfprn.py", font.face.bbox,\
## ##                   font.face.ascent, font.face.descent
## ##             minx,miny,maxx,maxy = font.face.bbox
## ##             boxheight=font.face.ascent-font.face.descent
## ##             #self.ratio_size2leading=float(maxy-miny) / font.face.defaultWidth
## ##             self.ratio_size2leading=float(boxheight) / font.face.defaultWidth
## ##             print "ratio_size2leading=",self.ratio_size2leading
##             pdfmetrics.registerFont(TTFont("Courier", "cour.ttf"))
##             pdfmetrics.registerFont(TTFont("Courier-Bold", "courbd.ttf"))
##             pdfmetrics.registerFont(TTFont("Courier-Oblique", "couri.ttf"))
##             pdfmetrics.registerFont(TTFont("Courier-BoldOblique", "courbi.ttf"))
##         except TTFError,e:
##             pass # continue with the Adobe builtin version
        
        
        self.maxLeading=0
        self.leading=0
        self.canvas = canvas.Canvas(filename,pagesize=A4)
        #self.textobject = None
        self.status = Status(fontName=fontName)
        self.leading=None
        self.lpi = None
        self.setCpi(self.cpi)
Esempio n. 2
0
    def __init__(self, filename, fontName="Courier", **kw):
        FileTextPrinter.__init__(self, filename, pageSize=A4, **kw)

        fontfiles = FONTFILES[fontName]
        pdfmetrics.registerFont(TTFont(fontName, fontfiles[0]))
        if len(fontfiles) == 1:
            self._can_bold = False
        else:
            self._can_bold = True
            pdfmetrics.registerFont(TTFont(fontName + "-Bold", fontfiles[1]))
            pdfmetrics.registerFont(TTFont(fontName + "-Oblique",
                                           fontfiles[2]))
            pdfmetrics.registerFont(
                TTFont(fontName + "-BoldOblique", fontfiles[3]))

##         try:
## ##             font=TTFont("Courier", "cour.ttf")
## ##             print "pdfprn.py", font.face.bbox,\
## ##                   font.face.ascent, font.face.descent
## ##             minx,miny,maxx,maxy = font.face.bbox
## ##             boxheight=font.face.ascent-font.face.descent
## ##             #self.ratio_size2leading=float(maxy-miny) / font.face.defaultWidth
## ##             self.ratio_size2leading=float(boxheight) / font.face.defaultWidth
## ##             print "ratio_size2leading=",self.ratio_size2leading
##             pdfmetrics.registerFont(TTFont("Courier", "cour.ttf"))
##             pdfmetrics.registerFont(TTFont("Courier-Bold", "courbd.ttf"))
##             pdfmetrics.registerFont(TTFont("Courier-Oblique", "couri.ttf"))
##             pdfmetrics.registerFont(TTFont("Courier-BoldOblique", "courbi.ttf"))
##         except TTFError,e:
##             pass # continue with the Adobe builtin version

        self.maxLeading = 0
        self.leading = 0
        self.canvas = canvas.Canvas(filename, pagesize=A4)
        #self.textobject = None
        self.status = Status(fontName=fontName)
        self.leading = None
        self.lpi = None
        self.setCpi(self.cpi)
Esempio n. 3
0
 def __init__(self,filename,**kw):
     FileTextPrinter.__init__(self,filename,**kw)
     self.writer = file(self.filename,"w")
     self.cpl=100