question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[varLib.cff] Suboptimal packing of deltas, or flaw in CFF2?

See original GitHub issue

With a CFF2 VF built from the attached designspace project (modified from MutatorSans), the S rendered at wdth=1000, wght=595 has a bump on the right hand side, even though its corresponding source does not:

letter_S

The bump is at the start/end point of the contour.

The design space has five sources, one on each corner, and a support master between Light Wide and Bold Wide.

Light    Medium   Bold
Wide     Wide     Wide
o--------o--------o
|                 |
|                 |
|                 |
|                 |
|                 |
|                 |
O-----------------o
Light             Bold
Condensed         Condensed
(neutral)

The Medium Wide source is at the location shown (wdth=1000, wght=595)

What I think happens is:

  • The delta for that location is relative to the interpolation between Light Wide and Bold Wide
  • This interpolation has fractional coordinates
  • The delta’s are calculated for relative coordinates (the differences between one point and the next), rounded to integers
  • Leading to an accumulation of rounding errors
  • To the extent that the final point is no longer coinciding with the starting point.
  • (The difference between start and end point is ≈3 units horizontally, and ≈1.5 units vertically.)

On the one hand, in theory the varLib CFF2 packer could do a better job, but looking at the code this seems far from trivial. On the other hand this shows that CFF2 has pretty terrible properties for cases like this.

mutator_sans_S.zip

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
justvanrossumcommented, Oct 1, 2022

if the start point is moved, the “extra start point” needs to be moved too

It does move, but because of the accumulated error over all relative coordinates + deltas, the end point doesn’t always move the exact same distance as the start point. Which is what we’re seeing here.

0reactions
khaledhosnycommented, Oct 4, 2022

I just fixed a bug with fractional CFF coordinates in LibreOffice subsetter the other day, which suggests they work fine elsewhere.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Releases · fonttools/fonttools - GitHub
[varLib.cff] Fixed sub-optimal packing of CFF2 deltas by no longer rounding them to integer (#2838). [scaleUpem] Calculate numShorts in VarData after scale; ...
Read more >
Virtual - pkgsrc.se | The NetBSD package collection
... [varLib.cff] Fixed sub-optimal packing of CFF2 deltas by no longer rounding them to integer - [scaleUpem] Calculate numShorts in VarData after scale; ......
Read more >
ChangeLog.openSUSE-Leap-15.3-DVD-x86_64 ... - Index of /
The precision of handling deltas in Variation Fonts has been - increased.The problem did only show up with multidimensional - designspaces.
Read more >
FontTools fonttools Issues - Giters
[ttx] Non-ascii in CFF FullName string doesn't round-trip. Updated 21 days ago 10 ... [varLib.cff] Suboptimal packing of deltas, or flaw in CFF2?...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found