fontrobot 0.1 → 0.1.2

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8c132e3d05391e3f79679bd1c384e7478ce27dcd
4
+ data.tar.gz: 3cf9b0c033571fcf21c68c9d8ea441af98a5a68c
5
+ SHA512:
6
+ metadata.gz: 8addd02091a2d6ee8126ad6a4021bec6be65ee1eb85d4823bc46f4a1b9d8636e64485094f2d76f956fda2e9a2f813f3e408aefefa5e5205cc9ff7ebbbc925638
7
+ data.tar.gz: 916d7bb981eb0fcb7359097ed5ccd0be8e91e155135c90e05dfc2551c7c7aa14fa0705a9c1b714aa9ee376d16b66983f5e10a57a9b20dc9610ed635eab114ea0
data/LICENSES.txt CHANGED
@@ -1,6 +1,7 @@
1
- fontrobot
1
+ fontcustom
2
2
 
3
3
  Copyright (c) 2013 Tim Barkow
4
+ Copyright (c) 2012 Yifei Zhang, Joshua Gross
4
5
 
5
6
  MIT License
6
7
 
data/README.md CHANGED
@@ -1,11 +1,17 @@
1
- FontRobot v0.1
1
+ FontRobot v0.1.1
2
2
  ==========
3
3
 
4
4
  **Generate custom icon webfonts from the comfort of the command line.**
5
5
 
6
- This is a fork of Fontcustom, required so I could make changes and update the gem in a timely fashion. FontRobot extends Fontcustom, adding more control over how the @fontface declaration is created. See command-line options below for more details.
6
+ This is a fork of Fontcustom. I needed a quick fork to work out the kinks using this gem in a large-scale production Rails environment. I'm testing it live every day. :) I hope to merge my changes upstream to Fontcustom soon (Just FYI).
7
7
 
8
- [Fontcustom documentation](http://fontcustom.github.com/fontcustom/)
8
+ FontRobot is primarily designed to add more control over how the @fontface declaration is created. See command-line options below for more details.
9
+
10
+ Fontrobot allows you specify the font order in @font-face, to inline font(s) as a data-uri, and creates an IE-compatible @font-face declaration.
11
+
12
+ Data-uri fonts are nice because they circumvent some browser's origin policies and they load fast. For best performance, make sure your server gzips all served assets.
13
+
14
+ [Original Fontcustom documentation](http://fontcustom.github.com/fontcustom/)
9
15
 
10
16
 
11
17
  Installation
@@ -38,7 +44,7 @@ Command-line options
38
44
  --font_path, -f => Specify a path for fonts in css @font-face declaration. Default: none
39
45
 
40
46
  --order, -r => Specify font order in css @font-face. Default: "eot,ttf,woff,svg"
41
- --inline, -i => Include specified font fomats as data-uri in @font-face. Default: none. Format: "eot,ttf,woff,svg"
47
+ --inline, -i => Specify fonts to include as data-uri's in @font-face. Default: none. Format: "ttf,svg" One is enough though.
42
48
 
43
49
  --nohash => (boolean) Disable filename hashes. Default: false
44
50
  --debug => (boolean) Display debug messages. Default: false
@@ -11,6 +11,7 @@ Gem::Specification.new do |gem|
11
11
  gem.summary = %q{Generate custom icon webfonts from the command line.}
12
12
  gem.description = %q{Transforms EPS and SVG vectors into icon webfonts. Generates Bootstrap compatible CSS for easy inclusion in your projects.}
13
13
  gem.homepage = "http://robotloveskitten.github.com/fontrobot/"
14
+ gem.licenses = ["MIT", "MPL 1.1/GPL 2.0/LGPL 2.1"]
14
15
 
15
16
  gem.files = `git ls-files`.split($/)
16
17
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -1,6 +1,7 @@
1
1
  require 'json'
2
2
  require 'thor/group'
3
3
  require 'base64'
4
+ require 'zlib'
4
5
 
5
6
  module Fontrobot
6
7
  class Generator < Thor::Group
@@ -9,13 +10,11 @@ module Fontrobot
9
10
  desc 'Generates webfonts from given directory of vectors.'
10
11
 
11
12
  argument :input, :type => :string
12
- class_option :output, :aliases => '-o'
13
- class_option :name, :aliases => '-n'
14
- class_option :font_path, :aliases => '-f'
15
-
13
+ class_option :output, :aliases => '-o'
14
+ class_option :name, :aliases => '-n'
15
+ class_option :font_path, :aliases => '-f'
16
16
  class_option :order, :aliases => '-r' # 'Specify font order in css @font-face. Default: "eot,ttf,woff,svg"'
17
17
  class_option :inline, :aliases => '-i' # 'Inline font as data-uri in @font-face. Default: none. Format: "eot,ttf,woff,svg"'
18
-
19
18
  class_option :nohash, :type => :boolean, :default => false
20
19
  class_option :debug, :type => :boolean, :default => false
21
20
  class_option :html, :type => :boolean, :default => false
@@ -46,17 +45,19 @@ module Fontrobot
46
45
  end
47
46
 
48
47
  def normalize_name
49
- @name = if options.name
50
- options.name.gsub(/\W/, '-').downcase
51
- else
52
- 'fontrobot'
53
- end
48
+ @name = (options.name) ? options.name.gsub(/\W/, '-').downcase : 'fontrobot'
54
49
  end
55
50
 
56
51
  def cleanup_output_dir
57
- # simpler: how about we just delete everything in the dir?
58
- old_files = Dir[File.join(@output, '*')]
59
- old_files.each {|file| remove_file file }
52
+ old_files = ['fontrobot.css','fontrobot-ie7.css','test.html']
53
+ old_name = 'fontrobot'
54
+ css = File.join(@output, old_files[0])
55
+ if File.exists?(css)
56
+ line = IO.readlines(css)[3]
57
+ old_name = line.match(/Path:([^-]+)/)[1].downcase
58
+ end
59
+ old_files.concat(Dir[File.join(@output, old_name + '-*.{woff,ttf,eot,svg}')])
60
+ old_files.each { |file| remove_file File.join(@output, file) }
60
61
  end
61
62
 
62
63
 
@@ -78,7 +79,6 @@ module Fontrobot
78
79
  def show_paths
79
80
  file = Dir[File.join(@output, @name + '*.ttf')].first
80
81
  @path = file.chomp('.ttf')
81
-
82
82
  ['woff','ttf','eot','svg'].each do |type|
83
83
  say_status(:create, @path + '.' + type)
84
84
  end
@@ -86,8 +86,11 @@ module Fontrobot
86
86
 
87
87
 
88
88
  def fontface_sources
89
- order = (options.order) ? options.order.split(",") : ['eot','ttf','woff','svg']
89
+ @inline_sources = false
90
+ fonts = (options.order) ? options.order.split(",") : ['eot','ttf','woff','svg']
90
91
  inline = (options.inline) ? options.inline.split(",") : []
92
+ zip = (options.zip.empty?) ? options.zip.split(",") : []
93
+
91
94
  reorder = {}
92
95
  longtype = {
93
96
  'woff' => 'woff',
@@ -96,6 +99,7 @@ module Fontrobot
96
99
  'svg' => 'svg'
97
100
  }
98
101
 
102
+ # set url path for font files
99
103
  if(!options.font_path.nil?)
100
104
  font_path = (options.font_path) ? options.font_path : ''
101
105
  @path = File.join(font_path, File.basename(@path))
@@ -103,26 +107,33 @@ module Fontrobot
103
107
  @path = File.basename(@path)
104
108
  end
105
109
 
106
- @fontface = {
107
- :eot => "url(\"#{@path}.eot?#iefix\") format(\"embedded-opentype\")",
108
- :woff => "url(\"#{@path}.woff\") format(\"woff\")",
109
- :ttf => "url(\"#{@path}.ttf\") format(\"truetype\")",
110
- :svg => "url(\"#{@path}.svg##{@name}\") format(\"svg\")"
110
+ fontface_strings = {
111
+ :eot => "url('#{@path}.eot?#iefix') format('embedded-opentype')",
112
+ :woff => "url('#{@path}.woff') format('woff')",
113
+ :ttf => "url('#{@path}.ttf') format('truetype')",
114
+ :svg => "url('#{@path}.svg##{@name}') format('svg')"
111
115
  }
112
116
 
113
- # reorder the fontface hash
114
- order.each do |type|
117
+ # if we're inlining we need to make 2 font-face declarations
118
+ # http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax
119
+ if(inline.any?)
120
+ @inline_sources = true
121
+ fonts.delete('eot') # can't ever inline an eot
122
+ end
123
+
124
+ # order the fontface hash
125
+ @font_sources = []
126
+ fonts.each do |type|
115
127
  if(inline.include?(type))
116
128
  fontpath = File.expand_path(File.join(@output, File.basename(@path)+"."+type))
117
- contents = File.read(fontpath)
118
- encoded_contents = Base64.encode64(contents).gsub(/\n/, '') # encode and remove newlines, 1.8.7 compat
119
- fontstring = "url(data:application/x-font-#{type};charset=utf-8;base64," + encoded_contents +") format('#{longtype[type]}')"
129
+ encoded_contents = Base64.encode64(File.read(fontpath)).gsub(/\n/, '') # encode and remove newlines, 1.8.7 compat
130
+ src = "url(data:application/x-font-#{type};charset=utf-8;base64," + encoded_contents +") format('#{longtype[type]}')"
120
131
  else
121
- fontstring = @fontface[type.to_sym]
132
+ src = fontface_strings[type.to_sym]
122
133
  end
123
- reorder[type.to_sym] = fontstring
134
+ @font_sources << src;
124
135
  end
125
- @fonturls = reorder.map{|k,v| v }.join(",\n");
136
+ @font_sources = @font_sources.join(', ');
126
137
  end
127
138
 
128
139
 
@@ -1,10 +1,19 @@
1
1
  /*
2
- Font Custom - icon webfonts made simple
2
+ Font Robot CSS
3
+ DO NOT EDIT THIS COMMENT BLOCK. IT'S REQUIRED BY THE GENERATOR. THX, FONTROBOT
4
+ Path:<%= @path %>
3
5
  */
4
-
6
+
7
+ <% if @inline_sources %>
8
+ @font-face {
9
+ font-family: "<%= @name %>";
10
+ src: url("<%= @path %>.eot?#iefix") format("embedded-opentype");
11
+ }
12
+
13
+ <% end %>
5
14
  @font-face {
6
15
  font-family: "<%= @name %>";
7
- src: <%= @fonturls %>;
16
+ src: <%= @font_sources %>;
8
17
  font-weight: normal;
9
18
  font-style: normal;
10
19
  }
@@ -1,3 +1,3 @@
1
1
  module Fontrobot
2
- VERSION = "0.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,137 +1,169 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fontrobot
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
5
- prerelease:
4
+ version: 0.1.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Tim Barkow
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-16 00:00:00.000000000 Z
11
+ date: 2013-03-21 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: json
16
- requirement: &70295096519860 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *70295096519860
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: thor
27
- requirement: &70295096517940 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
31
  - - ! '>='
31
32
  - !ruby/object:Gem::Version
32
33
  version: '0'
33
34
  type: :runtime
34
35
  prerelease: false
35
- version_requirements: *70295096517940
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: listen
38
- requirement: &70295096510920 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
45
  - - ! '>='
42
46
  - !ruby/object:Gem::Version
43
47
  version: '0'
44
48
  type: :runtime
45
49
  prerelease: false
46
- version_requirements: *70295096510920
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
47
55
  - !ruby/object:Gem::Dependency
48
56
  name: rake
49
- requirement: &70295096508960 !ruby/object:Gem::Requirement
50
- none: false
57
+ requirement: !ruby/object:Gem::Requirement
51
58
  requirements:
52
59
  - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
62
  type: :development
56
63
  prerelease: false
57
- version_requirements: *70295096508960
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
58
69
  - !ruby/object:Gem::Dependency
59
70
  name: bundler
60
- requirement: &70295096506800 !ruby/object:Gem::Requirement
61
- none: false
71
+ requirement: !ruby/object:Gem::Requirement
62
72
  requirements:
63
73
  - - ! '>='
64
74
  - !ruby/object:Gem::Version
65
75
  version: '0'
66
76
  type: :development
67
77
  prerelease: false
68
- version_requirements: *70295096506800
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rspec
71
- requirement: &70295096505020 !ruby/object:Gem::Requirement
72
- none: false
85
+ requirement: !ruby/object:Gem::Requirement
73
86
  requirements:
74
87
  - - ! '>='
75
88
  - !ruby/object:Gem::Version
76
89
  version: '0'
77
90
  type: :development
78
91
  prerelease: false
79
- version_requirements: *70295096505020
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
80
97
  - !ruby/object:Gem::Dependency
81
98
  name: fakefs
82
- requirement: &70295096503960 !ruby/object:Gem::Requirement
83
- none: false
99
+ requirement: !ruby/object:Gem::Requirement
84
100
  requirements:
85
101
  - - ! '>='
86
102
  - !ruby/object:Gem::Version
87
103
  version: '0'
88
104
  type: :development
89
105
  prerelease: false
90
- version_requirements: *70295096503960
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
91
111
  - !ruby/object:Gem::Dependency
92
112
  name: spork
93
- requirement: &70295096503140 !ruby/object:Gem::Requirement
94
- none: false
113
+ requirement: !ruby/object:Gem::Requirement
95
114
  requirements:
96
115
  - - ! '>='
97
116
  - !ruby/object:Gem::Version
98
117
  version: '0'
99
118
  type: :development
100
119
  prerelease: false
101
- version_requirements: *70295096503140
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
102
125
  - !ruby/object:Gem::Dependency
103
126
  name: guard-spork
104
- requirement: &70295092408240 !ruby/object:Gem::Requirement
105
- none: false
127
+ requirement: !ruby/object:Gem::Requirement
106
128
  requirements:
107
129
  - - ! '>='
108
130
  - !ruby/object:Gem::Version
109
131
  version: '0'
110
132
  type: :development
111
133
  prerelease: false
112
- version_requirements: *70295092408240
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ! '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
113
139
  - !ruby/object:Gem::Dependency
114
140
  name: guard-rspec
115
- requirement: &70295092404300 !ruby/object:Gem::Requirement
116
- none: false
141
+ requirement: !ruby/object:Gem::Requirement
117
142
  requirements:
118
143
  - - ! '>='
119
144
  - !ruby/object:Gem::Version
120
145
  version: '0'
121
146
  type: :development
122
147
  prerelease: false
123
- version_requirements: *70295092404300
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ! '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
124
153
  - !ruby/object:Gem::Dependency
125
154
  name: rb-fsevent
126
- requirement: &70295092403120 !ruby/object:Gem::Requirement
127
- none: false
155
+ requirement: !ruby/object:Gem::Requirement
128
156
  requirements:
129
157
  - - ~>
130
158
  - !ruby/object:Gem::Version
131
159
  version: 0.9.1
132
160
  type: :development
133
161
  prerelease: false
134
- version_requirements: *70295092403120
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ~>
165
+ - !ruby/object:Gem::Version
166
+ version: 0.9.1
135
167
  description: Transforms EPS and SVG vectors into icon webfonts. Generates Bootstrap
136
168
  compatible CSS for easy inclusion in your projects.
137
169
  email:
@@ -150,7 +182,7 @@ files:
150
182
  - README.md
151
183
  - Rakefile
152
184
  - bin/fontrobot
153
- - fontcustom.gemspec
185
+ - fontrobot.gemspec
154
186
  - lib/fontrobot.rb
155
187
  - lib/fontrobot/cli.rb
156
188
  - lib/fontrobot/generator.rb
@@ -171,28 +203,29 @@ files:
171
203
  - spec/fontrobot/watcher_spec.rb.off
172
204
  - spec/spec_helper.rb
173
205
  homepage: http://robotloveskitten.github.com/fontrobot/
174
- licenses: []
206
+ licenses:
207
+ - MIT
208
+ - MPL 1.1/GPL 2.0/LGPL 2.1
209
+ metadata: {}
175
210
  post_install_message:
176
211
  rdoc_options: []
177
212
  require_paths:
178
213
  - lib
179
214
  required_ruby_version: !ruby/object:Gem::Requirement
180
- none: false
181
215
  requirements:
182
216
  - - ! '>='
183
217
  - !ruby/object:Gem::Version
184
218
  version: '0'
185
219
  required_rubygems_version: !ruby/object:Gem::Requirement
186
- none: false
187
220
  requirements:
188
221
  - - ! '>='
189
222
  - !ruby/object:Gem::Version
190
223
  version: '0'
191
224
  requirements: []
192
225
  rubyforge_project:
193
- rubygems_version: 1.8.15
226
+ rubygems_version: 2.0.3
194
227
  signing_key:
195
- specification_version: 3
228
+ specification_version: 4
196
229
  summary: Generate custom icon webfonts from the command line.
197
230
  test_files:
198
231
  - spec/fixtures/empty/no_vectors_here.txt