Recover the quadrilateral of a text character. This requires the "rawdict" option of text extraction. Args: line_dir: (tuple) 'line["dir"]' of the span's line. span: (dict) the span dict. char: (dict) the character dict. Returns: The quadrilateral envelo
(line_dir: tuple, span: dict, char: dict)
| 5132 | |
| 5133 | |
| 5134 | def recover_char_quad(line_dir: tuple, span: dict, char: dict) -> Quad: |
| 5135 | """Recover the quadrilateral of a text character. |
| 5136 | |
| 5137 | This requires the "rawdict" option of text extraction. |
| 5138 | |
| 5139 | Args: |
| 5140 | line_dir: (tuple) 'line["dir"]' of the span's line. |
| 5141 | span: (dict) the span dict. |
| 5142 | char: (dict) the character dict. |
| 5143 | Returns: |
| 5144 | The quadrilateral enveloping the character. |
| 5145 | """ |
| 5146 | if line_dir == None: |
| 5147 | line_dir = span["dir"] |
| 5148 | if type(line_dir) is not tuple or len(line_dir) != 2: |
| 5149 | raise ValueError("bad line dir argument") |
| 5150 | if type(span) is not dict: |
| 5151 | raise ValueError("bad span argument") |
| 5152 | if type(char) is dict: |
| 5153 | bbox = Rect(char["bbox"]) |
| 5154 | elif type(char) is tuple: |
| 5155 | bbox = Rect(char[3]) |
| 5156 | else: |
| 5157 | raise ValueError("bad span argument") |
| 5158 | |
| 5159 | return recover_bbox_quad(line_dir, span, bbox) |
| 5160 | |
| 5161 | |
| 5162 | # ------------------------------------------------------------------- |
no test coverage detected
searching dependent graphs…