+
Skip to content

[otData] Fix DeltaValue repeat value #3758

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

Merged
merged 2 commits into from
Feb 4, 2025
Merged

[otData] Fix DeltaValue repeat value #3758

merged 2 commits into from
Feb 4, 2025

Conversation

behdad
Copy link
Member

@behdad behdad commented 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

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 Author

behdad commented Jan 30, 2025

Would be nice to add a test for this, but I don't have cycles for right now.

@behdad behdad requested a review from anthrotype January 30, 2025 13:54
@anthrotype
Copy link
Member

wow.. the DeltaValue's conv.repeat field has been an empty string for 23 years and nobody noticed? 🤔
Is it like nobody ever used it?

Just to confirm I understand, seeting it to None basically is to take the else branch of this if statement, in BaseTable.fromXML?

value = conv.xmlRead(attrs, content, font)
# Some manually-written tables have a conv.repeat of ""
# to represent lists. Hence comparing to None here to
# allow those lists to be read correctly from XML.
if conv.repeat is not None:
seq = getattr(self, conv.name, None)
if seq is None:
seq = []
setattr(self, conv.name, seq)
seq.append(value)
else:
setattr(self, conv.name, value)

@behdad
Copy link
Member Author

behdad commented Jan 30, 2025

wow.. the DeltaValue's conv.repeat field has been an empty string for 23 years and nobody noticed? 🤔
Is it like nobody ever used it?

I probably broke it in 2013: 7d13030

But yeah, wow!

Just to confirm I understand, seeting it to None basically is to take the else branch of this if statement, in BaseTable.fromXML?

Correct.

@behdad
Copy link
Member Author

behdad commented Jan 30, 2025

In HarfBuzz-using systems we don't even bother delta-adjusting GPOS.

@anthrotype
Copy link
Member

I'll work on a test tomorrow

@behdad
Copy link
Member Author

behdad commented Jan 30, 2025

I probably broke it in 2013: 7d13030

Oh. Probably more recently: ec78b57

@behdad
Copy link
Member Author

behdad commented Jan 30, 2025

I probably broke it in 2013: 7d13030

Oh. Probably more recently: ec78b57

I just checked, and DeltaValues are the only suspect of breakage from my change. The rest are intentional I believe:


>>> from otData import otData 
>>> for name,attrs in otData:
...     for typ,attrName,repeat,aux,desc in attrs:
...         if not repeat and repeat is not None:
...             print(name, attrName)
...             
Device DeltaValue
VarIdxMap mapping
DeltaSetIndexMapFormat0 mapping
DeltaSetIndexMapFormat1 mapping
MultiVarData Item
AxisIndicesList Item
VarCompositeGlyphs VarCompositeGlyph

@behdad
Copy link
Member Author

behdad commented Feb 4, 2025

LGTM. THanks.

@anthrotype
Copy link
Member

I force-pushed so that the test now does a full roundtrip (XML->binary->XML)

@anthrotype anthrotype merged commit 307b312 into main Feb 4, 2025
11 checks passed
@anthrotype anthrotype deleted the DeltaValue branch February 4, 2025 10:44
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浏览器服务,不要输入任何密码和下载