Class: Fontisan::Export::Transformers::FontToTtx

Inherits:
Object
  • Object
show all
Defined in:
lib/fontisan/export/transformers/font_to_ttx.rb

Overview

FontToTtx orchestrates font to TTX transformation

Main transformer that coordinates conversion of a complete font to TTX format using individual table transformers. Follows model-to-model transformation principles with clean separation of concerns.

Instance Method Summary collapse

Constructor Details

#initialize(font) ⇒ FontToTtx

Initialize transformer

Parameters:



16
17
18
# File 'lib/fontisan/export/transformers/font_to_ttx.rb', line 16

def initialize(font)
  @font = font
end

Instance Method Details

#transform(options = {}) ⇒ Models::Ttx::TtFont

Transform font to TTX model

Parameters:

  • options (Hash) (defaults to: {})

    Transformation options

Options Hash (options):

  • :tables (Array<String>)

    Specific tables to include

Returns:



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fontisan/export/transformers/font_to_ttx.rb', line 25

def transform(options = {})
  table_list = options[:tables] || :all

  Models::Ttx::TtFont.new.tap do |ttx|
    ttx.sfnt_version = format_sfnt_version(@font.header.sfnt_version.to_i)
    ttx.ttlib_version = "4.0"
    ttx.glyph_order = build_glyph_order

    # Transform specific tables
    tables_to_transform = select_tables(table_list)
    tables_to_transform.each do |tag|
      transform_table(ttx, tag)
    end
  end
end