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

Avoid negative hmtx values when creating font from variable CFF2 font #2827

Merged
merged 1 commit into from Sep 20, 2022

Conversation

liZe
Copy link
Contributor

@liZe liZe commented Sep 20, 2022

Fix #2821.

@anthrotype anthrotype changed the title Avoid negative hmtx values when creating font from variable font Avoid negative hmtx values when creating font from variable CFF2 font Sep 20, 2022
@anthrotype anthrotype merged commit 85fcb94 into fonttools:main Sep 20, 2022
@behdad
Copy link
Member

behdad commented Sep 20, 2022

Fix looks arbitrary though. This is speced nowhere.

@anthrotype
Copy link
Member

well, hmtx advance can't be negative, they are encoded as unsigned 16-bit integer, no?

@behdad
Copy link
Member

behdad commented Sep 20, 2022

well, hmtx advance can't be negative, they are encoded as unsigned 16-bit integer, no?

Correct. Though applications might interpret them otherwise. I'd say this is a case of a bad font. The fact that the advance is encoded as unsigned in hmtx is orthogonal to whether the combined advance has to be nonnegative.

@behdad
Copy link
Member

behdad commented Sep 20, 2022

We have other places in the format also that the variations can take a value outside the limits of its original value.

@anthrotype
Copy link
Member

FWIW we also do a similar thing for truetype-flavored VFs in the varLib.instancer, see

if horizontalAdvanceWidth < 0:
# unlikely, but it can happen, see:
# https://github.com/fonttools/fonttools/pull/1198
horizontalAdvanceWidth = 0

@behdad
Copy link
Member

behdad commented Sep 20, 2022

Okay I see; I forgot we are talking about instancing. Nevermind.

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.

Calling instantiateVariableFont can lead to negative advance widths in hmtx
3 participants