Sha256: 1b0664fee66f6011959fe6184632531a704f4ca3ec4e872f4244843a3f846503

Contents?: true

Size: 813 Bytes

Versions: 34

Compression:

Stored size: 813 Bytes

Contents

require 'ttfunk/table/post/format10'
require 'stringio'

module TTFunk
  class Table
    class Post
      module Format20
        include Format10

        def glyph_for(code)
          index = @glyph_name_index[code]
          if index <= 257
            POSTSCRIPT_GLYPHS[index]
          else
            @names[index - 258] || ".notdef"
          end
        end

        private

          def parse_format!
            number_of_glyphs = read(2, 'n').first
            @glyph_name_index = read(number_of_glyphs*2, 'n*')
            @names = []

            strings = StringIO.new(io.read(offset + length - io.pos))
            while !strings.eof?
              length = strings.read(1).unpack("C").first
              @names << strings.read(length)
            end
          end
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 10 rubygems

Version Path
ttfunk-1.2.2 lib/ttfunk/table/post/format20.rb
ttfunk-1.2.1 lib/ttfunk/table/post/format20.rb
ttfunk-1.2.0 lib/ttfunk/table/post/format20.rb
ttfunk-1.1.1 lib/ttfunk/table/post/format20.rb
ttfunk-1.1.0 lib/ttfunk/table/post/format20.rb
ttfunk-1.0.3 lib/ttfunk/table/post/format20.rb
ttfunk-1.0.2 lib/ttfunk/table/post/format20.rb
ttfunk-1.0.1 lib/ttfunk/table/post/format20.rb
davebenvenuti-prawn-0.11.1.pre vendor/ttfunk/lib/ttfunk/table/post/format20.rb
piglop-prawn-0.10.2.3 vendor/ttfunk/lib/ttfunk/table/post/format20.rb
piglop-prawn-0.10.2.2 vendor/ttfunk/lib/ttfunk/table/post/format20.rb
piglop-prawn-0.10.2.1 vendor/ttfunk/lib/ttfunk/table/post/format20.rb
glyph_imager-0.1.1 vendor/ttfunk/lib/ttfunk/table/post/format20.rb
prawn-0.11.1.pre vendor/ttfunk/lib/ttfunk/table/post/format20.rb
goodwill-prawn-edge-0.10.0 vendor/ttfunk/lib/ttfunk/table/post/format20.rb
alphasights-prawn-0.10.4 vendor/ttfunk/lib/ttfunk/table/post/format20.rb
alphasights-prawn-0.10.3 vendor/ttfunk/lib/ttfunk/table/post/format20.rb
alphasights-prawn-0.10.2 vendor/ttfunk/lib/ttfunk/table/post/format20.rb
alphasights-prawn-0.10.1 vendor/ttfunk/lib/ttfunk/table/post/format20.rb
glyph_imager-0.1.0 vendor/ttfunk/lib/ttfunk/table/post/format20.rb