Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoMethodError: undefined method `key?' when encoding a subset #45

Closed
camertron opened this issue Oct 20, 2017 · 3 comments
Closed

NoMethodError: undefined method `key?' when encoding a subset #45

camertron opened this issue Oct 20, 2017 · 3 comments

Comments

@camertron
Copy link
Member

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:

NotoSansCJKjp-Regular.otf.zip

@pointlessone
Copy link
Member

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.

@pointlessone
Copy link
Member

I will close this issue now. Feel free to reopen if you feel like your issue is not resolved.

@camertron
Copy link
Member Author

Ah ok that makes sense. Thanks @pointlessone :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants