class Fontist::SystemFont
Attributes
font[R]
style[R]
Public Class Methods
expand_paths(paths)
click to toggle source
# File lib/fontist/system_font.rb, line 23 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
find(font)
click to toggle source
# File lib/fontist/system_font.rb, line 37 def self.find(font) new(font: font).find end
find_styles(font, style)
click to toggle source
# File lib/fontist/system_font.rb, line 41 def self.find_styles(font, style) new(font: font, style: style).find_styles end
font_paths()
click to toggle source
# File lib/fontist/system_font.rb, line 10 def self.font_paths system_font_paths + fontist_font_paths end
fontist_font_paths()
click to toggle source
# File lib/fontist/system_font.rb, line 33 def self.fontist_font_paths Dir.glob(Fontist.fonts_path.join("**")) end
new(font:, style: nil)
click to toggle source
# File lib/fontist/system_font.rb, line 5 def initialize(font:, style: nil) @font = font @style = style end
system_font_paths()
click to toggle source
# File lib/fontist/system_font.rb, line 14 def self.system_font_paths config_path = Fontist.system_file_path os = Fontist::Utils::System.user_os.to_s templates = YAML.load_file(config_path)["system"][os]["paths"] patterns = expand_paths(templates) Dir.glob(patterns) end
Public Instance Methods
find()
click to toggle source
# File lib/fontist/system_font.rb, line 45 def find styles = find_styles return unless styles styles.map { |x| x[:path] } end
find_styles()
click to toggle source
# File lib/fontist/system_font.rb, line 52 def find_styles find_by_index end
Private Instance Methods
find_by_index()
click to toggle source
# File lib/fontist/system_font.rb, line 60 def find_by_index SystemIndex.system_index.find(font, style) end