Skip to content
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

Preserve format of value records after reading #861

Merged
merged 1 commit into from
Mar 26, 2024
Merged

Conversation

cmyr
Copy link
Member

@cmyr cmyr commented Mar 26, 2024

ValueRecords have an explicit format, which is generally stored once in their parent table. In the case of records with device or variation tables, we need to know the format in order to write them correctly, since it's possible for these fields to be legitimately null, and we cannot distinguish between a record which where a field is None because it is not included versus when it is intended to be null.

Previously, we would use the format when reading the table but would then discard it. This led to a bug where we would not know the correct format when we went to write the table back.

With this patch, we hold onto the format after reading, and pass it to write-fonts if we convert to write-fonts types. This ensures that we roundtrip tables correctly in this case.

closes #858

ValueRecords have an explicit format, which is generally stored once in
their parent table. In the case of records with device or variation
tables, we need to know the format in order to write them correctly,
since it's possible for these fields to be legitimately null, and we
cannot distinguish between a record which where a field is None because
it is not included versus when it is intended to be null.

Previously, we would use the format when reading the table but would
then discard it. This led to a bug where we would not know the correct
format when we went to write the table back.

With this patch, we hold onto the format after reading, and pass it to
write-fonts if we convert to write-fonts types. This ensures that we
roundtrip tables correctly in this case.
pub fn read_old(data: &[u8], format: ValueFormat) -> Result<Self, ReadError> {
let data = FontData::new(data);
Self::read(data, format)
// we ignore the format for the purpose of equality testing, it's redundant
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it's redundant why do we need to store it? - seems slightly contradictory. Perhaps further explanation of how this makes sense?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, it is redundant for the purposes of comparing two value records. In that case (testing, e.g.) I don't think we care.

@cmyr cmyr merged commit 59060d4 into main Mar 26, 2024
9 checks passed
@cmyr cmyr deleted the roundtrip-value-record branch March 26, 2024 17:06
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.

Recompiling GPOS unchanged fails for some fonts
3 participants