Sha256: da615a551f754ac3e8130fc7bb80ad5d56db6adb8a3e2b584e7b9c16cbb5a707
Contents?: true
Size: 1.26 KB
Versions: 22
Compression:
Stored size: 1.26 KB
Contents
require_relative "file_requirement" module Fontist module Import module Files class FontDetector REQUIREMENTS = { file: FileRequirement.new }.freeze FONT_LABELS = ["OpenType font data", "TrueType Font data"].freeze COLLECTION_LABELS = ["OpenType font collection data", "TrueType font collection data"].freeze FONT_EXTENSIONS = { "OpenType font data" => "otf", "TrueType Font data" => "ttf", "OpenType font collection data" => "ttc", "TrueType font collection data" => "ttc", }.freeze def self.detect(path) brief = file_brief(path) if brief.start_with?(*FONT_LABELS) :font elsif brief.start_with?(*COLLECTION_LABELS) :collection else :other end end def self.standard_extension(path) brief = file_brief(path) FONT_EXTENSIONS.each do |label, extension| return extension if brief.start_with?(label) end raise Errors::UnknownFontTypeError.new(path) end def self.file_brief(path) REQUIREMENTS[:file].call(path) end end end end end
Version data entries
22 entries across 22 versions & 1 rubygems
Version | Path |
---|---|
fontist-1.13.0 | lib/fontist/import/files/font_detector.rb |
fontist-1.12.0 | lib/fontist/import/files/font_detector.rb |