-
Notifications
You must be signed in to change notification settings - Fork 222
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
vhea
and glyf
fixes
#305
Open
StLyn4
wants to merge
4
commits into
foliojs:master
Choose a base branch
from
StLyn4:vhea-and-glyf-fixes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
vhea
and glyf
fixes
#305
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Note that the
vhea
version field is a 16dot16 number, which is not the same as two 16 bit ints.The first number is a uint16, but the second number uses a very different format, in which only values
0x0000
,0x1000
, ...,0x9000
are valid, and represent minor versions 0 through 9. When parsed as uint16, the result needs to be bitshifted right by 12 to get the actual value.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.
Good day! 👋 Thank you for the clarification. As I see it, the
maxp
table uses the same approach (16dot16) to versioning. In this library,maxp
describes the version as a simple 32-bit number with no additional major/minor divisions, because version, as I understand it, is not used anywhere else.fontkit/src/tables/maxp.js
Line 5 in a5fe0a1
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.
Correct, there are three tables (
maxp
,post
,vhea
) that use 16dot16 for historical reasons, and thankfully no future table will ever be allowed to use it again. If themaxp
table uses a 32 int, that may need fixing too, as there are technically two versions for themaxp
table (0.5 and 1.0).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.
Looking at https://github.com/foliojs/fontkit/tree/master/src/tables/post.js, it seems like that table, too, is not doing the right thing: as per the OpenType docs, "In earlier versions, these fields were documented as using a Fixed value, but had minor version numbers that did not follow the definition of the Fixed type" so if you want to make your code do "the same" as the
post
table, using ther.fixed32
as versioning field is probably the right way to go, unless restructure adds a 16dot16 type.Hopefully @devongovett can have a quick look here.
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.
oh that's fun. You might have to implement a custom type for that. Here is how
Fixed
is implemented. You'd need to do something similar to handle this type.I would also not switch this to two separate fields as that might be considered a breaking change (if someone was using the
version
field before).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 made a small encoder/decoder that should handle the given type and applied it to all 3 tables. A small note regarding the
Base
class of the restructure library: it is not exported, so we had to abandon inheritance and add thefromBuffer
andtoBuffer
methods directly toVersion16Dot16
. The test results did not change in any way (at least no degradation was noticed).