Sha256: abb39090661ab2877781dcd70def125a478541e57ec68d8fa7cdbb9a888f059b

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

module TTFunk
  class Table
    class Kern < Table
      def initialize(fh, font, info)
        fh.pos = info[:offset]
        data = fh.read(4)
        @fh = fh
        @version, @table_count = data.unpack("n2")
        
        @table_headers = {}
        
        @table_count.times do
          version, length, coverage = fh.read(6).unpack("n3")
          @table_headers[version] = { :length   => length, 
                                      :coverage => coverage,
                                      :format   => coverage >> 8 }
        end   
        
        generate_subtables
      end
        
      def generate_subtables
        @sub_tables = {}
        @table_headers.each do |version, data|
          if data[:format].zero?
            @sub_tables[0] = parse_subtable_format0
          else
            warn "TTFunk does not support kerning tables of format #{data[:format]}"
          end
        end
      end
      
      def parse_subtable_format0
        sub_table = {}
        pair_count, search_range, entry_selector, range_shift = @fh.read(8).unpack("n4")
        
        pair_count.times do
          left, right = @fh.read(4).unpack("n2")
          fword = to_signed(@fh.read(2).unpack("n").first)
          sub_table[[left,right]] = fword
        end
        
        return sub_table
      end
      
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
prawn-0.3.0 vendor/ttfunk/lib/ttfunk/table/kern.rb