Skip to content

(Bug) Removed wrong width == height check and removed debug statement

Jeremy Soller requested to merge fschutt:master into master

Created by: fschutt

This is a bug that I noticed here: https://github.com/dylanede/rusttype/issues/47

What the old code is doing is nonsense - it reads the numberOfContours from the glyf table and the first two bytes of the xMin coordinate. If they are not equal (most cases), it returns the offset of the glyf in the file. In the case of the space character (U+0020) the number of contours is 0, and the x coordinate is -10, which in big endian means that the first two bytes are 0, too. So I couldn't get the width of the character.

At least that is what I get from the Microsoft documentation about TrueType fonts:

Type Name Description
SHORT numberOfContours If,the number of contours is greater than or equal to zero, this is a single glyph; if negative, this is a composite glyph.
FWord xMin Minimum x for coordinate data.
FWord yMin Minimum y for coordinate data.
FWord xMax Maximum x for coordinate data.
FWord yMax Maximum y for coordinate data.

Merge request reports