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

Function util_measure_string

src/__init__.py:24169–24188  ·  view source on GitHub ↗
( text, fontname, fontsize, encoding)

Source from the content-addressed store, hash-verified

24167
24168
24169def util_measure_string( text, fontname, fontsize, encoding):
24170 font = mupdf.fz_new_base14_font(fontname)
24171 w = 0
24172 pos = 0
24173 while pos < len(text):
24174 t, c = mupdf.fz_chartorune(text[pos:])
24175 pos += t
24176 if encoding == mupdf.PDF_SIMPLE_ENCODING_GREEK:
24177 c = mupdf.fz_iso8859_7_from_unicode(c)
24178 elif encoding == mupdf.PDF_SIMPLE_ENCODING_CYRILLIC:
24179 c = mupdf.fz_windows_1251_from_unicode(c)
24180 else:
24181 c = mupdf.fz_windows_1252_from_unicode(c)
24182 if c < 0:
24183 c = 0xB7
24184 g = mupdf.fz_encode_character(font, c)
24185 dw = mupdf.fz_advance_glyph(font, g, 0)
24186 w += dw
24187 ret = w * fontsize
24188 return ret
24189
24190
24191def util_sine_between(C, P, Q):

Callers 1

get_text_lengthFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…