+
Skip to content

DeltaValue writer fails to write #3757

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

Closed
wants to merge 1 commit into from
Closed

Conversation

aaronbell
Copy link

@aaronbell aaronbell commented Jan 29, 2025

I have a font with Delta values built into the GPOS table that I am trying to round-trip through TTX:

Here is an example of it:

              <BaseRecord index="3">
                <BaseAnchor index="0" Format="3">
                  <XCoordinate value="1460"/>
                  <YCoordinate value="0"/>
                  <XDeviceTable>
                    <StartSize value="23"/>
                    <EndSize value="35"/>
                    <DeltaFormat value="2"/>
                    <DeltaValue value="[2, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1]"/>
                  </XDeviceTable>
                  <YDeviceTable>
                    <StartSize value="11"/>
                    <EndSize value="35"/>
                    <DeltaFormat value="2"/>
                    <DeltaValue value="[2, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1]"/>
                  </YDeviceTable>
                </BaseAnchor>

However, every time I tried to build the font, fonttools errors on the deltavalues above. Stepping through the specific code in otConverters, I found that the problem is due to this line assert len(DeltaValue) == nItems. In manually counting the items, this assertion appears to be fine, but I discovered that the value that is being passed into DeltaValue is not [2, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1] as it should be, but [[2, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1]], which is of course returning a len of 1 instead of 13.

Adding [0] to the declaration for DeltaValue solves this problem.

Updating the DeltaFormat write tool which appears to fail on compilation due to a list being inside a list.
@aaronbell
Copy link
Author

I expect there could be a different / better way to solve this bug than this approach, but I'll leave that to someone who understands the backend of fonttools better than I to sort out :)

@behdad
Copy link
Member

behdad commented Jan 29, 2025

Ouch. It must have hurt to debug that. I'll check soon. The correct fix might be somewhere else, as we should NOT be getting a list of lists to begin with. Can you attach or email me a full ttx file? Thanks!

@aaronbell
Copy link
Author

Sent!

behdad added a commit that referenced this pull request Jan 30, 2025
The "" marker is used when a custom converter expects a list.
For DeltaValues, we expect a list as a single value, not a list
to be enumerated in XML. So, None is appropriate here. Cryptic,
I know...

Fixes #3757
@behdad
Copy link
Member

behdad commented Jan 30, 2025

Proper fix in #3758

@behdad behdad closed this Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载