Class: Compass::Fontcustom::GlyphMap
- Inherits:
-
Sass::Script::Literal
- Object
- Sass::Script::Literal
- Compass::Fontcustom::GlyphMap
- Includes:
- Configurable
- Defined in:
- lib/compass/fontcustom/glyph_map.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #exists? ⇒ Boolean
- #filename ⇒ Object
-
#generate ⇒ Object
Starts the Fontcustom font generator to write font files to disk.
- #index_for_glyph(name) ⇒ Object
-
#initialize(glyphs, path, name, context) ⇒ GlyphMap
constructor
A new instance of GlyphMap.
- #output_dir ⇒ Object
- #to_s ⇒ Object
Methods included from Configurable
Constructor Details
#initialize(glyphs, path, name, context) ⇒ GlyphMap
Returns a new instance of GlyphMap.
27 28 29 30 31 32 33 |
# File 'lib/compass/fontcustom/glyph_map.rb', line 27 def initialize(glyphs, path, name, context) raise StandardError, "No glyphs found at '#{path}'" if glyphs.empty? @glyphs = glyphs @path = path @name = name @context = context end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/compass/fontcustom/glyph_map.rb', line 9 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/compass/fontcustom/glyph_map.rb', line 9 def path @path end |
Class Method Details
.from_uri(uri, context) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/compass/fontcustom/glyph_map.rb', line 12 def self.from_uri(uri, context) path, name = FontImporter.path_and_name uri glyphs = FontImporter.files(uri).sort # TODO: improve extraction of aboslute path path = File.dirname glyphs.first glyphs.map! { |file| File.basename(file)[0..-5] } new glyphs, path, name, context end |
Instance Method Details
#exists? ⇒ Boolean
59 60 61 |
# File 'lib/compass/fontcustom/glyph_map.rb', line 59 def exists? not glob.empty? end |
#filename ⇒ Object
54 55 56 57 |
# File 'lib/compass/fontcustom/glyph_map.rb', line 54 def filename file = glob.first File.basename file, File.extname(file) end |
#generate ⇒ Object
Starts the Fontcustom font generator to write font files to disk.
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/compass/fontcustom/glyph_map.rb', line 40 def generate unless exists? args = self.class.config. || {} args.merge!( :input => path, :output => output_dir, :font_name => @name, :no_hash => !Compass.configuration.fontcustom_hash, :quiet => true ) ::Fontcustom::Generator::Font.start [::Fontcustom::Options.new(args)] end end |
#index_for_glyph(name) ⇒ Object
35 36 37 |
# File 'lib/compass/fontcustom/glyph_map.rb', line 35 def index_for_glyph(name) @glyphs.index name end |
#output_dir ⇒ Object
63 64 65 |
# File 'lib/compass/fontcustom/glyph_map.rb', line 63 def output_dir Compass.configuration.fonts_path.to_s end |
#to_s ⇒ Object
67 68 69 |
# File 'lib/compass/fontcustom/glyph_map.rb', line 67 def to_s @name.to_s end |