Skip to content

Commit

Permalink
Remove underscores in GlyphHash lookups
Browse files Browse the repository at this point in the history
Certain PDFs use names like 'f_i' to stand for 'fi', so we remove all
underscores.
  • Loading branch information
bernerdschaefer authored and yob committed Oct 19, 2011
1 parent cd0a080 commit fdd1c07
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/pdf/reader/glyph_hash.rb
Expand Up @@ -48,6 +48,7 @@ def initialize
def [](name)
return nil unless name.is_a?(Symbol)

name = name.to_s.gsub('_', '').intern
str = name.to_s

if @adobe.has_key?(name)
Expand Down
5 changes: 5 additions & 0 deletions spec/glyph_hash_spec.rb
Expand Up @@ -13,6 +13,11 @@
map[:zukatakana].should eql(0x30BA)
end

it "should correctly map a glyph name with underscores to unicode" do
map = PDF::Reader::GlyphHash.new
map[:f_i].should eql(map[:fi])
end

it "should correctly map a uniHHHH glyph to unicode" do
map = PDF::Reader::GlyphHash.new
map[:uni0032].should eql(0x0032)
Expand Down

0 comments on commit fdd1c07

Please sign in to comment.