class Compass::Fontcustom::GlyphMap
Attributes
name[R]
path[R]
Public Class Methods
from_uri(uri, context)
click to toggle source
@param context [Object] usually an instance of FontImporter
# 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
new(glyphs, path, name, context)
click to toggle source
@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
# 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
Public Instance Methods
fonts()
click to toggle source
# 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()
click to toggle source
Starts the Fontcustom
font generator to write font files to disk.
# File lib/compass/fontcustom/glyph_map.rb, line 41 def generate args = (self.class.config.generator_options || {}). merge(output: output_dir, quiet: true, fonts: []). merge(Compass.configuration.fontcustom_options). 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()
click to toggle source
# File lib/compass/fontcustom/glyph_map.rb, line 59 def glyphs @fontcustom.manifest.get :glyphs end
index_for_glyph(name)
click to toggle source
# File lib/compass/fontcustom/glyph_map.rb, line 36 def index_for_glyph(name) @glyphs.index name end
output_dir()
click to toggle source
# File lib/compass/fontcustom/glyph_map.rb, line 67 def output_dir Compass.configuration.fontcustom_fonts_path || Compass.configuration.fonts_path end
to_s()
click to toggle source
# File lib/compass/fontcustom/glyph_map.rb, line 63 def to_s @name.to_s end