Class: Ucode::Audit::Emitter::GlyphEmitter
- Inherits:
-
Object
- Object
- Ucode::Audit::Emitter::GlyphEmitter
- Includes:
- Repo::AtomicWrites
- Defined in:
- lib/ucode/audit/emitter/glyph_emitter.rb
Overview
Writes <face_dir>/glyphs/U+XXXX.svg — the SVG outline of one
audited glyph, emitted only in --with-glyphs mode.
Glyph production is delegated to a caller-injected
glyph_resolver proc. The proc takes a codepoint Integer and
returns either an SVG string (write it) or nil (skip — no glyph
available). ucode 0.2 ships with a default proc that always
returns nil; the canonical 4-tier resolver (TODO 20) replaces it
with the real fontist/fontisan + Last-Resort pipeline.
Lazy by design: the resolver is invoked once per codepoint, and only for codepoints the caller actually iterates. No upfront font-load cost.
Constant Summary collapse
- DEFAULT_RESOLVER =
proc { |_codepoint| }
Instance Method Summary collapse
-
#emit(face_dir, codepoint) ⇒ Boolean
True if written, false if skipped (no glyph available, or content-identical to existing file).
-
#initialize(glyph_resolver: DEFAULT_RESOLVER) ⇒ GlyphEmitter
constructor
A new instance of GlyphEmitter.
Methods included from Repo::AtomicWrites
#same_content?, #to_pretty_json, #write_atomic
Constructor Details
#initialize(glyph_resolver: DEFAULT_RESOLVER) ⇒ GlyphEmitter
Returns a new instance of GlyphEmitter.
30 31 32 |
# File 'lib/ucode/audit/emitter/glyph_emitter.rb', line 30 def initialize(glyph_resolver: DEFAULT_RESOLVER) @glyph_resolver = glyph_resolver end |
Instance Method Details
#emit(face_dir, codepoint) ⇒ Boolean
Returns true if written, false if skipped (no glyph available, or content-identical to existing file).
38 39 40 41 42 43 44 |
# File 'lib/ucode/audit/emitter/glyph_emitter.rb', line 38 def emit(face_dir, codepoint) svg = @glyph_resolver.call(codepoint) return false if svg.nil? path = Paths.glyph_under(face_dir, format("U+%04X", codepoint)) write_atomic(path, svg) end |