Add Page.leftmost_nonblank and Line.indent.
This commit is contained in:
parent
05f7eb4585
commit
c739892e5b
1 changed files with 9 additions and 0 deletions
|
|
@ -114,6 +114,11 @@ class Page(PageObject):
|
|||
def lines(self):
|
||||
return self._merge_lines(self._iter_lines())
|
||||
|
||||
@cached_property
|
||||
def leftmost_nonblank(self):
|
||||
"""X coordinate of the leftmost non-blank pixel."""
|
||||
return min(line.glyphs[0].left for line in self.lines)
|
||||
|
||||
def _iter_lines(self):
|
||||
line_start = None
|
||||
prev_line_end = 0
|
||||
|
|
@ -174,6 +179,10 @@ class Line(PageObject):
|
|||
bottom = np.argmin(gradient) + skip
|
||||
return self.y + bottom
|
||||
|
||||
@cached_property
|
||||
def indent(self):
|
||||
return self.glyphs[0].left - self.page.leftmost_nonblank
|
||||
|
||||
@cached_property
|
||||
@collect_iterable
|
||||
def glyphs(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue