Class: DragonflyFonts::Processors::ExtractGlyph

Inherits:
Object
  • Object
show all
Defined in:
lib/dragonfly_fonts/processors/extract_glyph.rb

Instance Method Summary collapse

Instance Method Details

#call(content, glyph, options = {}) ⇒ Object

Raises:



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/dragonfly_fonts/processors/extract_glyph.rb', line 4

def call(content, glyph, options = {})
  raise UnsupportedFormat unless content.ext
  raise UnsupportedFormat unless FONT_FORGE_SUPPORTED_FORMATS.include?(content.ext.downcase)

  options = options.each_with_object({}) { |(k, v), memo| memo[k.to_s] = v } # stringify keys
  format = options.fetch('format', 'svg').to_s

  content.shell_update(ext: format) do |old_path, new_path|
    "#{fontforge_command} -lang=ff -c 'Open($1); Select($2); Export($3);' #{old_path} #{glyph} #{new_path}"
  end

  content.meta['format'] = format
  content.ext = format
end

#update_url(url_attributes, glyph, options = {}) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/dragonfly_fonts/processors/extract_glyph.rb', line 19

def update_url(url_attributes, glyph, options = {})
  options = options.each_with_object({}) { |(k, v), memo| memo[k.to_s] = v } # stringify keys
  format = options.fetch('format', 'svg').to_s

  url_attributes.ext = format
  url_attributes.glyph = glyph
end