OpenPDF icon indicating copy to clipboard operation
OpenPDF copied to clipboard

openpdf-html: Improve support for CSS `@font-face`

Open alexdupre opened this issue 4 months ago • 1 comments

The current support for the @font-face rule has a few issues:

  1. the src property is not correctly parsed, because the code expects a single url function, but there can be others (like format): https://github.com/LibrePDF/OpenPDF/blob/3ddd942e99317cd56e4c871d2956fdda85a8a7cb/openpdf-html/src/main/java/org/openpdf/css/parser/property/PrimitivePropertyBuilders.java#L1562
  2. the font file format is determined by the file extension, but the font url might not have a standard extension: the format function 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
  3. there is no way to embed fonts if the @font-face rule comes from an external @import (so no way to add -fs-pdf-font-embed: embed)
  4. given that there is no support for the format function, probably it doesn't currently support the presence of multiple url with different formats, from which to choose the supported one

alexdupre avatar Sep 12 '25 08:09 alexdupre

Pull requests welcome

andreasrosdal avatar Sep 16 '25 06:09 andreasrosdal