-
Notifications
You must be signed in to change notification settings - Fork 81
Description
Hello! I have noticed that for various ttf fonts the kerning table does not seem to get populated (example: https://fonts.google.com/specimen/Luxurious+Roman).
When I load the font with the stb_truetype library I get non-zero kerning values for character pairs such as ('A', 'V'), but if I load the same ttf file with fontdue, Font::horizontal_kern returns None for all glyph pairs.
Example:
let bytes = std::fs::read("LuxuriousRoman-Regular.ttf").unwrap();
let font = fontdue::Font::from_bytes(&bytes[..], FontSettings::default()).unwrap();
dbg!( font.horizontal_kern('A', 'V', 40.0)); // is None, but shouldn't be!
No kerning as visible here:

How is should look like:
Edit: I think the issue is with how the kerning is loaded:
face.raw_face().table(Tag::from_bytes(&b"kern"))?;
This just looks at the kern table, but a lot of fonts omit this table and put the kerning information into the gpos table instead, which contains records such as:
TagRecord {
tag: Tag(kern),
offset: Offset16(38),
},
For example stb_truetype is doing this:
if (info->gpos)
xAdvance += stbtt__GetGlyphGPOSInfoAdvance(info, g1, g2);
else if (info->kern)
xAdvance += stbtt__GetGlyphKernInfoAdvance(info, g1, g2);
