Class: Fontisan::Ufo::Compile::FeatureWriters::Kern2
- Defined in:
- lib/fontisan/ufo/compile/feature_writers/kern2.rb
Overview
Extended kerning (format 2 / Device-table variant of PairPos).
Same data shape as the basic Kern writer, but emits the extended format that supports:
- device tables (sub-pixel kerning)
- cross-stream kerning (y-direction adjustments)
- per-pair value-format overrides
The current implementation extracts the same kerning.pairs data as Kern; the differentiation is in how the GPOS table builder encodes the value format (Format1 vs Format2, plus device tables). Writers do not need to know about that — they just emit the structured data; the table builder picks the encoding.
Downstream consumers (compilers) choose between Kern and Kern2 based on whether they need device tables. Most don't; basic Kern is sufficient for the common case.
Constant Summary collapse
- LOOKUP_TYPE =
2- FEATURE_TAG =
"kern"- TABLE_TAG =
"GPOS"- FORMAT =
2
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Fontisan::Ufo::Compile::FeatureWriters::Base
Instance Method Details
#write ⇒ FeatureOutput?
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/fontisan/ufo/compile/feature_writers/kern2.rb', line 32 def write return nil if font.kerning.nil? || font.kerning.empty? pairs = font.kerning.pairs.map do |key, value| left, right = key.to_s.split(" ", 2) { left: left, right: right, value: value.to_f, group_left: left.to_s.start_with?("@"), group_right: right.to_s.start_with?("@"), } end FeatureOutput.new( table_tag: TABLE_TAG, feature_tag: FEATURE_TAG, lookup_type: LOOKUP_TYPE, data: { format: FORMAT, pairs: pairs }, ) end |