class Fontist::SystemFont
TODO: This is actually a SystemIndex font entry
Public Class Methods
Source
# File lib/fontist/system_font.rb, line 33 def self.expand_paths(paths) paths.map do |path| require "etc" passwd = Etc.getpwuid username = passwd ? passwd.name : Etc.getlogin username ? path.gsub("{username}", username) : path end end
Source
# File lib/fontist/system_font.rb, line 47 def self.find(font) styles = find_styles(font) return unless styles styles.map(&:path) end
Source
# File lib/fontist/system_font.rb, line 55 def self.find_styles(font, style = nil) SystemIndex.system_index.find(font, style) end
This returns a SystemIndexEntry
Source
# File lib/fontist/system_font.rb, line 6 def self.font_paths system_font_paths + fontist_font_paths end
Source
# File lib/fontist/system_font.rb, line 43 def self.fontist_font_paths Dir.glob(Fontist.fonts_path.join("**")) end
Source
# 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 = expand_paths(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
This detects all fonts on the system from the configuration file.
Source
# File lib/fontist/system_font.rb, line 29 def self.reset_system_font_paths_cache @system_font_paths = nil end
Source
# File lib/fontist/system_font.rb, line 25 def self.system_config YAML.load_file(Fontist.system_file_path) end
Source
# File lib/fontist/system_font.rb, line 10 def self.system_font_paths @system_font_paths ||= load_system_font_paths end