Sha256: 6b435555c0ae46af98274f70adb94db02ae092f49df7aad7610bde7a847e74ef

Contents?: true

Size: 785 Bytes

Versions: 4

Compression:

Stored size: 785 Bytes

Contents

require_relative '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))
          until strings.eof?
            length = strings.read(1).unpack('C').first
            @names << strings.read(length)
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 3 versions & 2 rubygems

Version Path
embulk-input-druginfo_interview_form-0.1.0 vendor/bundle/ruby/2.4.0/gems/ttfunk-1.5.1/lib/ttfunk/table/post/format20.rb
embulk-input-druginfo_interview_form-0.1.0 vendor/bundle/ruby/2.5.0/gems/ttfunk-1.5.1/lib/ttfunk/table/post/format20.rb
ttfunk-1.5.1 lib/ttfunk/table/post/format20.rb
ttfunk-1.5.0 lib/ttfunk/table/post/format20.rb