blacksmith 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -23,4 +23,6 @@ examples/**/*.svg
23
23
  examples/**/*.afm
24
24
  examples/**/*.eot
25
25
  examples/**/*.woff
26
+ examples/**/*.html
27
+ examples/**/*.css
26
28
  !examples/glyphs/*.svg
@@ -0,0 +1,16 @@
1
+ class Blacksmith::CSSForge
2
+ class << self
3
+ def execute(font)
4
+ File.open(font.css_path, 'w+') do |file|
5
+ file.write(stylesheet_template.result(binding))
6
+ end
7
+ end
8
+
9
+ private
10
+
11
+ def stylesheet_template
12
+ template = File.read(File.join(Blacksmith.support_directory, 'font.css.erb'))
13
+ ERB.new(template)
14
+ end
15
+ end
16
+ end
@@ -45,7 +45,7 @@ class Blacksmith::Font
45
45
  :accepts => lambda { |path| File.directory?(path) },
46
46
  :default => '.'
47
47
 
48
- [:ttf, :eot, :woff, :svg].each do |extension|
48
+ [:ttf, :eot, :woff, :svg, :css, :html].each do |extension|
49
49
  name = "#{extension}_path"
50
50
 
51
51
  property name, :converts => :to_s,
@@ -21,8 +21,11 @@ class Blacksmith::Glyph
21
21
  property :offset, :converts => :to_f,
22
22
  :accepts => lambda { |offset| offset <= 1.0 and offset >= -1.0 }
23
23
 
24
- def name
24
+ def file_name
25
25
  File.basename(outline)
26
26
  end
27
-
27
+
28
+ def name
29
+ File.basename(outline, '.svg')
30
+ end
28
31
  end
@@ -0,0 +1,16 @@
1
+ class Blacksmith::HTMLForge
2
+ class << self
3
+ def execute(font)
4
+ File.open(font.html_path, 'w+') do |file|
5
+ file.write(html_template.result(binding))
6
+ end
7
+ end
8
+
9
+ private
10
+
11
+ def html_template
12
+ template = File.read(File.join(Blacksmith.support_directory, 'font.html.erb'))
13
+ ERB.new(template)
14
+ end
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  class Blacksmith
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/blacksmith.rb CHANGED
@@ -41,6 +41,8 @@ class Blacksmith
41
41
  forge_font
42
42
  auto_hint_font
43
43
  convert_font
44
+ forge_css
45
+ forge_html
44
46
  end
45
47
 
46
48
  protected
@@ -64,11 +66,20 @@ class Blacksmith
64
66
  FontForge.execute(font.to_fontforge_conversion_instructions)
65
67
  end
66
68
 
69
+ def forge_css
70
+ CSSForge.execute(font)
71
+ end
72
+
73
+ def forge_html
74
+ HTMLForge.execute(font)
75
+ end
67
76
  end
68
77
 
69
78
  require 'blacksmith/executable'
70
79
  require 'blacksmith/font_forge'
71
80
  require 'blacksmith/ttf_auto_hint'
81
+ require 'blacksmith/css_forge'
82
+ require 'blacksmith/html_forge'
72
83
 
73
84
  require 'blacksmith/font'
74
85
  require 'blacksmith/font_builder'
@@ -0,0 +1,12 @@
1
+ @font-face {
2
+ font-family: '<%= font.family %>';
3
+ src: url('<%= File.basename(font.eot_path) %>');
4
+ src: url('<%= File.basename(font.eot_path) %>?#iefix') format('embedded-opentype'),
5
+ url('<%= File.basename(font.ttf_path) %>') format('truetype'),
6
+ url('<%= File.basename(font.svg_path) %>#<%= font.identifier %>') format('svg');
7
+ font-weight: <%= font.weight %>;
8
+ font-style: normal;
9
+ }
10
+
11
+ .<%= font.identifier %>{font-family:'<%= font.family %>';}
12
+ <% for glyph in font.glyphs do %>.<%= glyph.name %>:before{content:'\<%= "%04x" % glyph.code %>'} <% end %>
@@ -0,0 +1,28 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset=utf-8 />
5
+ <title><%= font.name %></title>
6
+ <link rel="stylesheet" href="<%= font.css_path %>" />
7
+ </head>
8
+ <body>
9
+ <table>
10
+ <thead>
11
+ <tr>
12
+ <th>Name</th>
13
+ <th>Icon</th>
14
+ <th>Code</th>
15
+ </tr>
16
+ </thead>
17
+ <tbody>
18
+ <% for glyph in font.glyphs do %>
19
+ <tr>
20
+ <td><%= glyph.name %></td>
21
+ <td><span class="<%= font.identifier %> <%= glyph.name %>"></span></td>
22
+ <td><%= "%04x" % glyph.code %></td>
23
+ </tr>
24
+ <% end %>
25
+ </tbody>
26
+ </table>
27
+ </body>
28
+ </html>
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.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-11 00:00:00.000000000 Z
12
+ date: 2012-06-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: smart_properties
@@ -46,13 +46,17 @@ files:
46
46
  - examples/glyphs/star.svg
47
47
  - examples/programmatic_font_creation/programmatic_font_creation.rb
48
48
  - lib/blacksmith.rb
49
+ - lib/blacksmith/css_forge.rb
49
50
  - lib/blacksmith/executable.rb
50
51
  - lib/blacksmith/font.rb
51
52
  - lib/blacksmith/font_builder.rb
52
53
  - lib/blacksmith/font_forge.rb
53
54
  - lib/blacksmith/glyph.rb
55
+ - lib/blacksmith/html_forge.rb
54
56
  - lib/blacksmith/ttf_auto_hint.rb
55
57
  - lib/blacksmith/version.rb
58
+ - support/font.css.erb
59
+ - support/font.html.erb
56
60
  - support/fontforge_build_instructions.py.erb
57
61
  - support/fontforge_conversion_instructions.py.erb
58
62
  homepage: http://github.com/t6d/blacksmith
@@ -75,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
79
  version: '0'
76
80
  requirements: []
77
81
  rubyforge_project:
78
- rubygems_version: 1.8.24
82
+ rubygems_version: 1.8.19
79
83
  signing_key:
80
84
  specification_version: 3
81
85
  summary: Blacksmith uses FontForge to build fonts from SVG graphics