Class: Fontisan::Variation::InstanceFontWrapper
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Fontisan::Variation::InstanceFontWrapper
- Defined in:
- lib/fontisan/variation/instance_font_wrapper.rb
Overview
Wraps a variable font to substitute specific table tags with instance-generated equivalents while forwarding everything else to the original font. Used by VariableSvgGenerator to feed the SVG generator an instance-shaped font without rewriting it.
Delegation uses SimpleDelegator so the wrapper is transparent: the original font's interface is preserved verbatim. Only #has_table? is overridden to also report instance-supplied tags.
NOTE: #table currently delegates to the original font for any tag not in the instance map. The previous implementation always delegated regardless of @table_data contents, which SvgGenerator depended on (it expects parsed BinData records, not raw bytes). Until SvgGenerator can consume raw instance bytes, this wrapper preserves that behavior. The @table_data map is still exposed so downstream code that wants the raw bytes can read them.
Instance Attribute Summary collapse
-
#table_data ⇒ Hash<String, String>
readonly
Instance-generated table bytes by tag.
Instance Method Summary collapse
- #has_table?(tag) ⇒ Boolean
-
#initialize(original_font, instance_tables) ⇒ InstanceFontWrapper
constructor
A new instance of InstanceFontWrapper.
Constructor Details
#initialize(original_font, instance_tables) ⇒ InstanceFontWrapper
Returns a new instance of InstanceFontWrapper.
29 30 31 32 |
# File 'lib/fontisan/variation/instance_font_wrapper.rb', line 29 def initialize(original_font, instance_tables) super(original_font) @table_data = instance_tables end |
Instance Attribute Details
#table_data ⇒ Hash<String, String> (readonly)
Returns instance-generated table bytes by tag.
25 26 27 |
# File 'lib/fontisan/variation/instance_font_wrapper.rb', line 25 def table_data @table_data end |
Instance Method Details
#has_table?(tag) ⇒ Boolean
36 37 38 |
# File 'lib/fontisan/variation/instance_font_wrapper.rb', line 36 def has_table?(tag) @table_data.key?(tag) || __getobj__.has_table?(tag) end |