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

Function JM_make_spanlist

src/__init__.py:20498–20646  ·  view source on GitHub ↗
(line_dict, line, raw, buff, tp_rect)

Source from the content-addressed store, hash-verified

20496
20497
20498def JM_make_spanlist(line_dict, line, raw, buff, tp_rect):
20499 if 1 or g_use_extra:
20500 return extra.JM_make_spanlist(line_dict, line, raw, buff, tp_rect)
20501 char_list = None
20502 span_list = []
20503 mupdf.fz_clear_buffer(buff)
20504 span_rect = mupdf.FzRect(mupdf.FzRect.Fixed_EMPTY)
20505 line_rect = mupdf.FzRect(mupdf.FzRect.Fixed_EMPTY)
20506
20507 class char_style:
20508 def __init__(self, rhs=None):
20509 if rhs:
20510 self.size = rhs.size
20511 self.flags = rhs.flags
20512 self.char_flags = rhs.char_flags
20513 self.font = rhs.font
20514 self.argb = rhs.argb
20515 self.asc = rhs.asc
20516 self.desc = rhs.desc
20517 self.bidi = rhs.bidi
20518 else:
20519 self.size = -1
20520 self.flags = -1
20521 self.char_flags = -1
20522 self.font = ''
20523 self.argb = -1
20524 self.asc = 0
20525 self.desc = 0
20526 self.bidi = 0
20527 def __str__(self):
20528 ret = f'{self.size} {self.flags}'
20529 ret += f' {self.char_flags}'
20530 ret += f' {self.font} {self.color} {self.asc} {self.desc}'
20531 return ret
20532
20533 old_style = char_style()
20534 style = char_style()
20535 span = None
20536 span_origin = None
20537
20538 for ch in line:
20539 # start-trace
20540 r = JM_char_bbox(line, ch)
20541 if (not JM_rects_overlap(tp_rect, r)
20542 and not mupdf.fz_is_infinite_rect(tp_rect)
20543 ):
20544 continue
20545
20546 # Info from:
20547 # detect_super_script()
20548 # fz_font_is_italic()
20549 # fz_font_is_serif()
20550 # fz_font_is_monospaced()
20551 # fz_font_is_bold()
20552
20553 flags = JM_char_font_flags(mupdf.FzFont(mupdf.ll_fz_keep_font(ch.m_internal.font)), line, ch)
20554 origin = mupdf.FzPoint(ch.m_internal.origin)
20555 style.size = ch.m_internal.size

Callers 1

JM_make_text_blockFunction · 0.85

Calls 13

char_styleClass · 0.85
JM_char_bboxFunction · 0.85
JM_rects_overlapFunction · 0.85
JM_char_font_flagsFunction · 0.85
JM_font_nameFunction · 0.85
JM_font_ascenderFunction · 0.85
JM_font_descenderFunction · 0.85
JM_EscapeStrFromBufferFunction · 0.85
JM_py_from_pointFunction · 0.85
JM_py_from_rectFunction · 0.85
JM_EscapeStrFromStrFunction · 0.85
JM_append_runeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…