fontcustom 1.3.0.beta → 1.3.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -4
- data/README.md +23 -30
- data/TODO.md +7 -2
- data/lib/fontcustom/cli.rb +1 -1
- data/lib/fontcustom/generator/font.rb +6 -2
- data/lib/fontcustom/options.rb +31 -31
- data/lib/fontcustom/utility.rb +2 -1
- data/lib/fontcustom/version.rb +1 -1
- data/lib/fontcustom/watcher.rb +1 -1
- data/spec/fontcustom/generator/font_spec.rb +8 -8
- data/spec/fontcustom/options_spec.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a89156ba7ef7d8a12424e06e6768e0973270b6cf
|
4
|
+
data.tar.gz: 83bbb3c5f0aa93ab04b089e642f1b57e3f9bc04d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 576122be6d77bcdf8fc9f4b577fc124b84efabd8370121404b9f137263f1d315f69e1a48d975a90cb37a1bb2be19af0655250ced8fb52d14d9f38c303f531c36
|
7
|
+
data.tar.gz: d1f6317e39596082c8c9ffe884f227a62867590140eb548cade80bf3f50d4dcd966296a29a4a62bd0ef7c0fa3a10a9ffe310ee9199a20020abb13e03f85dace1
|
data/CHANGELOG.md
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
## 1.3.0.beta (11/25/2013)
|
2
2
|
|
3
|
-
|
3
|
+
**Delete your old `.fontcustom-manifest.json` and output directories before using this version.**
|
4
4
|
|
5
|
-
|
5
|
+
The big news: fixed glyph code points. Automatically assigned for now, but changing them by hand is just a matter of modifying the generated `.fontcustom-manifest.json`. A few breaking changes (`css_prefix`, custom template syntax, possibly others). Error messages and docs are currently sparse — my apologies in advance.
|
6
6
|
|
7
7
|
* Fixed glyph code points ([#56](https://github.com/FontCustom/fontcustom/issues/56))
|
8
8
|
* Changes `css_prefix` to `css_selector` to allow greater flexibility ([#126](https://github.com/FontCustom/fontcustom/pull/126))
|
9
9
|
* Skips compilation if inputs have not changed (and `force` option to bypass checks)
|
10
10
|
* Adds CSS template helpers for convenience and DRYness
|
11
|
-
* Drops bootstrap templates (
|
11
|
+
* Drops bootstrap templates (maintenance overhead, unsure if anyone was using them)
|
12
12
|
|
13
13
|
Next up:
|
14
14
|
|
15
|
-
* Storing relative paths
|
15
|
+
* Storing relative paths for collaborative editing ([#149](https://github.com/FontCustom/fontcustom/pull/149))
|
16
16
|
|
17
17
|
## 1.2.0 (11/2/2013)
|
18
18
|
|
data/README.md
CHANGED
@@ -6,12 +6,10 @@
|
|
6
6
|
|
7
7
|
**Icon fonts from the command line.**
|
8
8
|
|
9
|
-
Generate cross-browser
|
10
|
-
@font-face CSS) from a collection of SVGs.
|
9
|
+
Generate cross-browser icon fonts and supporting files (@font-face CSS, etc.) from a collection of SVGs.
|
11
10
|
|
12
|
-
[
|
13
|
-
[
|
14
|
-
[Support](https://github.com/FontCustom/fontcustom/issues)<br/>
|
11
|
+
[Changelog](https://github.com/FontCustom/fontcustom/blob/master/CHANGELOG.md)<br>
|
12
|
+
[Bugs/Support](https://github.com/FontCustom/fontcustom/issues)<br>
|
15
13
|
[Contribute!](https://github.com/FontCustom/fontcustom/blob/master/CONTRIBUTING.md)
|
16
14
|
|
17
15
|
### Installation
|
@@ -35,10 +33,8 @@ gem install fontcustom
|
|
35
33
|
```sh
|
36
34
|
fontcustom compile path/to/vectors # Compiles icons into `fontcustom/`
|
37
35
|
fontcustom watch path/to/vectors # Compiles when vectors are changed/added/removed
|
38
|
-
|
39
|
-
|
40
|
-
fontcustom watch
|
41
|
-
|
36
|
+
fontcustom compile # Uses configuration file at `fontcustom.yml`
|
37
|
+
# or `config/fontcustom.yml`
|
42
38
|
fontcustom config # Generate a blank a configuration file
|
43
39
|
fontcustom help # See all options
|
44
40
|
```
|
@@ -47,10 +43,11 @@ fontcustom help # See all options
|
|
47
43
|
|
48
44
|
To preserve options between compiles, create a configuration file with
|
49
45
|
`fontcustom config`. This should live in the directory where you plan on
|
50
|
-
running `fontcustom` commands.
|
46
|
+
running `fontcustom` commands. Most of the following can also be used as
|
47
|
+
command line flags (`--css-selector`, etc.).
|
51
48
|
|
52
49
|
```yml
|
53
|
-
#
|
50
|
+
# (defaults shown)
|
54
51
|
font_name: fontcustom # Names the font and sets the name and directory
|
55
52
|
# of generated files
|
56
53
|
project_root: (pwd) # Context for all relative paths
|
@@ -58,16 +55,15 @@ input: (project_root) # Where vectors and templates are located
|
|
58
55
|
output: (project_root)/(font name) # Where generated files will be saved
|
59
56
|
config: (pwd)/fontcustom.yml # Optional path to a configuration file
|
60
57
|
templates: [ css, preview ] # Templates to generate alongside fonts
|
61
|
-
# Possible values: preview, css, scss,
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
no_hash: false # Don't add asset-busting hashes
|
66
|
-
preprocessor_path: "" # Font path used in CSS proprocessor templates
|
58
|
+
# Possible values: preview, css, scss, scss-rails
|
59
|
+
css_selector: .icon-{{glyph}} # Template for CSS classes
|
60
|
+
6
|
61
|
+
preprocessor_path: "" # Font path used in proprocessor templates (Sass, etc.)
|
62
|
+
no_hash: false # Don't add asset-busting hashes to font files
|
67
63
|
autowidth: false # Automatically size glyphs based on the width of
|
68
64
|
# their individual vectors
|
69
65
|
debug: false # Output raw messages from fontforge
|
70
|
-
quiet: false # Silence all
|
66
|
+
quiet: false # Silence all messages except errors
|
71
67
|
|
72
68
|
# For more control over file locations,
|
73
69
|
# set input and output as Yaml hashes
|
@@ -79,21 +75,18 @@ output:
|
|
79
75
|
fonts: app/assets/fonts # required
|
80
76
|
css: app/assets/stylesheets
|
81
77
|
preview: app/views/styleguide
|
82
|
-
|
78
|
+
6
|
83
79
|
```
|
84
80
|
|
85
|
-
### SVG
|
86
|
-
|
87
|
-
All vectors are imported as a single layer with colors and strokes ignored. If
|
88
|
-
you run into trouble, try combining your paths and ensuring that you don't have
|
89
|
-
any white fills (which show up as colored).
|
90
|
-
|
91
|
-
By default, Font Custom scales each vector to fit a 512x512 canvas with a
|
92
|
-
baseline at 448. In practice, that means as long as your SVG `viewBox` is
|
93
|
-
square, icons will look exactly like your SVGs.
|
81
|
+
### SVG Guidelines
|
94
82
|
|
95
|
-
|
96
|
-
|
83
|
+
* All colors will be rendered identically — including white fills.
|
84
|
+
* Make transparent colors solid. SVGs with transparency will be skipped.
|
85
|
+
* For greater precision, prefer fills to strokes (especially if your icon includes curves).
|
86
|
+
* Keep your icon within a square `viewBox`. Font Custom scales each SVG to fit
|
87
|
+
a 512x512 canvas with a baseline at 448.
|
88
|
+
* Setting `autowidth` to true trims horizontal white space from each glyph. This can be much easier
|
89
|
+
than centering dozens of SVGs by hand.
|
97
90
|
|
98
91
|
---
|
99
92
|
|
data/TODO.md
CHANGED
@@ -2,15 +2,20 @@
|
|
2
2
|
|
3
3
|
### 1.3.0
|
4
4
|
|
5
|
-
* tests, error messages, and docs for generate.py / SVG bugs
|
6
5
|
* tests, error messages, and docs for template generator
|
7
6
|
* store relative paths in manifest (rebuild in generator/util)
|
7
|
+
|
8
|
+
* Detect old manifest / show error message
|
9
|
+
* In template/fontcustom.yml, clarify that input/output can be hashes
|
10
|
+
|
11
|
+
* Add more travis CLI rubies / thor versions?
|
8
12
|
* documentation for template helpers
|
9
13
|
* redirect fontcustom.com to github repo (use wiki for documentation)
|
10
14
|
|
11
|
-
###
|
15
|
+
### Future
|
12
16
|
|
13
17
|
* conserve code points: http://stackoverflow.com/questions/8794430/ruby-finding-lowest-free-id-in-an-id-array
|
18
|
+
* strip /fill: rgba(...)/ from SVGs so that transparent SVGs don't fail
|
14
19
|
* more flexible input/ouput hashes (regex or file extensions)
|
15
20
|
* sass template with variables
|
16
21
|
* less template with variables
|
data/lib/fontcustom/cli.rb
CHANGED
@@ -61,7 +61,7 @@ module Fontcustom
|
|
61
61
|
File.join Fontcustom.gem_lib, "templates"
|
62
62
|
end
|
63
63
|
|
64
|
-
desc "compile [INPUT] [OPTIONS]", "Generates webfonts and templates from *.svg
|
64
|
+
desc "compile [INPUT] [OPTIONS]", "Generates webfonts and templates from *.svg files in INPUT. Default: `pwd`"
|
65
65
|
def compile(input = nil)
|
66
66
|
Base.new(options.merge(:input => input)).compile
|
67
67
|
rescue Fontcustom::Error => e
|
@@ -47,7 +47,7 @@ module Fontcustom
|
|
47
47
|
glyphs = {}
|
48
48
|
files.each do |file|
|
49
49
|
name = File.basename file, ".svg"
|
50
|
-
name = name.strip.gsub(/\W/, "-")
|
50
|
+
name = name.strip.gsub(/\W/, "-")
|
51
51
|
glyphs[name.to_sym] = { :source => file }
|
52
52
|
end
|
53
53
|
|
@@ -73,9 +73,13 @@ module Fontcustom
|
|
73
73
|
stdout = stdout.split("\n")
|
74
74
|
stdout = stdout[1..-1] if stdout[0] == "CreateAllPyModules()"
|
75
75
|
|
76
|
+
if stderr.include? "Failed to parse color rgba("
|
77
|
+
say_message :warn, "Transparent glyphs are not supported. Check your SVGs."
|
78
|
+
end
|
79
|
+
|
76
80
|
debug_msg = " Try again with --debug for more details."
|
77
81
|
if @options[:debug]
|
78
|
-
say_message :debug, "#{stderr}\n#{' ' * 14}#{stdout}"
|
82
|
+
say_message :debug, "#{stderr}\n#{' ' * 14}#{stdout}"
|
79
83
|
debug_msg = ""
|
80
84
|
end
|
81
85
|
|
data/lib/fontcustom/options.rb
CHANGED
@@ -19,6 +19,7 @@ module Fontcustom
|
|
19
19
|
load_config
|
20
20
|
merge_options
|
21
21
|
clean_font_name
|
22
|
+
clean_css_selector
|
22
23
|
set_manifest_path
|
23
24
|
set_input_paths
|
24
25
|
set_output_paths
|
@@ -92,6 +93,14 @@ module Fontcustom
|
|
92
93
|
@options[:font_name] = @options[:font_name].strip.gsub(/\W/, "-")
|
93
94
|
end
|
94
95
|
|
96
|
+
def clean_css_selector
|
97
|
+
unless @options[:css_selector].include? "{{glyph}}"
|
98
|
+
raise Fontcustom::Error,
|
99
|
+
"CSS selector `#{@options[:css_selector]}` should contain the \"{{glyph}}\" placeholder."
|
100
|
+
end
|
101
|
+
@options[:css_selector] = @options[:css_selector].strip.gsub(/[^\{\}\w]/, "-")
|
102
|
+
end
|
103
|
+
|
95
104
|
def set_manifest_path
|
96
105
|
@options[:manifest] = if ! @options[:manifest].nil?
|
97
106
|
expand_path @options[:manifest]
|
@@ -107,35 +116,21 @@ module Fontcustom
|
|
107
116
|
@options[:input] = symbolize_hash(@options[:input])
|
108
117
|
if @options[:input].has_key? :vectors
|
109
118
|
@options[:input][:vectors] = expand_path @options[:input][:vectors]
|
110
|
-
|
111
|
-
raise Fontcustom::Error,
|
112
|
-
"INPUT[:vectors] (`#{relative_to_root(@options[:input][:vectors])}`) should be "\
|
113
|
-
"a directory. Check `#{relative_to_root(@options[:config])}` or your CLI options."
|
114
|
-
end
|
119
|
+
check_input @options[:input][:vectors]
|
115
120
|
else
|
116
|
-
raise Fontcustom::Error,
|
117
|
-
"
|
118
|
-
"or your CLI options."
|
121
|
+
raise Fontcustom::Error,
|
122
|
+
"Input paths (assigned as a hash) should have a :vectors key. Check your options."
|
119
123
|
end
|
120
124
|
|
121
125
|
if @options[:input].has_key? :templates
|
122
126
|
@options[:input][:templates] = expand_path @options[:input][:templates]
|
123
|
-
|
124
|
-
raise Fontcustom::Error,
|
125
|
-
"INPUT[:templates] (`#{relative_to_root(@options[:input][:templates])}`) "\
|
126
|
-
"should be a directory. Check `#{relative_to_root(@options[:config])}` or "\
|
127
|
-
"your CLI options."
|
128
|
-
end
|
127
|
+
check_input @options[:input][:templates]
|
129
128
|
else
|
130
129
|
@options[:input][:templates] = @options[:input][:vectors]
|
131
130
|
end
|
132
131
|
else
|
133
132
|
input = @options[:input] ? expand_path(@options[:input]) : @options[:project_root]
|
134
|
-
|
135
|
-
raise Fontcustom::Error,
|
136
|
-
"INPUT (`#{relative_to_root(input)}`) should be a directory. Check "\
|
137
|
-
"`#{relative_to_root(@options[:config])}` or your CLI options."
|
138
|
-
end
|
133
|
+
check_input input
|
139
134
|
@options[:input] = { :vectors => input, :templates => input }
|
140
135
|
end
|
141
136
|
|
@@ -148,17 +143,15 @@ module Fontcustom
|
|
148
143
|
if @options[:output].is_a? Hash
|
149
144
|
@options[:output] = symbolize_hash(@options[:output])
|
150
145
|
unless @options[:output].has_key? :fonts
|
151
|
-
raise Fontcustom::Error,
|
152
|
-
"
|
153
|
-
"or your CLI options."
|
146
|
+
raise Fontcustom::Error,
|
147
|
+
"Output paths (assigned as a hash) should have a :fonts key. Check your options."
|
154
148
|
end
|
155
149
|
|
156
150
|
@options[:output].each do |key, val|
|
157
151
|
@options[:output][key] = expand_path val
|
158
152
|
if File.exists?(val) && ! File.directory?(val)
|
159
|
-
raise Fontcustom::Error,
|
160
|
-
"
|
161
|
-
"a directory. Check `#{relative_to_root(@options[:config])}` or your CLI options."
|
153
|
+
raise Fontcustom::Error,
|
154
|
+
"Output `#{relative_to_root(@options[:output][key])}` exists but isn't a directory. Check your options."
|
162
155
|
end
|
163
156
|
end
|
164
157
|
|
@@ -168,9 +161,8 @@ module Fontcustom
|
|
168
161
|
if @options[:output].is_a? String
|
169
162
|
output = expand_path @options[:output]
|
170
163
|
if File.exists?(output) && ! File.directory?(output)
|
171
|
-
raise Fontcustom::Error,
|
172
|
-
"
|
173
|
-
"`#{relative_to_root(@options[:config])}` or your CLI options."
|
164
|
+
raise Fontcustom::Error,
|
165
|
+
"Output `#{relative_to_root(output)}` exists but isn't a directory. Check your options."
|
174
166
|
end
|
175
167
|
else
|
176
168
|
output = File.join @options[:project_root], @options[:font_name]
|
@@ -214,14 +206,22 @@ module Fontcustom
|
|
214
206
|
else
|
215
207
|
template = File.expand_path File.join(@options[:input][:templates], template) unless template[0] == "/"
|
216
208
|
unless File.exists? template
|
217
|
-
config = @options[:config] ? " `#{relative_to_root(@options[:config])}` or" : ""
|
218
209
|
raise Fontcustom::Error,
|
219
|
-
"Custom template `#{relative_to_root(template)}` doesn't exist. "
|
220
|
-
"Check#{config} your CLI options."
|
210
|
+
"Custom template `#{relative_to_root(template)}` doesn't exist. Check your options."
|
221
211
|
end
|
222
212
|
template
|
223
213
|
end
|
224
214
|
end
|
225
215
|
end
|
216
|
+
|
217
|
+
def check_input(dir)
|
218
|
+
if ! File.exists? dir
|
219
|
+
raise Fontcustom::Error,
|
220
|
+
"Input `#{relative_to_root(dir)}` doesn't exist. Check your options."
|
221
|
+
elsif ! File.directory? dir
|
222
|
+
raise Fontcustom::Error,
|
223
|
+
"Input `#{relative_to_root(dir)}` isn't a directory. Check your options."
|
224
|
+
end
|
225
|
+
end
|
226
226
|
end
|
227
227
|
end
|
data/lib/fontcustom/utility.rb
CHANGED
@@ -125,8 +125,9 @@ module Fontcustom
|
|
125
125
|
# Messages
|
126
126
|
#
|
127
127
|
|
128
|
-
def say_message(status, message, color =
|
128
|
+
def say_message(status, message, color = nil)
|
129
129
|
return if _options[:quiet] && status != :error
|
130
|
+
color = :red if [:error, :debug, :warn].include?(status)
|
130
131
|
say_status status, message, color
|
131
132
|
end
|
132
133
|
|
data/lib/fontcustom/version.rb
CHANGED
data/lib/fontcustom/watcher.rb
CHANGED
@@ -13,7 +13,7 @@ describe Fontcustom::Generator::Font do
|
|
13
13
|
gen = Fontcustom::Generator::Font.new manifest
|
14
14
|
gen.stub :create_fonts
|
15
15
|
gen.generate
|
16
|
-
File.read(manifest).should match(/"glyphs":.+"
|
16
|
+
File.read(manifest).should match(/"glyphs":.+"C":/m)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -50,22 +50,22 @@ describe Fontcustom::Generator::Font do
|
|
50
50
|
gen.should_receive(:save_manifest)
|
51
51
|
gen.send :set_glyph_info
|
52
52
|
manifest = gen.instance_variable_get(:@manifest)
|
53
|
-
manifest[:glyphs][:
|
54
|
-
manifest[:glyphs][:
|
55
|
-
manifest[:glyphs][:
|
53
|
+
manifest[:glyphs][:C].should include(:codepoint => 61696)
|
54
|
+
manifest[:glyphs][:D].should include(:codepoint => 61697)
|
55
|
+
manifest[:glyphs][:"a_R3ally-eXotic-f1Le-Name"].should include(:codepoint => 61698)
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should not change codepoints of existing glyphs" do
|
59
59
|
gen = generator
|
60
60
|
gen.instance_variable_set :@options, :input => {:vectors => fixture("shared/vectors")}
|
61
|
-
gen.instance_variable_set :@manifest, :glyphs => {:
|
61
|
+
gen.instance_variable_set :@manifest, :glyphs => {:C => {:source => "foo", :codepoint => 61699}}
|
62
62
|
|
63
63
|
gen.should_receive(:save_manifest)
|
64
64
|
gen.send :set_glyph_info
|
65
65
|
manifest = gen.instance_variable_get(:@manifest)
|
66
|
-
manifest[:glyphs][:
|
67
|
-
manifest[:glyphs][:
|
68
|
-
manifest[:glyphs][:
|
66
|
+
manifest[:glyphs][:C].should include(:codepoint => 61699)
|
67
|
+
manifest[:glyphs][:D].should include(:codepoint => 61700)
|
68
|
+
manifest[:glyphs][:"a_R3ally-eXotic-f1Le-Name"].should include(:codepoint => 61701)
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
@@ -207,7 +207,7 @@ describe Fontcustom::Options do
|
|
207
207
|
:config => "fontcustom.yml",
|
208
208
|
:input => { :vectors => "shared/not-a-dir" }
|
209
209
|
}
|
210
|
-
expect { o.send :set_input_paths }.to raise_error Fontcustom::Error, /
|
210
|
+
expect { o.send :set_input_paths }.to raise_error Fontcustom::Error, /isn't a directory/
|
211
211
|
end
|
212
212
|
end
|
213
213
|
|
@@ -240,7 +240,7 @@ describe Fontcustom::Options do
|
|
240
240
|
:config => "fontcustom.yml",
|
241
241
|
:input => "shared/not-a-dir"
|
242
242
|
}
|
243
|
-
expect { o.send :set_input_paths }.to raise_error Fontcustom::Error, /
|
243
|
+
expect { o.send :set_input_paths }.to raise_error Fontcustom::Error, /isn't a directory/
|
244
244
|
end
|
245
245
|
end
|
246
246
|
end
|
@@ -354,7 +354,7 @@ describe Fontcustom::Options do
|
|
354
354
|
:config => "fontcustom.yml",
|
355
355
|
:output => "shared/not-a-dir"
|
356
356
|
}
|
357
|
-
expect { o.send :set_output_paths }.to raise_error Fontcustom::Error, /
|
357
|
+
expect { o.send :set_output_paths }.to raise_error Fontcustom::Error, /isn't a directory/
|
358
358
|
end
|
359
359
|
end
|
360
360
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fontcustom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.0.
|
4
|
+
version: 1.3.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kai Zau
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|