[glyf] Attempt to drop empty components from composite glyphs. #289
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is because such components cause DirectWrite to fail to render the composite at all, even though an empty component should (presumably) have no visible effect.
Reported in the context of pdf.js at mozilla/pdf.js#18848, but experimentation indicates that Windows/DWrite fails to paint such glyphs in other contexts as well -- e.g. when using Character Map to view an installed font.
(I don't think there's any real use case for such components, and their presence is probably an anomaly/artifact of a particular font creation/subsetting/embedding workflow. Still, if OTS can fix them up, this will best serve end users.)
The current patch discards empty components from composite glyphs unless the empty glyph is the last component. In that case, we can't just skip it, because the preceding component (which will now be last) has the MORE_COMPONENTS flag, and that's no longer true. I have not seen cases in the wild where this issue affects the final component, but it's presumably possible (and testing indicates that DirectWrite would fail in that case too), so this would be a good followup enhancement. Currently the code just issues a warning if such a case occurs.