LTLine is now strictly horizontal or vertical.

pull/1/head
Yusuke Shinyama 2011-04-20 22:01:54 +09:00
parent 4bba94feec
commit dab70855bf
1 changed files with 11 additions and 9 deletions

View File

@ -69,8 +69,10 @@ class PDFLayoutAnalyzer(PDFTextDevice):
(_,x1,y1) = path[1] (_,x1,y1) = path[1]
(x0,y0) = apply_matrix_pt(self.ctm, (x0,y0)) (x0,y0) = apply_matrix_pt(self.ctm, (x0,y0))
(x1,y1) = apply_matrix_pt(self.ctm, (x1,y1)) (x1,y1) = apply_matrix_pt(self.ctm, (x1,y1))
self.cur_item.add(LTLine(gstate.linewidth, (x0,y0), (x1,y1))) if x0 == x1 or y0 == y1:
elif shape == 'mlllh': self.cur_item.add(LTLine(gstate.linewidth, (x0,y0), (x1,y1)))
return
if shape == 'mlllh':
# rectangle # rectangle
(_,x0,y0) = path[0] (_,x0,y0) = path[0]
(_,x1,y1) = path[1] (_,x1,y1) = path[1]
@ -83,13 +85,13 @@ class PDFLayoutAnalyzer(PDFTextDevice):
if ((x0 == x1 and y1 == y2 and x2 == x3 and y3 == y0) or if ((x0 == x1 and y1 == y2 and x2 == x3 and y3 == y0) or
(y0 == y1 and x1 == x2 and y2 == y3 and x3 == x0)): (y0 == y1 and x1 == x2 and y2 == y3 and x3 == x0)):
self.cur_item.add(LTRect(gstate.linewidth, (x0,y0,x2,y2))) self.cur_item.add(LTRect(gstate.linewidth, (x0,y0,x2,y2)))
else: return
# other polygon # other shapes
pts = [] pts = []
for p in path: for p in path:
for i in xrange(1, len(p), 2): for i in xrange(1, len(p), 2):
pts.append(apply_matrix_pt(self.ctm, (p[i], p[i+1]))) pts.append(apply_matrix_pt(self.ctm, (p[i], p[i+1])))
self.cur_item.add(LTPolygon(gstate.linewidth, pts)) self.cur_item.add(LTPolygon(gstate.linewidth, pts))
return return
def render_char(self, matrix, font, fontsize, scaling, rise, cid): def render_char(self, matrix, font, fontsize, scaling, rise, cid):