Class: Fontisan::Ufo::Compile::FeatureWriters::MarkFamilyBase

Inherits:
Base
  • Object
show all
Defined in:
lib/fontisan/ufo/compile/feature_writers/mark_family_base.rb

Overview

Shared base for feature writers that pair "mark" glyphs with "base" glyphs via a paired-anchor convention (Mark uses _<name><name>; Mkmk uses _<name>mkmk<name>mkmk). Concrete subclasses plug in the lookup convention + the lookup type + the feature tag.

Reduces duplication between Mark and Mkmk: both walk every glyph, collect its anchor classes (with the convention's prefix + suffix), then pair each class with matching bases.

Direct Known Subclasses

Mark, Mkmk

Instance Attribute Summary

Attributes inherited from Base

#font

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Fontisan::Ufo::Compile::FeatureWriters::Base

Instance Method Details

#writeFeatureOutput?

Returns:



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fontisan/ufo/compile/feature_writers/mark_family_base.rb', line 18

def write
  marks = collect_marks
  return nil if marks.empty?

  attachments = {}

  marks.each do |(mark_name, classes)|
    classes.each do |class_name, mark_anchor|
      bases = collect_bases_for(class_name)
      next if bases.empty?

      attachments[class_name] ||= new_class_entry
      attachments[class_name][:marks][mark_name] = mark_anchor
      bases.each { |n, a| attachments[class_name][base_bucket_key][n] = a }
    end
  end

  return nil if attachments.empty?

  FeatureOutput.new(
    table_tag: table_tag,
    feature_tag: feature_tag,
    lookup_type: lookup_type,
    data: { attachments: attachments },
  )
end