Uh oh!
There was an error while loading. Please reload this page.
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.
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 think this will cause us to switch to the large format sometimes when not needed. For example, if the original font contained a lot of glyphs, but the subset only contains a few, then we shouldn't need to use the large format.
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.
This should not be a issue because the subset size would still be proportional to the original font. Say we have a font with 1000 glyphs with same size, a subset with 100 glyphs of such font would have the expected 10% size of the original.
Also is not doable to convert from large to short format because would require to make all offsets even numbers, needing to add some sort of data padding complicating things at write and read time. This could even work with fontkit but would not work for, e.g, pdf readers
In a font i was testing (NanumGothic) the .notdef (id 0) glyph has a size of 87 bytes = the offset of the first glyph in the subset. Since the short format requires the offset to be stored divided by 2, it saves as 43. When reading the subset, the offset is multiplied by 2 getting 86 -> the glyph data is read incorrectly.
To convert to short format it would need pad the id 0 glyph (or any odd sized glyph) to have one more byte or store a lookup somewhere the glyphs that need to have the offset corrected at read time. This should work in fontkit only and the complexity (and size increase) is not worth.