OpenPDF
OpenPDF copied to clipboard
openpdf-html: Improve support for CSS `@font-face`
The current support for the @font-face rule has a few issues:
- the
srcproperty is not correctly parsed, because the code expects a singleurlfunction, but there can be others (likeformat): https://github.com/LibrePDF/OpenPDF/blob/3ddd942e99317cd56e4c871d2956fdda85a8a7cb/openpdf-html/src/main/java/org/openpdf/css/parser/property/PrimitivePropertyBuilders.java#L1562 - the font file format is determined by the file extension, but the font url might not have a standard extension: the
formatfunction should be the preferred method to determine the type, with fallback on file extension: https://github.com/LibrePDF/OpenPDF/blob/3ddd942e99317cd56e4c871d2956fdda85a8a7cb/openpdf-html/src/main/java/org/openpdf/pdf/ITextFontResolver.java#L286 - there is no way to embed fonts if the
@font-facerule comes from an external@import(so no way to add-fs-pdf-font-embed: embed) - given that there is no support for the
formatfunction, probably it doesn't currently support the presence of multipleurlwith different formats, from which to choose the supported one
Pull requests welcome