NoMethodError: undefined method `key?' when encoding a subset
camertron opened this issue · 3 comments
Hey guys,
First of all, thanks for all the work you do on Prawn and TTFunk! The ruby community really appreciates it :)
I'm trying to use TTFunk to subset the Noto font, but getting an error with the following snippet (adapted from looking at the tests):
font = TTFunk::File.open('path/to/NotoSansCJKjp-Regular.otf')
subset = TTFunk::Subset.for(font, :unicode)
subset.use(0x304b) # Katakana letter "ka"
subset.encode
I get the following error:
NoMethodError: undefined method `key?' for nil:NilClass
from /Users/cameron/workspace/ttfunk/lib/ttfunk/table/glyf.rb:30:in `for'
from /Users/cameron/workspace/ttfunk/lib/ttfunk/subset/base.rb:158:in `block in collect_glyphs'
from /Users/cameron/workspace/ttfunk/lib/ttfunk/subset/base.rb:157:in `each'
from /Users/cameron/workspace/ttfunk/lib/ttfunk/subset/base.rb:157:in `each_with_object'
from /Users/cameron/workspace/ttfunk/lib/ttfunk/subset/base.rb:157:in `collect_glyphs'
from /Users/cameron/workspace/ttfunk/lib/ttfunk/subset/base.rb:32:in `encode'
It looks like the @cache
variable is nil
.
Any idea why that would be? I would be happy to track down the issue and submit a pull request, but I have no idea where to start. Thanks!
Oh, and here's the font in question:
The glyf
table might not have been parsed. Cache is initialized during the parsing. The reason might be that TTfunk doesn't officially support OTF.
I will close this issue now. Feel free to reopen if you feel like your issue is not resolved.
Ah ok that makes sense. Thanks @pointlessone :)