blacksmith 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -18,8 +18,9 @@ test/version_tmp
18
18
  tmp
19
19
 
20
20
  .DS_Store
21
- examples/*.ttf
22
- examples/*.svg
23
- examples/*.afm
24
- examples/*.eot
25
- examples/*.woff
21
+ examples/**/*.ttf
22
+ examples/**/*.svg
23
+ examples/**/*.afm
24
+ examples/**/*.eot
25
+ examples/**/*.woff
26
+ !examples/glyphs/*.svg
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Blacksmith
2
2
 
3
- TODO: Write a gem description
3
+ Blacksmith uses FontForge to build fonts from SVG graphics.
4
4
 
5
5
  ## Installation
6
6
 
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'blacksmith'
3
+
4
+ Blacksmith.run(ARGV)
@@ -0,0 +1,4 @@
1
+ family 'Blacksmith'
2
+ source '../glyphs'
3
+
4
+ glyph 'star', code: 0x0061
@@ -4,6 +4,7 @@ require 'blacksmith'
4
4
  Blacksmith.forge do
5
5
 
6
6
  family "Blacksmith"
7
+ source File.expand_path('../../glyphs', __FILE__)
7
8
 
8
9
  glyph 'star', code: 0x0061
9
10
 
@@ -10,7 +10,13 @@ class Blacksmith
10
10
  class DependencyMissing < Error; end
11
11
 
12
12
  class << self
13
-
13
+
14
+ def run(args = [])
15
+ if args.empty?
16
+ new(File.join(Dir.pwd, 'Forgefile')).forge
17
+ end
18
+ end
19
+
14
20
  def forge(*args, &block)
15
21
  new(*args, &block).forge
16
22
  end
@@ -26,7 +32,7 @@ class Blacksmith
26
32
  end
27
33
 
28
34
  def initialize(filename = nil, &block)
29
- @font = build_font(&block)
35
+ @font = FontBuilder.execute(filename, &block)
30
36
  end
31
37
 
32
38
  def forge
@@ -41,10 +47,6 @@ class Blacksmith
41
47
 
42
48
  attr_reader :font
43
49
 
44
- def build_font(&block)
45
- FontBuilder.execute(&block)
46
- end
47
-
48
50
  def check_environment
49
51
  FontForge.check_dependency!
50
52
  TTFAutoHint.check_dependency!
@@ -1,21 +1,31 @@
1
1
  class Blacksmith::FontBuilder
2
2
  class << self
3
3
 
4
- def execute(&block)
5
- new(&block).execute
4
+ def execute(*args, &block)
5
+ new(*args, &block).execute
6
6
  end
7
7
 
8
8
  end
9
9
 
10
- def initialize(&block)
11
- @_instructions = block
10
+ def initialize(filename = nil, &block)
11
+ raise "Expects filename or block" unless filename || block
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)
14
+
15
+ @_instructions = block || File.read(filename)
16
+
12
17
  @_attributes = {}
13
18
  @_glyphs = {}
14
19
  @_source = '.'
15
20
  end
16
21
 
17
22
  def execute
18
- instance_eval(&@_instructions)
23
+ case @_instructions
24
+ when String
25
+ instance_eval(@_instructions)
26
+ when Proc
27
+ instance_eval(&@_instructions)
28
+ end
19
29
 
20
30
  font = Blacksmith::Font.new(@_attributes)
21
31
 
@@ -1,3 +1,3 @@
1
1
  class Blacksmith
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -30,7 +30,8 @@ dependencies:
30
30
  description:
31
31
  email:
32
32
  - me@t6d.de
33
- executables: []
33
+ executables:
34
+ - blacksmith
34
35
  extensions: []
35
36
  extra_rdoc_files: []
36
37
  files:
@@ -39,9 +40,11 @@ files:
39
40
  - LICENSE
40
41
  - README.md
41
42
  - Rakefile
43
+ - bin/blacksmith
42
44
  - blacksmith.gemspec
43
- - examples/forging_fonts.rb
45
+ - examples/forgefile/Forgefile
44
46
  - examples/glyphs/star.svg
47
+ - examples/programmatic_font_creation/programmatic_font_creation.rb
45
48
  - lib/blacksmith.rb
46
49
  - lib/blacksmith/executable.rb
47
50
  - lib/blacksmith/font.rb