prawnpdf / ttfunk

Font Metrics Parser for Prawn
http://prawnpdf.org
Other
125 stars 75 forks source link

Fix for issue #13 (lots of ruby warnings generated). #21

Closed jessedoyle closed 10 years ago

jessedoyle commented 10 years ago

Many of TTFunk's classes had unused variable assignments. The warnings were bothering me, so I changed all unused variables to underscores, but left a comment above the change outlining what the variable represents. All tests pass for me and the warnings are no longer generated.

jessedoyle commented 10 years ago

I wasn't sure what to do with with the parse_format! method in the file ttfunk/lib/ttfunk/table/post/format25.rb on line 17.

The code was (number_of_glyphs was unused):

def parse_format!
  number_of_glyphs = read(2, 'n').first
  @offsets = read(@number_of_glyphs, "c*")
end

I'm guessing the original author intended to set the instance variable @number_of_glyphs instead of the local variable number_of_glyphs? Or maybe I'm missing something?

Anyways I just removed the unused variable assignment and kept the read, which should theoretically behave in the same manner.

practicingruby commented 10 years ago

@jessedoyle You may have uncovered a bug, because @number_of_glyphs does not appear to be defined anywhere else in the project. For now let's call read(number_of_glyphs, "c*"), but I"m going to open another ticket to try to confirm the correct behavior.

practicingruby commented 10 years ago

@jessedoyle I've taken a closer look at this and I'm pretty sure it's a bug. Because the post table format 2.5 was deprecated back in February 2000, I think we may want to just stop supporting it in TTFunk for the moment. This feature probably never worked properly, so I don't think it'd hurt anyone to turn it off entirely. I'll take care of that in a separate commit after merging your code.

Thanks for the great work!

practicingruby commented 10 years ago

@jessedoyle Because your pull request was accepted, you now have commit access to all prawnpdf repositories. See the contribution guidelines for more details, and thanks for the patch!