Class: Ucode::Glyphs::RealFonts::FontLocator

Inherits:
Object
  • Object
show all
Defined in:
lib/ucode/glyphs/real_fonts/font_locator.rb

Overview

Resolves a user-provided font specifier to a concrete file path on disk. Resolution order:

1. Direct file path — returns it if it exists. Useful for
   local checkouts (e.g. a developer's clone of Lentariso).
2. `Fontist::Font.find(name)` — returns the already-installed
   font path if fontist has it on disk.
3. `Fontist::Font.install(name)` — downloads + installs the
   font via the fontist formula index.

Fontist is the canonical discovery layer for the fontist ecosystem. We never reach into other package managers or hardcode URLs here — formulas live in fontist/formulas.

Defined Under Namespace

Classes: LocateResult

Instance Method Summary collapse

Instance Method Details

#locate(spec, install: true) ⇒ LocateResult

Parameters:

  • spec (String)

    either a file path or a fontist formula name (case-insensitive). A ‘name=path` form is also accepted so a CLI can name the font whatever the user wants without depending on the formula’s family name.

  • install (Boolean) (defaults to: true)

    if true and the font is not on disk, attempt ‘Fontist::Font.install`. Default: true.

Returns:

Raises:

  • (Errno::ENOENT)

    if path does not exist and fontist cannot resolve the name.



35
36
37
38
39
40
41
42
43
# File 'lib/ucode/glyphs/real_fonts/font_locator.rb', line 35

def locate(spec, install: true)
  name, path = split_spec(spec)
  return result(name, path, :direct) if path && File.exist?(path)

  via_fontist = find_via_fontist(name, install: install)
  return via_fontist if via_fontist

  raise Errno::ENOENT, "Font not found: #{spec}"
end