Merged from upstream 19 261105 01
Killed
merged
Commit message
[FIX] tools: convert PDFs using simple fonts to PDF/A Steps to reproduce: - Install the optional `fonttools` package (it is also pulled by other packages, e.g. `pyHanko[opentype]`) - Run `odoo-bin -i base --test-tags /base:TestPdf` Issue: `test_convert_to_pdfa_without_outlines` fails with `KeyError: '/DescendantFonts'`. Cause: When `fonttools` is installed, `convert_to_pdfa` rewrites the glyph widths of the fonts used in the PDF and reads `/DescendantFonts` of every font, assuming they are all composite (Type0) fonts like the ones embedded by wkhtmltopdf. Simple fonts (Type1, TrueType, ...), such as the Arial font of `base/tests/minimal.pdf`, have no descendant fonts, so the conversion crashes. Without `fonttools` the whole block is skipped, which hides the issue. The callers (Factur-X/ZUGFeRD and ZATCA invoice PDFs) catch the exception and only log it, so such a PDF is sent without being converted to PDF/A. Fix: Only collect the descendant fonts of composite fonts. Simple fonts keep their widths in `/Widths` (or use the standard 14 font metrics) and are left untouched. (cherry picked from commit c0604707ec5db1e309b78d196a2aec2fb3e08a7f) Signed-off-by: David Tran <david.tran@tvtmarine.com>