예제 #1
0
 def test8(self):
     '''text _text2Path'''
     story = self.story
     story.append(Paragraph('Texts drawn using a Path', h3))
     story.append(Spacer(0, 0.5 * cm))
     P = _text2Path('Hello World from font Times-Roman!',
                    x=10,
                    y=20,
                    fontName='Times-Roman',
                    fontSize=20,
                    strokeColor=colors.blue,
                    strokeWidth=0.1,
                    fillColor=colors.red)
     d = Drawing(400, 50)
     d.add(P)
     story.append(d)
     P = _text2Path('Hello World from font Helvetica!',
                    x=10,
                    y=20,
                    fontName='Helvetica',
                    fontSize=20,
                    strokeColor=colors.blue,
                    strokeWidth=0.1,
                    fillColor=colors.red)
     d = Drawing(400, 50)
     d.add(P)
     story.append(d)
     story.append(Spacer(0, 1 * cm))
예제 #2
0
 def test8(self):
     '''text _text2Path'''
     story = self.story
     story.append(Paragraph('Texts drawn using a Path', h3))
     story.append(Spacer(0,0.5*cm))
     P=_text2Path('Hello World from font Times-Roman!',x=10,y=20,fontName='Times-Roman',fontSize=20,strokeColor=colors.blue,strokeWidth=0.1,fillColor=colors.red)
     d = Drawing(400,50)
     d.add(P)
     story.append(d)
     P=_text2Path('Hello World from font Helvetica!',x=10,y=20,fontName='Helvetica',fontSize=20,strokeColor=colors.blue,strokeWidth=0.1,fillColor=colors.red)
     d = Drawing(400,50)
     d.add(P)
     story.append(d)
     story.append(Spacer(0,1*cm))
예제 #3
0
 def getTextBounds(self, text, size, font=None):
     '''
     This function returns the size of the passed text,
     when drawn as (x-extent, y-extent)
     '''
     if font is None:
         font = self.font
     p = _text2Path(text, fontName=font, fontSize=size)
     bounds = p.getBounds()
     return (bounds[2] - bounds[0], bounds[3] - bounds[1])
예제 #4
0
 def height_of(self, s):
     x1, y1, x2, y2 = _text2Path(s, fontName=self.font,
                                 fontSize=1).getBounds()
     #print x1,y1,x2,y2,'-',y2+y1
     return y2 - 0.21  # 0.21 repesents the PT size difference between a capital and small letter
예제 #5
0
def text_extents(text, face, size):
    p = _text2Path(text, 0, 0, face, size)
    return p.getBounds()