Class: Ucode::Models::GlyphSource
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Ucode::Models::GlyphSource
- Defined in:
- lib/ucode/models/glyph_source.rb
Overview
One Tier 1 font entry inside a GlyphSourceMap. Corresponds to
one - kind: … item under a block's sources: list in
config/unicode17_universal_glyph_set.yml.
This is the typed representation of a font curation choice. The Glyphs::Sources::Tier1RealFont source consumes it to resolve and load the font; the resolver treats each entry as an independent tier-1 attempt.
Wire shape (YAML / JSON identical):
kind: fontist # one of: fontist, path, system
label: noto-sans # human + provenance key
priority: 1 # lower wins; resolver tries in order
license: OFL # optional; OFL / PROPRIETARY / etc.
provenance: "Google Noto Sans" # optional citation
path: "/abs/font.ttf" # required when kind == :path
kind is stored as a plain string on the wire (lutaml-model has
no Symbol adapter for key_value); the #kind_sym reader casts it
for internal dispatch.
Instance Method Summary collapse
-
#kind_sym ⇒ Symbol
:fontist, :path, :system; raises if kind is blank — every entry must declare its kind.
-
#requires_path? ⇒ Boolean
True when this entry requires a
pathfield (kind == :path). -
#to_font_spec ⇒ String
Renders this source as the legacy font-spec string consumed by Glyphs::RealFonts::FontLocator:
label=/path/to/fontfor kind=path, orlabel(the fontist formula name) for kind=fontist.
Instance Method Details
#kind_sym ⇒ Symbol
Returns :fontist, :path, :system; raises if kind is blank — every entry must declare its kind.
53 54 55 56 57 |
# File 'lib/ucode/models/glyph_source.rb', line 53 def kind_sym raise ArgumentError, "GlyphSource#kind is required" if kind.nil? || kind.empty? kind.to_sym end |
#requires_path? ⇒ Boolean
Returns true when this entry requires a path field
(kind == :path). Used by the loader to validate structure.
61 62 63 |
# File 'lib/ucode/models/glyph_source.rb', line 61 def requires_path? kind_sym == :path end |
#to_font_spec ⇒ String
Renders this source as the legacy font-spec string consumed by
Glyphs::RealFonts::FontLocator: label=/path/to/font
for kind=path, or label (the fontist formula name) for
kind=fontist. The locator's locate understands both shapes.
This is the one adapter method that lets the typed model integrate with the existing locator without rewriting it.
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/ucode/models/glyph_source.rb', line 74 def to_font_spec case kind_sym when :path raise ArgumentError, "GlyphSource#{label} has kind=path but no path" if path.nil? || path.empty? "#{label}=#{path}" when :fontist, :system label end end |