Sha256: 995a305bdb27de1abcf192a3090c6a93161257af1626d20758499c91f67cbd35
Contents?: true
Size: 1.97 KB
Versions: 2
Compression:
Stored size: 1.97 KB
Contents
require_relative "../otfinfo/otfinfo_requirement" require_relative "../text_helper" module Fontist module Import module Otf class FontFile REQUIREMENTS = { otfinfo: Otfinfo::OtfinfoRequirement.new, }.freeze STYLE_ATTRIBUTES = %i[family_name type full_name post_script_name version description copyright font].freeze COLLECTION_ATTRIBUTES = STYLE_ATTRIBUTES.reject { |a| a == :font } attr_reader :path def initialize(path) @path = path @info = read end def to_style STYLE_ATTRIBUTES.map { |name| [name, send(name)] }.to_h.compact end def to_collection_style COLLECTION_ATTRIBUTES.map { |name| [name, send(name)] }.to_h.compact end def family_name info["Preferred family"] || info["Family"] end def type info["Preferred subfamily"] || info["Subfamily"] end def full_name info["Full name"] end def post_script_name info["PostScript name"] end def version return unless info["Version"] info["Version"].gsub("Version ", "") end def description info["Description"] end def font File.basename(@path) end def copyright info["Copyright"] end def homepage info["Vendor URL"] end def license_url info["License URL"] end private attr_reader :info def read text = REQUIREMENTS[:otfinfo].call(@path) text .encode("UTF-8", invalid: :replace, replace: "") .split("\n") .select { |x| x.include?(":") } .map { |x| x.split(":", 2) } .map { |x| x.map { |y| Fontist::Import::TextHelper.cleanup(y) } } .to_h end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fontist-1.6.0 | lib/fontist/import/otf/font_file.rb |
fontist-1.5.1 | lib/fontist/import/otf/font_file.rb |