Class: Fontisan::Pipeline::Strategies::PreserveStrategy

Inherits:
BaseStrategy
  • Object
show all
Defined in:
lib/fontisan/pipeline/strategies/preserve_strategy.rb

Overview

Strategy for preserving variation data during conversion

This strategy maintains all variation tables intact, making it suitable for conversions between compatible formats:

  • Variable TTF → Variable TTF (same format)
  • Variable OTF → Variable OTF (same format)
  • Variable TTF → Variable WOFF/WOFF2 (packaging change only)
  • Variable OTF → Variable WOFF/WOFF2 (packaging change only)

The strategy copies all font tables including:

  • Variation tables: fvar, gvar/CFF2, avar, HVAR, VVAR, MVAR
  • Base tables: All non-variation tables

Examples:

Preserve variation data

strategy = PreserveStrategy.new
tables = strategy.resolve(variable_font)
# tables includes fvar, gvar, etc.

Instance Attribute Summary

Attributes inherited from BaseStrategy

#options

Instance Method Summary collapse

Methods inherited from BaseStrategy

#initialize

Constructor Details

This class inherits a constructor from Fontisan::Pipeline::Strategies::BaseStrategy

Instance Method Details

#preserves_variation?Boolean

Check if strategy preserves variation data

Returns:

  • (Boolean)

    Always true for this strategy



41
42
43
# File 'lib/fontisan/pipeline/strategies/preserve_strategy.rb', line 41

def preserves_variation?
  true
end

#resolve(font) ⇒ Hash<String, String>

Resolve by preserving all variation data

Returns all font tables including variation tables. This is a simple copy operation that maintains the variable font's full capabilities.

Parameters:

Returns:

  • (Hash<String, String>)

    All font tables



31
32
33
34
35
36
# File 'lib/fontisan/pipeline/strategies/preserve_strategy.rb', line 31

def resolve(font)
  # Return a copy of all font tables
  # This preserves variation tables (fvar, gvar, CFF2, avar, HVAR, etc.)
  # and all base tables
  font.table_data.dup
end

#strategy_nameSymbol

Get strategy name

Returns:

  • (Symbol)

    :preserve



48
49
50
# File 'lib/fontisan/pipeline/strategies/preserve_strategy.rb', line 48

def strategy_name
  :preserve
end