(doc: pymupdf.Document, xref: int)
| 788 | |
| 789 | |
| 790 | def _get_font_properties(doc: pymupdf.Document, xref: int) -> tuple: |
| 791 | fontname, ext, stype, buffer = doc.extract_font(xref) |
| 792 | asc = 0.8 |
| 793 | dsc = -0.2 |
| 794 | if ext == "": |
| 795 | return fontname, ext, stype, asc, dsc |
| 796 | |
| 797 | if buffer: |
| 798 | try: |
| 799 | font = pymupdf.Font(fontbuffer=buffer) |
| 800 | asc = font.ascender |
| 801 | dsc = font.descender |
| 802 | bbox = font.bbox |
| 803 | if asc - dsc < 1: |
| 804 | if bbox.y0 < dsc: |
| 805 | dsc = bbox.y0 |
| 806 | asc = 1 - dsc |
| 807 | except Exception: |
| 808 | pymupdf.exception_info() |
| 809 | asc *= 1.2 |
| 810 | dsc *= 1.2 |
| 811 | return fontname, ext, stype, asc, dsc |
| 812 | if ext != "n/a": |
| 813 | try: |
| 814 | font = pymupdf.Font(fontname) |
| 815 | asc = font.ascender |
| 816 | dsc = font.descender |
| 817 | except Exception: |
| 818 | pymupdf.exception_info() |
| 819 | asc *= 1.2 |
| 820 | dsc *= 1.2 |
| 821 | else: |
| 822 | asc *= 1.2 |
| 823 | dsc *= 1.2 |
| 824 | return fontname, ext, stype, asc, dsc |
| 825 | |
| 826 | |
| 827 | def _show_fz_text( text): |
nothing calls this directly
no test coverage detected
searching dependent graphs…