Class: Fontist::Import::Otf::FontFile
- Inherits:
-
Object
- Object
- Fontist::Import::Otf::FontFile
- Defined in:
- lib/fontist/import/otf/font_file.rb
Constant Summary collapse
- REQUIREMENTS =
{ otfinfo: Otfinfo::OtfinfoRequirement.new, }.freeze
- STYLE_ATTRIBUTES =
%i[family_name type preferred_family_name preferred_type full_name post_script_name version description copyright font source_font].freeze
- COLLECTION_ATTRIBUTES =
STYLE_ATTRIBUTES.reject do |a| %i[font source_font].include?(a) end
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #copyright ⇒ Object
- #description ⇒ Object
- #family_name ⇒ Object
- #font ⇒ Object
- #full_name ⇒ Object
- #homepage ⇒ Object
-
#initialize(path) ⇒ FontFile
constructor
A new instance of FontFile.
- #license_url ⇒ Object
- #post_script_name ⇒ Object
- #preferred_family_name ⇒ Object
- #preferred_type ⇒ Object
- #source_font ⇒ Object
- #to_collection_style ⇒ Object
- #to_style ⇒ Object
- #type ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(path) ⇒ FontFile
Returns a new instance of FontFile.
24 25 26 27 28 |
# File 'lib/fontist/import/otf/font_file.rb', line 24 def initialize(path) @path = path @info = read @extension = detect_extension end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
22 23 24 |
# File 'lib/fontist/import/otf/font_file.rb', line 22 def path @path end |
Instance Method Details
#copyright ⇒ Object
82 83 84 |
# File 'lib/fontist/import/otf/font_file.rb', line 82 def copyright info["Copyright"] end |
#description ⇒ Object
68 69 70 |
# File 'lib/fontist/import/otf/font_file.rb', line 68 def description info["Description"] end |
#family_name ⇒ Object
38 39 40 |
# File 'lib/fontist/import/otf/font_file.rb', line 38 def family_name info["Family"] end |
#font ⇒ Object
72 73 74 75 76 |
# File 'lib/fontist/import/otf/font_file.rb', line 72 def font basename = File.basename(@path, ".*").chomp(".#{@extension}") "#{basename}.#{@extension}" end |
#full_name ⇒ Object
54 55 56 |
# File 'lib/fontist/import/otf/font_file.rb', line 54 def full_name info["Full name"] end |
#homepage ⇒ Object
86 87 88 |
# File 'lib/fontist/import/otf/font_file.rb', line 86 def homepage info["Vendor URL"] end |
#license_url ⇒ Object
90 91 92 |
# File 'lib/fontist/import/otf/font_file.rb', line 90 def license_url info["License URL"] end |
#post_script_name ⇒ Object
58 59 60 |
# File 'lib/fontist/import/otf/font_file.rb', line 58 def post_script_name info["PostScript name"] end |
#preferred_family_name ⇒ Object
46 47 48 |
# File 'lib/fontist/import/otf/font_file.rb', line 46 def preferred_family_name info["Preferred family"] end |
#preferred_type ⇒ Object
50 51 52 |
# File 'lib/fontist/import/otf/font_file.rb', line 50 def preferred_type info["Preferred subfamily"] end |
#source_font ⇒ Object
78 79 80 |
# 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 ⇒ Object
34 35 36 |
# 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 ⇒ Object
30 31 32 |
# 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 ⇒ Object
42 43 44 |
# File 'lib/fontist/import/otf/font_file.rb', line 42 def type info["Subfamily"] end |
#version ⇒ Object
62 63 64 65 66 |
# File 'lib/fontist/import/otf/font_file.rb', line 62 def version return unless info["Version"] info["Version"].gsub("Version ", "") end |