class Fontist::SystemIndex

Constants

ALLOWED_KEYS

Public Class Methods

family() click to toggle source
# File lib/fontist/system_index.rb, line 65
def self.family
  Fontist.preferred_family? ? PreferredFamily.new : DefaultFamily.new
end
fontist_index() click to toggle source
# File lib/fontist/system_index.rb, line 52
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
new(index_path, font_paths_fetcher, family) click to toggle source
# File lib/fontist/system_index.rb, line 73
def initialize(index_path, font_paths_fetcher, family)
  @index_path = index_path
  @font_paths_fetcher = font_paths_fetcher
  @family = family
end
system_index() click to toggle source
# File lib/fontist/system_index.rb, line 39
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

Public Instance Methods

excluded_fonts() click to toggle source
# File lib/fontist/system_index.rb, line 69
def excluded_fonts
  @excluded_fonts ||= YAML.load_file(Fontist.excluded_fonts_path)
end
find(font, style) click to toggle source
# File lib/fontist/system_index.rb, line 79
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() click to toggle source
# File lib/fontist/system_index.rb, line 88
def rebuild
  build_index
end