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
handles table transformations that improve compression in WOFF2.
The WOFF2 spec defines transformations for glyf/loca and hmtx tables.
Transformations implemented:
- glyf/loca: Combined stream format with specialized encoding
- hmtx: Delta encoding with 255UInt16 compression
Reference: https://www.w3.org/TR/WOFF2/#table_tranforms
Constant Summary collapse
- TRANSFORM_DISPATCH =
Transform a table for WOFF2 encoding
Per-tag transform method dispatch.
{ "glyf" => :transform_glyf, "loca" => :transform_loca, "hmtx" => :transform_hmtx, }.freeze
- TRANSFORM_VERSIONS =
Per-tag transform version constant.
{ "glyf" => Directory::TRANSFORM_GLYF_LOCA, "loca" => Directory::TRANSFORM_GLYF_LOCA, "hmtx" => Directory::TRANSFORM_HMTX, }.freeze
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) ⇒ Object
- #transformable?(tag) ⇒ Boolean
- #transformation_version(tag) ⇒ Object
Constructor Details
#initialize(font) ⇒ TableTransformer
Initialize transformer with font
27 28 29 |
# File 'lib/fontisan/woff2/table_transformer.rb', line 27 def initialize(font) @font = font end |
Instance Attribute Details
#font ⇒ Object (readonly)
Returns Font object with table access.
22 23 24 |
# File 'lib/fontisan/woff2/table_transformer.rb', line 22 def font @font end |
Instance Method Details
#transform_table(tag) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/fontisan/woff2/table_transformer.rb', line 49 def transform_table(tag) transform_method = TRANSFORM_DISPATCH[tag] return method(transform_method).call if transform_method # No transformation, return original data get_table_data(tag) end |
#transformable?(tag) ⇒ Boolean
57 58 59 |
# File 'lib/fontisan/woff2/table_transformer.rb', line 57 def transformable?(tag) TRANSFORM_DISPATCH.key?(tag) end |
#transformation_version(tag) ⇒ Object
61 62 63 |
# File 'lib/fontisan/woff2/table_transformer.rb', line 61 def transformation_version(tag) TRANSFORM_VERSIONS.fetch(tag, Directory::TRANSFORM_NONE) end |