MCPcopy Index your code
hub / github.com/pymupdf/PyMuPDF / append

Method append

src/__init__.py:16748–16790  ·  view source on GitHub ↗

Store 'text' at point 'pos' using 'font' and 'fontsize'.

(self, pos, text, font=None, fontsize=11, language=None, right_to_left=0, small_caps=0)

Source from the content-addressed store, hash-verified

16746 return val
16747
16748 def append(self, pos, text, font=None, fontsize=11, language=None, right_to_left=0, small_caps=0):
16749 """Store 'text' at point 'pos' using 'font' and 'fontsize'."""
16750 pos = Point(pos) * self.ictm
16751 #log( '{font=}')
16752 if font is None:
16753 font = Font("helv")
16754 if not font.is_writable:
16755 if 0:
16756 log( '{font.this.m_internal.name=}')
16757 log( '{font.this.m_internal.t3matrix=}')
16758 log( '{font.this.m_internal.bbox=}')
16759 log( '{font.this.m_internal.glyph_count=}')
16760 log( '{font.this.m_internal.use_glyph_bbox=}')
16761 log( '{font.this.m_internal.width_count=}')
16762 log( '{font.this.m_internal.width_default=}')
16763 log( '{font.this.m_internal.has_digest=}')
16764 log( 'Unsupported font {font.name=}')
16765 if mupdf_cppyy:
16766 import cppyy
16767 log( f'Unsupported font {cppyy.gbl.mupdf_font_name(font.this.m_internal)=}')
16768 raise ValueError(f"Unsupported font '{font.name}'.")
16769 if right_to_left:
16770 text = self.clean_rtl(text)
16771 text = "".join(reversed(text))
16772 right_to_left = 0
16773
16774 lang = mupdf.fz_text_language_from_string(language)
16775 p = JM_point_from_py(pos)
16776 trm = mupdf.fz_make_matrix(fontsize, 0, 0, fontsize, p.x, p.y)
16777 markup_dir = 0
16778 wmode = 0
16779 if small_caps == 0:
16780 trm = mupdf.fz_show_string( self.this, font.this, trm, text, wmode, right_to_left, markup_dir, lang)
16781 else:
16782 trm = JM_show_string_cs( self.this, font.this, trm, text, wmode, right_to_left, markup_dir, lang)
16783 val = JM_py_from_matrix(trm)
16784
16785 self.last_point = Point(val[-2:]) * self.ctm
16786 self.text_rect = self._bbox * self.ctm
16787 val = self.text_rect, self.last_point
16788 if font.flags["mono"] == 1:
16789 self.used_fonts.add(font)
16790 return val
16791
16792 def appendv(self, pos, text, font=None, fontsize=11, language=None, small_caps=False):
16793 lheight = fontsize * 1.2

Callers 15

appendvMethod · 0.95
test_4141Function · 0.95
test_techwriter_appendFunction · 0.95
bbox_countFunction · 0.95
check_nameMethod · 0.45
build_extensionFunction · 0.45
git_itemsFunction · 0.45
_command_linesFunction · 0.45
_get_prerequisitesFunction · 0.45
get_sonameFunction · 0.45
getMethod · 0.45
sysconfig_python_flagsFunction · 0.45

Calls 8

clean_rtlMethod · 0.95
PointClass · 0.85
FontClass · 0.85
JM_point_from_pyFunction · 0.85
JM_show_string_csFunction · 0.85
JM_py_from_matrixFunction · 0.85
logFunction · 0.70
addMethod · 0.45

Tested by 15

test_4141Function · 0.76
test_techwriter_appendFunction · 0.76
bbox_countFunction · 0.76
cibw_cpFunction · 0.36
mainFunction · 0.36
test_remove_rotationFunction · 0.36
test_3950Function · 0.36
get_widgets_by_nameFunction · 0.36
test_2812Function · 0.36
test_boxes_paramFunction · 0.36
test_file_infoFunction · 0.36