Module: Fontisan::Stitcher::GlyphCloner
- Defined in:
- lib/fontisan/stitcher/glyph_cloner.rb
Overview
Deep-clone helper for UFO glyphs. Stateless — every call returns
a fresh Ufo::Glyph with copied contours, components, anchors,
and guidelines plus the original's width/height.
Extracted as a collaborator so GlyphCopier and CbdtPropagator
share one implementation of the clone algorithm. Both previously
defined identical clone_glyph / clone_contour private methods
— a DRY violation that risked drifting apart as the glyph model
gained fields.
Class Method Summary collapse
-
.clone(original, name: nil) ⇒ Ufo::Glyph
A fresh glyph with the original's geometry and metrics, sharing no mutable state with it.
Class Method Details
.clone(original, name: nil) ⇒ Ufo::Glyph
Returns a fresh glyph with the original's geometry and metrics, sharing no mutable state with it.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/fontisan/stitcher/glyph_cloner.rb', line 21 def self.clone(original, name: nil) copy = Ufo::Glyph.new(name: name || original.name) copy.width = original.width copy.height = original.height original.contours.each { |c| copy.add_contour(clone_contour(c)) } original.components.each { |c| copy.add_component(c) } original.anchors.each { |a| copy.add_anchor(a) } original.guidelines.each { |g| copy.add_guideline(g) } copy end |