space width guessing fixed.
git-svn-id: https://pdfminerr.googlecode.com/svn/trunk/pdfminer@66 1aa58f4a-7d42-0410-adbc-911cccaed67cpull/1/head
parent
6b09fe2bc4
commit
ca1783c956
|
@ -80,8 +80,6 @@ class FigureItem(PageItem):
|
|||
##
|
||||
class TextItem(object):
|
||||
|
||||
SPACE_WIDTH = 0.6
|
||||
|
||||
def __init__(self, matrix, font, fontsize, charspace, scaling, text):
|
||||
self.matrix = matrix
|
||||
self.font = font
|
||||
|
@ -93,7 +91,7 @@ class TextItem(object):
|
|||
size = (font.get_ascent() - font.get_descent()) * fontsize
|
||||
if not self.font.is_vertical():
|
||||
# horizontal text
|
||||
spwidth = font.char_width(32) * self.SPACE_WIDTH # space width
|
||||
spwidth = font.space_width()
|
||||
self.direction = 1
|
||||
w = 0
|
||||
dx = 0
|
||||
|
|
|
@ -66,6 +66,9 @@ class PDFFont(object):
|
|||
def string_width(self, s):
|
||||
return sum( self.char_width(cid) for cid in self.decode(s) )
|
||||
|
||||
def space_width(self):
|
||||
return max(self.char_width(32), self.char_width(44), self.char_width(46)) * 0.5
|
||||
|
||||
|
||||
# PDFSimpleFont
|
||||
class PDFSimpleFont(PDFFont):
|
||||
|
@ -352,3 +355,6 @@ class PDFCIDFont(PDFFont):
|
|||
raise PDFUnicodeNotDefined(self.cidcoding, cid)
|
||||
chars = unpack('>%dH' % (len(code)/2), code)
|
||||
return ''.join( unichr(c) for c in chars )
|
||||
|
||||
def space_width(self):
|
||||
return 0
|
||||
|
|
Loading…
Reference in New Issue