Class: Fontist::Import::FontMetadataExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/fontist/import/font_metadata_extractor.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ FontMetadataExtractor

Returns a new instance of FontMetadataExtractor.



6
7
8
# File 'lib/fontist/import/font_metadata_extractor.rb', line 6

def initialize(path)
  @path = path
end

Instance Method Details

#extractObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fontist/import/font_metadata_extractor.rb', line 10

def extract
  # Use FontLoader directly for consistent handling of both
  # individual fonts and collections (TTC/OTC)
  # For TTC files, loads the first font (index 0) by default
  font = Fontisan::FontLoader.load(
    @path,
    font_index: 0,
    mode: Fontisan::LoadingModes::METADATA,
  )

  (font)
rescue StandardError => e
  raise Errors::FontExtractError,
        "Failed to extract metadata from #{@path}: #{e.message}"
end