-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move font subsetting from render to output #2149
Move font subsetting from render to output #2149
Conversation
…rid of double frame tree processing
@bsweeney please have a look at this. It worked well in short examples. But I had no run with multiple fonts and I might overlook things I don't know yet. ;) |
Prior to this change Dompdf did not pass the font subsetting option through to PDFLib. The default option for PDFLib is to enable subsetting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran this through my test gauntlet and didn't notice any issues.
I do think we should tweak the way we do this to behave similar to how PDFLib does it. For PDFLib the specifies the font subsetting preference when adding a font to the document. PDFLib handles the actual determination of the characters for the subset. For CPDF we would have to make a few changes to what we have so far:
- Add a new argument to CPDF::selectFont (bool subset) to indicate if subsetting should be enabled for the font.
- Add a new key to the font options to indicate if it is subsetted.
- Modify CPDF::addText to check if the font subset option is true. When the option is true register the passed-in text for subsetting for the font.
- Subsetting can now be determined based on the font option rather than if a subset exists.
- Update the CPDF::o_font "out" action to modify the BaseFont value per section 5.5.3 of the PDF specification. This section indicates that the font name for subsetted fonts should be six characters followed by a plus followed by the font name, e.g.
ABCDEF+DejaVu-Sans-Normal
.
There are two reasons to make this change:
- To better align with the PDF specification where subsetted fonts are concerned.
- Provide a better user experience for subsetting text placed through direct access to the CPDF instance (i.e. the user just has to indicate that the font is subsetted, they don't have to register the text since CPDF will take care of it).
This is what I was thinking about earlier, but probably didn't sufficiently explain myself. Thoughts?
FYI, I added a commit to your branch to add support for honoring the font subset option in PDFLib.
And, finally, I do think with this update that font subsetting works more consistently. As such we should go ahead and set the default font subsetting option to true.
Once we finish up with this I'll return to the RTL branch so we can finish that up. |
Your requested changes are making sense. I'll implement them. |
In detail I did the following changes which should cover all your points:
|
Unicode and file suffix detection are now taken into account early to never collect text data unnecessarily. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
look good
This should not be needed anymore since #2149. The text is registered when it is added to the canvas, as with regular text nodes.
This should not be needed anymore since #2149. The text is registered when it is added to the canvas, as with regular text nodes.
The major part of the font processing is now triggered from the output instead of the render step.
The needed chars are collected from text output calls to CPDF instead of walking the frame tree another time. This also moves all work to CPDF.
Todos:
Addresses: #750