Class: Arrolio::FontScanner
- Inherits:
-
Object
- Object
- Arrolio::FontScanner
- Defined in:
- lib/arrolio/font_scanner.rb
Overview
Scans font directories for TTF files and builds an index of family-name → file-path mappings using Fontisan to read each font's internal name tables. Used by ConfigDrivenPipeline to resolve font family names referenced by layout styles to actual TTF files on disk.
Constant Summary collapse
- FONT_DIRECTORIES =
[ File.('~/.fontist/fonts'), '/Library/Fonts', '/System/Library/Fonts', File.('~/Library/Fonts') ].freeze
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
Instance Method Summary collapse
- #build_index ⇒ Object
-
#initialize(directories = FONT_DIRECTORIES) ⇒ FontScanner
constructor
A new instance of FontScanner.
- #resolve(font_name) ⇒ Object
Constructor Details
#initialize(directories = FONT_DIRECTORIES) ⇒ FontScanner
Returns a new instance of FontScanner.
21 22 23 24 |
# File 'lib/arrolio/font_scanner.rb', line 21 def initialize(directories = FONT_DIRECTORIES) @directories = directories @index = nil end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
19 20 21 |
# File 'lib/arrolio/font_scanner.rb', line 19 def index @index end |
Instance Method Details
#build_index ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/arrolio/font_scanner.rb', line 31 def build_index @index = {} @directories.each do |dir| scan_directory(dir) end @index end |
#resolve(font_name) ⇒ Object
26 27 28 29 |
# File 'lib/arrolio/font_scanner.rb', line 26 def resolve(font_name) build_index unless @index @index[font_name.to_s] end |