Class: Fontist::SystemFont
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Fontist::SystemFont
- Defined in:
- lib/fontist/system_font.rb
Overview
TODO: This is actually a SystemIndex font entry
Class Method Summary collapse
- .expand_paths(paths) ⇒ Object
- .find(font) ⇒ Object
-
.find_styles(font, style = nil) ⇒ Object
This returns a SystemIndexEntry.
- .font_paths ⇒ Object
- .fontist_font_paths ⇒ Object
-
.load_system_font_paths ⇒ Object
This detects all fonts on the system from the configuration file.
- .reset_system_font_paths_cache ⇒ Object
- .system_config ⇒ Object
- .system_font_paths ⇒ Object
Class Method Details
.expand_paths(paths) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/fontist/system_font.rb', line 33 def self.(paths) paths.map do |path| require "etc" passwd = Etc.getpwuid username = passwd ? passwd.name : Etc.getlogin username ? path.gsub("{username}", username) : path end end |
.find(font) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/fontist/system_font.rb', line 47 def self.find(font) styles = find_styles(font) return unless styles styles.map(&:path) end |
.find_styles(font, style = nil) ⇒ Object
This returns a SystemIndexEntry
55 56 57 |
# File 'lib/fontist/system_font.rb', line 55 def self.find_styles(font, style = nil) SystemIndex.system_index.find(font, style) end |
.font_paths ⇒ Object
6 7 8 |
# File 'lib/fontist/system_font.rb', line 6 def self.font_paths system_font_paths + fontist_font_paths end |
.fontist_font_paths ⇒ Object
43 44 45 |
# File 'lib/fontist/system_font.rb', line 43 def self.fontist_font_paths Dir.glob(Fontist.fonts_path.join("**")) end |
.load_system_font_paths ⇒ Object
This detects all fonts on the system from the configuration file.
15 16 17 18 19 20 21 22 23 |
# File 'lib/fontist/system_font.rb', line 15 def self.load_system_font_paths os = Fontist::Utils::System.user_os.to_s templates = system_config["system"][os]["paths"] patterns = (templates) Dir.glob(patterns) # File::FNM_CASEFOLD is officially ignored -- see https://ruby-doc.org/core-3.1.1/Dir.html#method-c-glob # "Case sensitivity depends on your system" end |
.reset_system_font_paths_cache ⇒ Object
29 30 31 |
# File 'lib/fontist/system_font.rb', line 29 def self.reset_system_font_paths_cache @system_font_paths = nil end |
.system_config ⇒ Object
25 26 27 |
# File 'lib/fontist/system_font.rb', line 25 def self.system_config YAML.load_file(Fontist.system_file_path) end |
.system_font_paths ⇒ Object
10 11 12 |
# File 'lib/fontist/system_font.rb', line 10 def self.system_font_paths @system_font_paths ||= load_system_font_paths end |