lib/compass/fontcustom/glyph_map.rb in compass-fontcustom-1.0.0 vs lib/compass/fontcustom/glyph_map.rb in compass-fontcustom-1.1.0
- old
+ new
@@ -1,6 +1,6 @@
-require 'fontcustom/generator/font'
+require 'fontcustom'
require 'compass/fontcustom/configurable'
module Compass
module Fontcustom
class GlyphMap < Sass::Script::Literal
@@ -9,14 +9,23 @@
attr_reader :name, :path
# @param context [Object] usually an instance of FontImporter
def self.from_uri(uri, context)
path, name = FontImporter.path_and_name uri
- glyphs = FontImporter.files(uri).sort.map { |file| File.basename(file)[0..-5] }
+ glyphs = FontImporter.files(uri).sort
+
+ # TODO: improve extraction of aboslute path
+ path = File.dirname glyphs.first
+ glyphs.map! { |file| File.basename(file)[0..-5].gsub(/[^0-9A-Za-z]/, '') }
+
new glyphs, path, name, context
end
+ # @param glyphs [Array] all the glyphs found at path
+ # @param path [String] the absolute path where glyphs are stored
+ # @param name [String] the name of the glyph font
+ # @param context [Object] the invoking object
def initialize(glyphs, path, name, context)
raise StandardError, "No glyphs found at '#{path}'" if glyphs.empty?
@glyphs = glyphs
@path = path
@name = name
@@ -30,16 +39,16 @@
# Starts the Fontcustom font generator to write font files to disk.
def generate
unless exists?
args = self.class.config.generator_options || {}
args.merge!(
- :input => File.join(Compass.configuration.images_path.to_s, self.path),
+ :input => path,
:output => output_dir,
:font_name => @name,
- :file_hash => Compass.configuration.fontcustom_hash,
- :verbose => false
+ :no_hash => !Compass.configuration.fontcustom_hash,
+ :quiet => true
)
- ::Fontcustom::Generator::Font.start [args]
+ ::Fontcustom::Generator::Font.start [::Fontcustom::Options.new(args)]
end
end
def filename
file = glob.first