Class: Fontisan::Woff2::TableTransformer
- Inherits:
-
Object
- Object
- Fontisan::Woff2::TableTransformer
- Defined in:
- lib/fontisan/woff2/table_transformer.rb
Overview
Table transformer for WOFF2 encoding
[‘Woff2::TableTransformer`](lib/fontisan/woff2/table_transformer.rb) handles table transformations that improve compression in WOFF2. The WOFF2 spec defines transformations for glyf/loca and hmtx tables.
For Phase 2 Milestone 2.1:
-
Architecture is in place for transformations
-
Actual transformation implementations are marked as TODO
-
Tables are copied as-is without transformation
-
This allows valid WOFF2 generation while leaving room for optimization
Future milestones will implement:
-
glyf/loca transformation (combined stream, delta encoding)
-
hmtx transformation (compact representation)
Reference: www.w3.org/TR/WOFF2/#table_tranforms
Instance Attribute Summary collapse
-
#font ⇒ Object
readonly
Font object with table access.
Instance Method Summary collapse
-
#initialize(font) ⇒ TableTransformer
constructor
Initialize transformer with font.
-
#transform_table(tag) ⇒ String?
Transform a table for WOFF2 encoding.
-
#transformable?(tag) ⇒ Boolean
Check if a table can be transformed.
-
#transformation_version(_tag) ⇒ Integer
Determine transformation version for a table.
Constructor Details
#initialize(font) ⇒ TableTransformer
Initialize transformer with font
33 34 35 |
# File 'lib/fontisan/woff2/table_transformer.rb', line 33 def initialize(font) @font = font end |
Instance Attribute Details
#font ⇒ Object (readonly)
Returns Font object with table access.
28 29 30 |
# File 'lib/fontisan/woff2/table_transformer.rb', line 28 def font @font end |
Instance Method Details
#transform_table(tag) ⇒ String?
Transform a table for WOFF2 encoding
For Milestone 2.1, this returns the original table data without transformation. The architecture supports future implementation of actual transformations.
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/fontisan/woff2/table_transformer.rb', line 45 def transform_table(tag) case tag when "glyf" transform_glyf when "loca" transform_loca when "hmtx" transform_hmtx else # No transformation, return original data get_table_data(tag) end end |
#transformable?(tag) ⇒ Boolean
Check if a table can be transformed
63 64 65 |
# File 'lib/fontisan/woff2/table_transformer.rb', line 63 def transformable?(tag) %w[glyf loca hmtx].include?(tag) end |
#transformation_version(_tag) ⇒ Integer
Determine transformation version for a table
For Milestone 2.1, always returns TRANSFORM_NONE since we don’t implement transformations yet.
74 75 76 77 |
# File 'lib/fontisan/woff2/table_transformer.rb', line 74 def transformation_version(_tag) # For this milestone, no transformations are applied Directory::TRANSFORM_NONE end |