Class: DragonflyFonts::Processors::SetWidth

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

Instance Method Summary collapse

Instance Method Details

#call(content, width, relative = 1) ⇒ Object

relative: when absent or 0 the vertical width will be set to width when 1 then the vertical width will be incremented by the first when 2 then the vertical width will be scaled by <first argument>/100.0.

Raises:



8
9
10
11
12
13
14
15
# File 'lib/dragonfly_fonts/processors/set_width.rb', line 8

def call(content, width, relative = 1)
  raise UnsupportedFormat unless content.ext
  raise UnsupportedFormat unless FONT_FORGE_SUPPORTED_FORMATS.include?(content.ext.downcase)

  content.shell_update(ext: content.ext || 'ttf') do |old_path, new_path|
    "#{fontforge_command} -lang=ff -c 'Open($1); SelectWorthOutputting(); SetWidth(#{width},#{relative}); Generate($2);' #{old_path} #{new_path}"
  end
end

#update_url(attrs, *_args) ⇒ Object



17
18
19
# File 'lib/dragonfly_fonts/processors/set_width.rb', line 17

def update_url(attrs, *_args)
  attrs.style = 'adjwidth'
end