MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / recover_char_quad

Function recover_char_quad

src_classic/utils.py:5134–5159  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

5132
5133
5134def 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# -------------------------------------------------------------------

Callers 1

recover_span_quadFunction · 0.70

Calls 2

RectClass · 0.85
recover_bbox_quadFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…