Module: Fontisan::Ufo::Compile::Filters::Transformations

Defined in:
lib/fontisan/ufo/compile/filters/transformations.rb

Overview

Applies a 2×3 affine transformation to every glyph's contours + components. The general-purpose filter — other filters (decompose_components, propagate_anchors) are special cases of geometric transforms applied to specific glyph subsets.

Used for:

- Symmetric mirroring (e.g. italic→upright flip).
- Slant adjustment.
- Custom per-font offsets that callers want baked in at
compile time rather than carried as variation axis deltas.

Identity matrix is a no-op fast path.

Constant Summary collapse

DEFAULT_OFFSET_X =
0.0
DEFAULT_OFFSET_Y =
0.0

Class Method Summary collapse

Class Method Details

.run(glyphs, matrix: nil, **_opts) ⇒ Array<Fontisan::Ufo::Glyph>

Returns the same array (mutated).

Parameters:

  • glyphs (Array<Fontisan::Ufo::Glyph>)
  • matrix (Fontisan::Ufo::Transformation, Array<Numeric>, nil) (defaults to: nil)

    The affine matrix to apply. Accepts either a Transformation value object or the raw [a, b, c, d, e, f] array. nil (the default) is a no-op — leaves glyphs unchanged.

Returns:



31
32
33
34
35
36
37
38
39
# File 'lib/fontisan/ufo/compile/filters/transformations.rb', line 31

def self.run(glyphs, matrix: nil, **_opts)
  return glyphs if matrix.nil?

  transform = coerce_transformation(matrix)
  return glyphs if transform.identity?

  glyphs.each { |g| apply_to_glyph(g, transform) }
  glyphs
end