Add new form font.
(self, name, font)
| 3057 | return f"{is_closed}Document('{self.name}', <memory, doc# {self._graft_id:d}>)" |
| 3058 | |
| 3059 | def _addFormFont(self, name, font): |
| 3060 | """Add new form font.""" |
| 3061 | if self.is_closed or self.is_encrypted: |
| 3062 | raise ValueError("document closed or encrypted") |
| 3063 | pdf = _as_pdf_document(self, required=0) |
| 3064 | if not pdf.m_internal: |
| 3065 | return |
| 3066 | fonts = mupdf.pdf_dict_getl( |
| 3067 | mupdf.pdf_trailer( pdf), |
| 3068 | PDF_NAME('Root'), |
| 3069 | PDF_NAME('AcroForm'), |
| 3070 | PDF_NAME('DR'), |
| 3071 | PDF_NAME('Font'), |
| 3072 | ) |
| 3073 | if not fonts.m_internal or not mupdf.pdf_is_dict( fonts): |
| 3074 | raise RuntimeError( "PDF has no form fonts yet") |
| 3075 | k = mupdf.pdf_new_name( name) |
| 3076 | v = JM_pdf_obj_from_str( pdf, font) |
| 3077 | mupdf.pdf_dict_put( fonts, k, v) |
| 3078 | |
| 3079 | def del_toc_item( |
| 3080 | self, |
nothing calls this directly
no test coverage detected