Exemplo n.º 1
0
    def __init__(self,
                 filename,
                 width,
                 height,
                 font_metrics,
                 use_compression=True):
        """
        width (horizontal) and height (vertical) in mm
        font_metrics is an object of type fonts.FontMetrics
        """
        GraphicsInterface.__init__(self, width, height)

        self.use_compression = use_compression
        self.font_metrics = font_metrics
        self.object_list = []
        self.pdf = None
        self.set_filename(filename)

        self.drawingtext = StringIO()
        self.set_linewidth(0.1)
        self.set_font('Times-Roman', 12 * POINT)

        self.starttext = '%PDF-1.4\n%\283\200\250\202\n'
        self.xref_list = []

        A4w, A4h = paper_A(4)
        self.set_origin(self.gi_width / 2.0, self.gi_height / 2.0)
        self.start_drawing()
        pass
Exemplo n.º 2
0
 def set_font(self, font='Times-Roman', fontsize=12 * POINT):
     """
     Fontscale is the font height in mm.
     """
     GraphicsInterface.set_font(self, font, fontsize)
     self.pstext += '/' + font + ' findfont ' + str(
         fontsize) + ' scalefont setfont\n'
     pass
Exemplo n.º 3
0
    def __init__(self, filename, width, height):
        """
        width (horizontal) and height (vertical) in mm
        """
        GraphicsInterface.__init__(self, width, height)

        self.psfile = None
        self.set_filename(filename)
        self.pstext = ''

        self.set_linewidth(0.1)
        self.set_pen_gray(0.0)
        self.set_fill_gray(0.0)
        self.set_font('Times-Roman', 12 * POINT)

        A4w, A4h = paper_A(4)
        self.offsetx = int((A4w - self.gi_width) / 2.0 * DPMM + 0.5)  # points
        self.offsety = int((A4h - self.gi_height) / 2.0 * DPMM + 0.5)  # points

        self.set_origin(self.gi_width / 2.0, self.gi_height / 2.0)
        pass
Exemplo n.º 4
0
 def set_dashed_line(self, on, off, start=0.0):
     GraphicsInterface.set_dashed_line(self, on, off, start)
     self.drawingtext.write('[' + str(on) + ' ' + str(off) + '] ' +
                            str(start) + ' d ')
     pass
Exemplo n.º 5
0
 def set_solid_line(self):
     GraphicsInterface.set_solid_line(self)
     self.drawingtext.write('[] 0 d ')
     pass
Exemplo n.º 6
0
 def set_fill_gray(self, whiteness):
     GraphicsInterface.set_fill_gray(self, whiteness)
     self.drawingtext.write(str(check_zero(whiteness)) + ' g ')
     pass
Exemplo n.º 7
0
 def set_linewidth(self, linewidth):
     GraphicsInterface.set_linewidth(self, linewidth)
     self.drawingtext.write(str(check_zero(linewidth)) + ' w ')
     pass
Exemplo n.º 8
0
 def restore(self):
     GraphicsInterface.restore(self)
     self.drawingtext.write('Q ')
     pass
Exemplo n.º 9
0
 def save(self):
     GraphicsInterface.save(self)
     self.drawingtext.write('q ')
     pass
Exemplo n.º 10
0
 def set_solid_line(self):
     GraphicsInterface.set_solid_line(self)
     self.pstext += '[] 0 setdash\n'
     pass
Exemplo n.º 11
0
 def set_dashed_line(self, on, off, start=0):
     GraphicsInterface.set_dashed_line(self, on, off, start)
     self.pstext += '[' + str(on) + ' ' + str(off) + '] ' + str(
         start) + ' setdash\n'
     pass
Exemplo n.º 12
0
 def set_fill_gray(self, whiteness):
     GraphicsInterface.set_fill_gray(self, whiteness)
     self.pstext += str(whiteness) + ' SG\n'
     pass
Exemplo n.º 13
0
 def set_linewidth(self, linewidth):
     GraphicsInterface.set_linewidth(self, linewidth)
     self.pstext += str(linewidth) + ' setlinewidth\n'
     pass
Exemplo n.º 14
0
 def restore(self):
     GraphicsInterface.restore(self)
     self.pstext += 'grestore\n'
     pass
Exemplo n.º 15
0
 def save(self):
     GraphicsInterface.save(self)
     self.pstext += 'gsave\n'
     pass