Class: Fontist::SystemIndex
- Inherits:
-
Object
- Object
- Fontist::SystemIndex
- Includes:
- Utils::Locking
- Defined in:
- lib/fontist/system_index.rb
Defined Under Namespace
Classes: DefaultFamily, PreferredFamily
Constant Summary collapse
- PLATFORM_MACINTOSH =
1- PLATFORM_MICROSOFT =
3- ENCODING_MAC_ROMAN =
0- ENCODING_MS_UNICODE_BMP =
1- LANGUAGE_MAC_ENGLISH =
0- LANGUAGE_MS_ENGLISH_AMERICAN =
0x409- ALLOWED_KEYS =
%i[path full_name family_name type].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #find(font, style) ⇒ Object
-
#initialize(index_path, font_paths_fetcher, family) ⇒ SystemIndex
constructor
A new instance of SystemIndex.
- #rebuild ⇒ Object
Methods included from Utils::Locking
Constructor Details
#initialize(index_path, font_paths_fetcher, family) ⇒ SystemIndex
Returns a new instance of SystemIndex.
81 82 83 84 85 |
# File 'lib/fontist/system_index.rb', line 81 def initialize(index_path, font_paths_fetcher, family) @index_path = index_path @font_paths_fetcher = font_paths_fetcher @family = family end |
Class Method Details
.family ⇒ Object
77 78 79 |
# File 'lib/fontist/system_index.rb', line 77 def self.family Fontist.preferred_family? ? PreferredFamily.new : DefaultFamily.new end |
.fontist_index ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/fontist/system_index.rb', line 64 def self.fontist_index path = if Fontist.preferred_family? Fontist.fontist_preferred_family_index_path else Fontist.fontist_index_path end @fontist_index ||= {} @fontist_index[Fontist.preferred_family?] ||= {} @fontist_index[Fontist.preferred_family?][path] ||= new(path, -> { SystemFont.fontist_font_paths }, family) end |
.system_index ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/fontist/system_index.rb', line 51 def self.system_index path = if Fontist.preferred_family? Fontist.system_preferred_family_index_path else Fontist.system_index_path end @system_index ||= {} @system_index[Fontist.preferred_family?] ||= {} @system_index[Fontist.preferred_family?][path] ||= new(path, -> { SystemFont.font_paths }, family) end |
Instance Method Details
#find(font, style) ⇒ Object
87 88 89 90 91 92 93 94 |
# File 'lib/fontist/system_index.rb', line 87 def find(font, style) fonts = index.select do |file| file[:family_name].casecmp?(font) && (style.nil? || file[:type].casecmp?(style)) end fonts.empty? ? nil : fonts end |
#rebuild ⇒ Object
96 97 98 |
# File 'lib/fontist/system_index.rb', line 96 def rebuild build_index end |