blacksmith 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
1
  family 'Blacksmith'
2
2
  source '../glyphs'
3
3
 
4
- glyph 'star', code: 0x0061
4
+ glyph 'star.svg', code: 0x0061
@@ -6,6 +6,6 @@ Blacksmith.forge do
6
6
  family "Blacksmith"
7
7
  source File.expand_path('../../glyphs', __FILE__)
8
8
 
9
- glyph 'star', code: 0x0061
9
+ glyph 'star.svg', code: 0x0061
10
10
 
11
11
  end
@@ -10,13 +10,11 @@ class Blacksmith::FontBuilder
10
10
  def initialize(filename = nil, &block)
11
11
  raise "Expects filename or block" unless filename || block
12
12
  raise "Expects either a block or a filename - not both" if filename and block
13
- raise "File not found: #{filename}" unless filename && File.exist?(filename)
13
+ raise "File not found: #{filename}" if filename && !File.exist?(filename)
14
14
 
15
15
  @_instructions = block || File.read(filename)
16
-
17
16
  @_attributes = {}
18
17
  @_glyphs = {}
19
- @_source = '.'
20
18
  end
21
19
 
22
20
  def execute
@@ -29,10 +27,10 @@ class Blacksmith::FontBuilder
29
27
 
30
28
  font = Blacksmith::Font.new(@_attributes)
31
29
 
32
- @_glyphs.each do |name, attrs|
33
- attrs[:scale] ||= font.scale
34
- attrs[:offset] ||= font.offset
35
- attrs[:outline] ||= File.join(font.source, "#{name}.svg")
30
+ @_glyphs.each do |filename, attrs|
31
+ attrs[:scale] ||= font.scale
32
+ attrs[:offset] ||= font.offset
33
+ attrs[:source] ||= File.join(font.source, filename)
36
34
 
37
35
  font << Blacksmith::Glyph.new(attrs)
38
36
  end
@@ -40,8 +38,8 @@ class Blacksmith::FontBuilder
40
38
  font
41
39
  end
42
40
 
43
- def glyph(name, attrs)
44
- @_glyphs[name] = attrs
41
+ def glyph(filename, attrs)
42
+ @_glyphs[filename] = attrs
45
43
  end
46
44
 
47
45
  def method_missing(name, *args)
@@ -1,12 +1,15 @@
1
1
  class Blacksmith::Glyph
2
2
  include SmartProperties
3
+
4
+ property :name, :converts => :to_s
3
5
 
4
- property :outline, :required => true,
5
- :converts => :to_s,
6
- :accepts => lambda { |filename| File.exist?(filename) }
7
-
8
- property :code, :required => true
9
-
6
+ property :code, :required => true,
7
+ :converts => :to_i
8
+
9
+ property :source, :required => true,
10
+ :converts => :to_s,
11
+ :accepts => lambda { |filename| File.exist?(filename) }
12
+
10
13
  property :left_side_bearing, :required => true,
11
14
  :converts => :to_i,
12
15
  :default => 15
@@ -20,12 +23,9 @@ class Blacksmith::Glyph
20
23
 
21
24
  property :offset, :converts => :to_f,
22
25
  :accepts => lambda { |offset| offset <= 1.0 and offset >= -1.0 }
23
-
24
- def file_name
25
- File.basename(outline)
26
- end
27
26
 
28
27
  def name
29
- File.basename(outline, '.svg')
28
+ super || File.basename(source, File.extname(source))
30
29
  end
30
+
31
31
  end
@@ -1,3 +1,3 @@
1
1
  class Blacksmith
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -44,7 +44,7 @@ font.weight = "<%= weight %>"
44
44
  <% for glyph in glyphs do %>
45
45
  # <%= glyph.name %>
46
46
  c = font.createChar(<%= glyph.code %>)
47
- c.importOutlines("<%= glyph.outline %>")
47
+ c.importOutlines("<%= glyph.source %>")
48
48
  c.left_side_bearing = <%= glyph.left_side_bearing %>
49
49
  c.right_side_bearing = <%= glyph.right_side_bearing %>
50
50
  c.simplify()
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacksmith
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: