Class: Ucode::Glyphs::LastResort::Source
- Inherits:
-
Object
- Object
- Ucode::Glyphs::LastResort::Source
- Defined in:
- lib/ucode/glyphs/last_resort/source.rb
Overview
Locates the Last Resort Font UFO source on disk.
Resolution order (first match wins):
1. Explicit `root:` argument.
2. `UCODE_LAST_RESORT_FONT_ROOT` environment variable.
3. `Ucode::Config#last_resort_font_root` (if configured).
4. Conventional sibling-of-repo path `../../external/unicode/
last-resort-font` relative to the gem root.
The UFO must contain:
* `cmap-f13.ttx` — Format 13 cmap (cp → glyph name).
* `font.ufo/glyphs/contents.plist` — glyph name → .glif file.
* `font.ufo/glyphs/*.glif` — outline files.
If any required artifact is missing, the constructor raises LastResortMissingError with a ‘context:` payload listing the resolved root and which artifact is absent. The CLI catches this to print a friendly “see README for setup” message.
Instance Attribute Summary collapse
-
#cmap_path ⇒ Object
readonly
Returns the value of attribute cmap_path.
-
#contents_path ⇒ Object
readonly
Returns the value of attribute contents_path.
-
#glyphs_dir ⇒ Object
readonly
Returns the value of attribute glyphs_dir.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
-
#available? ⇒ Boolean
True if all required artifacts are present.
-
#glif_path(basename) ⇒ Pathname
Path to a specific ‘.glif` file by basename.
-
#initialize(root: nil, env: ENV, gem_root: nil) ⇒ Source
constructor
A new instance of Source.
Constructor Details
Instance Attribute Details
#cmap_path ⇒ Object (readonly)
Returns the value of attribute cmap_path.
31 32 33 |
# File 'lib/ucode/glyphs/last_resort/source.rb', line 31 def cmap_path @cmap_path end |
#contents_path ⇒ Object (readonly)
Returns the value of attribute contents_path.
31 32 33 |
# File 'lib/ucode/glyphs/last_resort/source.rb', line 31 def contents_path @contents_path end |
#glyphs_dir ⇒ Object (readonly)
Returns the value of attribute glyphs_dir.
31 32 33 |
# File 'lib/ucode/glyphs/last_resort/source.rb', line 31 def glyphs_dir @glyphs_dir end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
31 32 33 |
# File 'lib/ucode/glyphs/last_resort/source.rb', line 31 def root @root end |
Instance Method Details
#available? ⇒ Boolean
Returns true if all required artifacts are present.
56 57 58 59 60 61 62 |
# File 'lib/ucode/glyphs/last_resort/source.rb', line 56 def available? [ @cmap_path, @glyphs_dir, @contents_path, ].all?(&:exist?) end |
#glif_path(basename) ⇒ Pathname
Path to a specific ‘.glif` file by basename. Does NOT verify the file exists; callers resolve via Contents first.
69 70 71 |
# File 'lib/ucode/glyphs/last_resort/source.rb', line 69 def glif_path(basename) @glyphs_dir.join(basename) end |