prawnpdf/ttfunk

Unable to use kerning

daniellAlgar opened this issue · 7 comments

Hi all!

I'm facing an issue where the kerning isn't read properly from the font.

file_name = ARGV.first || File.join(__dir__, './my_font.ttf')
file = TTFunk::File.open(file_name)
puts "kerning? : #{file.kerning.exists?}"

result in kerning? : false

The font does contain kerning and I've verified it by installing it in the MacOS Font Book and used the font in TextEdit.

Any thoughts or similar experiences? Or even better, any solution?

+1

This is due to the fact that ttfunk only recognizes kerning in a font that either has an old-style kern table or is in the Apple TTF format. These are both options when you can enable when you save the font with FontForge.

See the second screenshot on https://fontforge.github.io/en-US/documentation/interface/generate/.

If you're using a FontForge script, you'd set the following flags:

genflags = 0x90 + 0x800

which I pass into the Generate command as follows:

Generate(export_file, "", genflags)

I think that saving in the Apple format is just another way of enabling the old-style kern table.

Btw, those flags are:

  • 0x90 - neither OpenType or Apple
  • 0x800 - generate old-style 'kern' table

It isn't necessary to trim the font down like that. It's just what I use.

@mojavelinux Thanks a million! That was indeed the issue.

As a side note: FontForge warns about

Ignoring 'LTSH' linear threshold table
Ignoring 'VDMX' vertical device metrics table
Ignoring 'hdmx' horizontal device metrics table

Is that serious in any way?

Sounds good enough :).

Thank you so much again! I'm closing this issue.