lib/ttfunk/table/kern.rb in ttfunk-1.7.0 vs lib/ttfunk/table/kern.rb in ttfunk-1.8.0

- old
+ new

@@ -2,18 +2,30 @@ require_relative '../table' module TTFunk class Table + # Kerning (`kern`) table class Kern < Table + # Table version + # @return [Integer] attr_reader :version + + # Subtables. + # @return [Array<TTFunk::Table::Kern::Format0>] attr_reader :tables + # Encode table. + # + # @param kerning [TTFunk::Table::Kern] + # @param mapping [Hash{Integer => Integer}] keys are new glyph IDs, values + # are old glyph IDs + # @return [String, nil] def self.encode(kerning, mapping) return unless kerning.exists? && kerning.tables.any? - tables = kerning.tables.map { |table| table.recode(mapping) }.compact + tables = kerning.tables.filter_map { |table| table.recode(mapping) } return if tables.empty? [0, tables.length, tables.join].pack('nnA*') end @@ -50,15 +62,15 @@ add_table( format, version: version, length: length, coverage: coverage, - data: raw[10..-1], + data: raw[10..], vertical: (coverage & 0x1).zero?, minimum: (coverage & 0x2 != 0), cross: (coverage & 0x4 != 0), - override: (coverage & 0x8 != 0) + override: (coverage & 0x8 != 0), ) end def parse_version_1_tables(num_tables) num_tables.times do @@ -71,10 +83,10 @@ coverage: coverage, tuple_index: tuple_index, data: io.read(length - 8), vertical: (coverage & 0x8000 != 0), cross: (coverage & 0x4000 != 0), - variation: (coverage & 0x2000 != 0) + variation: (coverage & 0x2000 != 0), ) end end def add_table(format, attributes = {})