Class: TTFunk::Table::Kern

Inherits:
TTFunk::Table show all
Defined in:
lib/ttfunk/table/kern.rb,
lib/ttfunk/table/kern/format0.rb

Overview

Kerning (‘kern`) table

Defined Under Namespace

Classes: Format0

Instance Attribute Summary collapse

Attributes inherited from TTFunk::Table

#file, #length, #offset

Class Method Summary collapse

Methods inherited from TTFunk::Table

#exists?, #initialize, #raw, #tag

Constructor Details

This class inherits a constructor from TTFunk::Table

Instance Attribute Details

#tablesArray<TTFunk::Table::Kern::Format0> (readonly)

Subtables.

Returns:



15
16
17
# File 'lib/ttfunk/table/kern.rb', line 15

def tables
  @tables
end

#versionInteger (readonly)

Table version

Returns:

  • (Integer)


11
12
13
# File 'lib/ttfunk/table/kern.rb', line 11

def version
  @version
end

Class Method Details

.encode(kerning, mapping) ⇒ String?

Encode table.

Parameters:

  • kerning (TTFunk::Table::Kern)
  • mapping (Hash{Integer => Integer})

    keys are new glyph IDs, values are old glyph IDs

Returns:

  • (String, nil)


23
24
25
26
27
28
29
30
# File 'lib/ttfunk/table/kern.rb', line 23

def self.encode(kerning, mapping)
  return unless kerning.exists? && kerning.tables.any?

  tables = kerning.tables.filter_map { |table| table.recode(mapping) }
  return if tables.empty?

  [0, tables.length, tables.join].pack('nnA*')
end