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

Function JM_make_annot_DA

src/__init__.py:20478–20495  ·  view source on GitHub ↗
(annot, ncol, col, fontname, fontsize)

Source from the content-addressed store, hash-verified

20476
20477
20478def JM_make_annot_DA(annot, ncol, col, fontname, fontsize):
20479 # PyMuPDF uses a fz_buffer to build up the string, but it's non-trivial to
20480 # convert the fz_buffer's `unsigned char*` into a `const char*` suitable
20481 # for passing to pdf_dict_put_text_string(). So instead we build up the
20482 # string directly in Python.
20483 buf = ''
20484 if ncol < 1:
20485 buf += f'0 g '
20486 elif ncol == 1:
20487 buf += f'{col[0]:g} g '
20488 elif ncol == 2:
20489 assert 0
20490 elif ncol == 3:
20491 buf += f'{col[0]:g} {col[1]:g} {col[2]:g} rg '
20492 else:
20493 buf += f'{col[0]:g} {col[1]:g} {col[2]:g} {col[3]:g} k '
20494 buf += f'/{JM_expand_fname(fontname)} {fontsize} Tf'
20495 mupdf.pdf_dict_put_text_string(mupdf.pdf_annot_obj(annot), mupdf.PDF_ENUM_NAME_DA, buf)
20496
20497
20498def JM_make_spanlist(line_dict, line, raw, buff, tp_rect):

Callers 2

updateMethod · 0.85
_add_freetext_annotMethod · 0.85

Calls 1

JM_expand_fnameFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…