class Fontist::Import::Otf::FontFile

Constants

COLLECTION_ATTRIBUTES
REQUIREMENTS
STYLE_ATTRIBUTES

Attributes

path[R]

Public Class Methods

new(path) click to toggle source
# File lib/fontist/import/otf/font_file.rb, line 24
def initialize(path)
  @path = path
  @info = read
  @extension = detect_extension
end

Public Instance Methods

description() click to toggle source
# File lib/fontist/import/otf/font_file.rb, line 68
def description
  info["Description"]
end
family_name() click to toggle source
# File lib/fontist/import/otf/font_file.rb, line 38
def family_name
  info["Family"]
end
font() click to toggle source
# File lib/fontist/import/otf/font_file.rb, line 72
def font
  basename = File.basename(@path, ".*").chomp(".#{@extension}")

  "#{basename}.#{@extension}"
end
full_name() click to toggle source
# File lib/fontist/import/otf/font_file.rb, line 54
def full_name
  info["Full name"]
end
homepage() click to toggle source
# File lib/fontist/import/otf/font_file.rb, line 86
def homepage
  info["Vendor URL"]
end
license_url() click to toggle source
# File lib/fontist/import/otf/font_file.rb, line 90
def license_url
  info["License URL"]
end
post_script_name() click to toggle source
# File lib/fontist/import/otf/font_file.rb, line 58
def post_script_name
  info["PostScript name"]
end
preferred_family_name() click to toggle source
# File lib/fontist/import/otf/font_file.rb, line 46
def preferred_family_name
  info["Preferred family"]
end
preferred_type() click to toggle source
# File lib/fontist/import/otf/font_file.rb, line 50
def preferred_type
  info["Preferred subfamily"]
end
source_font() click to toggle source
# File lib/fontist/import/otf/font_file.rb, line 78
def source_font
  File.basename(@path) unless font == File.basename(@path)
end
to_collection_style() click to toggle source
# File lib/fontist/import/otf/font_file.rb, line 34
def to_collection_style
  COLLECTION_ATTRIBUTES.map { |name| [name, send(name)] }.to_h.compact
end
to_style() click to toggle source
# File lib/fontist/import/otf/font_file.rb, line 30
def to_style
  STYLE_ATTRIBUTES.map { |name| [name, send(name)] }.to_h.compact
end
type() click to toggle source
# File lib/fontist/import/otf/font_file.rb, line 42
def type
  info["Subfamily"]
end
version() click to toggle source
# File lib/fontist/import/otf/font_file.rb, line 62
def version
  return unless info["Version"]

  info["Version"].gsub("Version ", "")
end