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
- #fonts ⇒ Object
-
#generate ⇒ Object
Starts the Fontcustom font generator to write font files to disk.
- #glyphs ⇒ Object
- #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.
28 29 30 31 32 33 34 |
# File 'lib/compass/fontcustom/glyph_map.rb', line 28 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.
10 11 12 |
# File 'lib/compass/fontcustom/glyph_map.rb', line 10 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
10 11 12 |
# File 'lib/compass/fontcustom/glyph_map.rb', line 10 def path @path end |
Class Method Details
.from_uri(uri, context) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/compass/fontcustom/glyph_map.rb', line 13 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
#fonts ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/compass/fontcustom/glyph_map.rb', line 51 def fonts if @fontcustom @fontcustom.manifest.get(:fonts).each_with_object({}) do |font, result| result[File.extname(font)[1..-1].to_sym] = font end end end |
#generate ⇒ Object
Starts the Fontcustom font generator to write font files to disk.
41 42 43 44 45 46 47 48 49 |
# File 'lib/compass/fontcustom/glyph_map.rb', line 41 def generate args = (self.class.config. || {}). merge(output: output_dir, quiet: true, fonts: []). merge(Compass.configuration.). merge(font_name: @name, input: path) @fontcustom = ::Fontcustom::Base.new(args) @fontcustom.compile File.delete(@fontcustom.manifest.manifest) if Compass.configuration.fontcustom_discard_manifest end |
#glyphs ⇒ Object
59 60 61 |
# File 'lib/compass/fontcustom/glyph_map.rb', line 59 def glyphs @fontcustom.manifest.get :glyphs end |
#index_for_glyph(name) ⇒ Object
36 37 38 |
# File 'lib/compass/fontcustom/glyph_map.rb', line 36 def index_for_glyph(name) @glyphs.index name end |
#output_dir ⇒ Object
67 68 69 |
# File 'lib/compass/fontcustom/glyph_map.rb', line 67 def output_dir Compass.configuration.fontcustom_fonts_path || Compass.configuration.fonts_path end |
#to_s ⇒ Object
63 64 65 |
# File 'lib/compass/fontcustom/glyph_map.rb', line 63 def to_s @name.to_s end |