Exemplo n.º 1
0
 def _drawGrid(self):
     label_every = 1
     if self.units > 24:
         label_every = 2
     drawing.save()
     drawing.strokeWidth(0)
     drawing.stroke(None)
     drawing.fill(0.88, 0.92, 0.98)
     if self.system is not None:
         if self.system.min_units is not None:
             drawing.rect(0, 0, 10 + self.system.min_units * self.histogram_width / (self.units * self.ems_horizontal), self.histogram_height)
         if self.system.max_units is not None:
             drawing.rect(10 + self.system.max_units * self.histogram_width / (self.units * self.ems_horizontal), 0, self.histogram_width, self.histogram_height)
     
     drawing.strokeWidth(1.0)
     drawing.stroke(0.8, 0.8, 0.8)
     drawing.fill(0.6, 0.6, 0.6)
     for u in range(0, int(ceil(self.units * self.ems_horizontal))):
         x = 10 + u * self.histogram_width / (self.units * self.ems_horizontal)
         if u == self.units:
             # mark the full em
             drawing.stroke(0, 0, 0)
             drawing.line(x, 20, x, self.histogram_height-10)
             drawing.strokeWidth(0)
             drawing.text("1 em", x + 4, self.histogram_height - 21)
             drawing.strokeWidth(1.0)
         elif u % 10 == 0:
             # make every 10th line darker
             drawing.stroke(0.5, 0.5, 0.5)
             drawing.line(x, 20, x, self.histogram_height - 20)
         else:
             drawing.stroke(0.8, 0.8, 0.8)
             drawing.line(x, 20, x, self.histogram_height - 30)
         if u % label_every == 0:
             drawing.strokeWidth(0)
             drawing.text("%s" % (u), x - 3 * len(str(u)), 5)
     drawing.restore()
Exemplo n.º 2
0
                 for i in range(len(histogram[width])):
                     glyph_name = histogram[width][i]
                     if glyph_name in font:
                         u = font[glyph_name].unicode
                         if u:
                             drawing.text("%s" % unichr(u), x + 4, 18 + i * self.scale_vertical)
                         else:
                             drawing.text("%s" % glyph_name, x + 4, 18 + i * self.scale_vertical)
                     else:
                         drawing.text("%s" % glyph_name, x + 4, 18 + i * self.scale_vertical)
                 drawing.restore()
                 drawing.strokewidth(2)
             else:
                 drawing.strokewidth(6)
             # draw bars
             drawing.line(x, 20, x, 20 + num * self.scale_vertical)
             drawing.strokewidth(0)
             drawing.text("%s" % (num), x - 3 * len(str(num)), 22 + num * self.scale_vertical)
             drawing.restore()
     except Exception, err:
         print sys.exc_info()[0]
         print traceback.format_exc()
     drawing.restore()
 
 def _drawGrid(self):
     label_every = 1
     if self.units > 24:
         label_every = 2
     drawing.save()
     drawing.strokeWidth(0)
     drawing.stroke(None)