Return tuple of char lengths of unicode 'text' under a fontsize.
(self, text, fontsize=11, language=None, script=0, wmode=0, small_caps=0)
| 8250 | return mupdf.fz_buffer_extract_copy( buffer_) |
| 8251 | |
| 8252 | def char_lengths(self, text, fontsize=11, language=None, script=0, wmode=0, small_caps=0): |
| 8253 | """Return tuple of char lengths of unicode 'text' under a fontsize.""" |
| 8254 | lang = mupdf.fz_text_language_from_string(language) |
| 8255 | rc = [] |
| 8256 | for ch in text: |
| 8257 | c = ord(ch) |
| 8258 | if small_caps: |
| 8259 | gid = mupdf.fz_encode_character_sc(self.this, c) |
| 8260 | if gid >= 0: |
| 8261 | font = self.this |
| 8262 | else: |
| 8263 | gid, font = mupdf.fz_encode_character_with_fallback(self.this, c, script, lang) |
| 8264 | rc.append(fontsize * mupdf.fz_advance_glyph(font, gid, wmode)) |
| 8265 | return rc |
| 8266 | |
| 8267 | @property |
| 8268 | def descender(self): |