This is the absolute minimum of additions for PDF/A support (PDF/A-2b).
The API is not that great since there are various standard one can conform to and here it's just a bool, but maybe that is out of scope for the current svg2pdf architecture and should be revisited in the new architecture where Typst and svg2pdf share more code.
Concretely, these changes should result in all rules listed in the Typst tracking issue being satisfied by svg2pdf. The only problems I could find were:
Name length for font names: I adjusted the code to trim them.
Maximum q nesting depth: I added a method to pdf-writer to track the depth (tracking it here would make the code uglier). I think that's generally useful. However, the validation itself happens in svg2pdf. When the nesting depth is too high, a new TooMuchNesting error is returned. In theory, we could use XObjects to reset the depth, but that is too much work right now.
Notdef glyphs: When they are found and PDF/A support is enabled, a new MissingGlyphs error is returned.
Notably, only the notdef rule actually checks for PDF/A mode because the other rules turn out to apply to all PDF standards as far as I can tell!
I would release pdf-writer 0.11.1 before merging this.
I think there are a few more points that require attention:
Strings can't be longer than 32767 bytes -> Can't this happen if someone inputs a very long string? The text showing operator uses strings to display the glyphs, right?
Can't contain more than 8388607 indirect objects -> I guess this can be done on the Typst side?
6.2.11.3.3: IIRC we don't write the WMode in the CMAP dictionary, should be an easy fix, though.
This is the absolute minimum of additions for PDF/A support (PDF/A-2b).
The API is not that great since there are various standard one can conform to and here it's just a bool, but maybe that is out of scope for the current svg2pdf architecture and should be revisited in the new architecture where Typst and svg2pdf share more code.
Concretely, these changes should result in all rules listed in the Typst tracking issue being satisfied by svg2pdf. The only problems I could find were:
TooMuchNesting
error is returned. In theory, we could use XObjects to reset the depth, but that is too much work right now.MissingGlyphs
error is returned.Notably, only the notdef rule actually checks for PDF/A mode because the other rules turn out to apply to all PDF standards as far as I can tell!
I would release pdf-writer 0.11.1 before merging this.