Class: Fontist::CollectionFile
- Inherits:
-
Object
- Object
- Fontist::CollectionFile
- Includes:
- Enumerable
- Defined in:
- lib/fontist/collection_file.rb
Defined Under Namespace
Classes: FontFileMetadata
Class Method Summary collapse
Instance Method Summary collapse
-
#[](index) ⇒ Object
Return font metadata for a font in the collection.
- #count ⇒ Object
- #each ⇒ Object
-
#initialize(fontisan_collection, path) ⇒ CollectionFile
constructor
A new instance of CollectionFile.
Constructor Details
#initialize(fontisan_collection, path) ⇒ CollectionFile
Returns a new instance of CollectionFile.
84 85 86 87 |
# File 'lib/fontist/collection_file.rb', line 84 def initialize(fontisan_collection, path) @collection = fontisan_collection @path = path end |
Class Method Details
.from_path(path) {|new(collection, path)| ... } ⇒ Object
9 10 11 12 13 |
# File 'lib/fontist/collection_file.rb', line 9 def from_path(path) collection = build_collection(path) yield new(collection, path) end |
Instance Method Details
#[](index) ⇒ Object
Return font metadata for a font in the collection. This uses Fontisan directly to extract metadata without creating tempfiles, which avoids Windows file locking issues.
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/fontist/collection_file.rb', line 104 def [](index) # Load the font directly from the collection using Fontisan's FontLoader # mode: :metadata gives us just the metadata tables (faster, less memory) # lazy: false means we load the tables immediately (not deferred) font = Fontisan::FontLoader.load(@path, font_index: index, mode: :metadata, lazy: false) # Extract font metadata directly from Fontisan's font object # This avoids creating tempfiles and loading the font twice font_info = (font) # Create a FontFile-like object to hold the metadata # We use a simple struct with accessor methods for compatibility FontFileMetadata.new(font_info) end |
#count ⇒ Object
89 90 91 |
# File 'lib/fontist/collection_file.rb', line 89 def count @collection.num_fonts end |
#each ⇒ Object
93 94 95 96 97 98 99 |
# File 'lib/fontist/collection_file.rb', line 93 def each count.times do |index| yield self[index] end self end |