Relationship between left side bearing and contour coordinates (TTX/FontTools)

John YeungJohn Yeung Posts: 1
edited November 22 in Font Technology

I was fiddling around with TTX/FontTools and noticed that if I adjust the left side bearing of a glyph (just find that one number in the TTX file and replace it with another number) and then recompile the font, the glyph is indeed shifted to the left or right, but the stored coordinates of all the contour points remain unchanged. For example, if a glyph's leftmost point in the contour data is (100, 0) and I change the LSB from 100 to 60, then in the resulting font, the glyph really is displayed 40 units to the left of where it was in the original font. Yet the contour data still has (100, 0) as the leftmost point, not (60, 0). This is confirmed by looking at the TTX file which results from the recompiled font.

My question is: If I want to programmatically shift glyphs like this, should I be readjusting all the contour points as well, for consistency? Or is that like painting the back of a cabinet that will be mounted against a wall? Are there any ill effects from leaving the contour data as-is while fiddling with the LSB (and advance width, as needed)?

Though I happen to be using TTX, I would think this question isn't limited to TTX. It's more generally about the font file (.ttf in my case). Or is TTX the only tool which allows such a state to occur?

Comments

  • The effect you found there is a fully valid usage of the LSB data.

    In the OpenType ‘head’ table flags field there is a bit that should be set (bit 1) when LSB is equal to the minimum x coordinate for all glyphs. In your case if you modify only the LSB, you should unset that bit.

    The existence of this bit probably means that there is a faster processing path in font rendering engines for the case that all LSB are set in this optimal way. As far as I know, all font editors will calculate the LSB and coordinates in this way. For OpenType variation fonts, it is even a requirement.
Sign In or Register to comment.