Class: Ucode::Glyphs::EmbeddedFonts::Renderer
- Inherits:
-
Object
- Object
- Ucode::Glyphs::EmbeddedFonts::Renderer
- Defined in:
- lib/ucode/glyphs/embedded_fonts/renderer.rb
Overview
Renders one codepoint’s glyph by chaining the Catalog index lookup → FontEntry accessor → Svg wrapper.
Mirrors LastResort::Renderer: a Result struct is returned on success, nil on miss. The caller (Writer or CLI) decides how to handle misses — typically by falling back to the LastResort renderer.
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
-
#initialize(catalog) ⇒ Renderer
constructor
A new instance of Renderer.
-
#render(codepoint) ⇒ Result?
Nil when no font in the PDF covers this codepoint, or when the GID’s outline is empty.
Constructor Details
#initialize(catalog) ⇒ Renderer
Returns a new instance of Renderer.
24 25 26 |
# File 'lib/ucode/glyphs/embedded_fonts/renderer.rb', line 24 def initialize(catalog) @catalog = catalog end |
Instance Method Details
#render(codepoint) ⇒ Result?
Returns nil when no font in the PDF covers this codepoint, or when the GID’s outline is empty.
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ucode/glyphs/embedded_fonts/renderer.rb', line 31 def render(codepoint) entry = @catalog.lookup(codepoint) return nil unless entry gid = entry.gid_for(codepoint) return nil unless gid outline = entry.accessor.outline_for_id(gid) return nil if outline.nil? || outline.empty? svg = Svg.new(outline, codepoint: codepoint, base_font: entry.base_font).to_s Result.new(codepoint: codepoint, base_font: entry.base_font, gid: gid, svg: svg) end |