fontcustom 1.2.0 → 1.3.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +16 -0
- data/CONTRIBUTING.md +35 -15
- data/TODO.md +20 -0
- data/lib/fontcustom.rb +11 -24
- data/lib/fontcustom/base.rb +56 -0
- data/lib/fontcustom/cli.rb +13 -12
- data/lib/fontcustom/generator/font.rb +63 -65
- data/lib/fontcustom/generator/template.rb +81 -52
- data/lib/fontcustom/manifest.rb +42 -0
- data/lib/fontcustom/options.rb +93 -80
- data/lib/fontcustom/scripts/generate.py +116 -127
- data/lib/fontcustom/templates/_fontcustom-rails.scss +13 -18
- data/lib/fontcustom/templates/_fontcustom.scss +10 -18
- data/lib/fontcustom/templates/fontcustom-preview.html +17 -24
- data/lib/fontcustom/templates/fontcustom.css +10 -18
- data/lib/fontcustom/templates/fontcustom.yml +3 -3
- data/lib/fontcustom/utility.rb +145 -0
- data/lib/fontcustom/version.rb +1 -1
- data/lib/fontcustom/watcher.rb +1 -1
- data/spec/fixtures/generators/.fontcustom-manifest-corrupted.json +12 -5
- data/spec/fixtures/generators/.fontcustom-manifest-empty.json +0 -0
- data/spec/fixtures/generators/.fontcustom-manifest.json +49 -14
- data/spec/fixtures/generators/mixed-output/fontcustom_82a59e769bc60192484f2620570bbb59.eot +0 -0
- data/spec/fixtures/generators/mixed-output/fontcustom_82a59e769bc60192484f2620570bbb59.svg +56 -0
- data/spec/fixtures/generators/mixed-output/fontcustom_82a59e769bc60192484f2620570bbb59.ttf +0 -0
- data/spec/fixtures/generators/mixed-output/fontcustom_82a59e769bc60192484f2620570bbb59.woff +0 -0
- data/spec/fixtures/sandbox/.gitkeep +0 -0
- data/spec/fontcustom/base_spec.rb +58 -0
- data/spec/fontcustom/cli_spec.rb +15 -0
- data/spec/fontcustom/generator/font_spec.rb +50 -220
- data/spec/fontcustom/generator/template_spec.rb +30 -194
- data/spec/fontcustom/generator/template_spec.rb.off +215 -0
- data/spec/fontcustom/manifest_spec.rb +16 -0
- data/spec/fontcustom/options_spec.rb +206 -208
- data/spec/fontcustom/utility_spec.rb +163 -0
- data/spec/fontcustom/{watcher_spec.rb → watcher_spec.rb.off} +0 -0
- data/spec/spec_helper.rb +77 -19
- metadata +44 -54
- data/lib/fontcustom/templates/_fontcustom-bootstrap-ie7.scss +0 -22
- data/lib/fontcustom/templates/_fontcustom-bootstrap.scss +0 -63
- data/lib/fontcustom/templates/fontcustom-bootstrap-ie7.css +0 -22
- data/lib/fontcustom/templates/fontcustom-bootstrap.css +0 -63
- data/lib/fontcustom/util.rb +0 -62
- data/spec/fixtures/generators/mixed-output/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.eot +0 -0
- data/spec/fixtures/generators/mixed-output/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.svg +0 -102
- data/spec/fixtures/generators/mixed-output/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.ttf +0 -0
- data/spec/fixtures/generators/mixed-output/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.woff +0 -0
- data/spec/fontcustom/util_spec.rb +0 -82
@@ -5,10 +5,11 @@
|
|
5
5
|
# --------------------------------------------------------------------------- #
|
6
6
|
|
7
7
|
#font_name: fontcustom
|
8
|
-
#
|
8
|
+
#css_selector: .icon-{{glyph}}
|
9
9
|
#preprocessor_path: ""
|
10
10
|
#autowidth: false
|
11
11
|
#no_hash: false
|
12
|
+
#force: false
|
12
13
|
#debug: false
|
13
14
|
#quiet: false
|
14
15
|
|
@@ -37,8 +38,7 @@
|
|
37
38
|
# --------------------------------------------------------------------------- #
|
38
39
|
# Templates
|
39
40
|
# Included in Font Custom:
|
40
|
-
# preview, css, scss, scss-rails
|
41
|
-
# bootstrap-ie7-scss
|
41
|
+
# preview, css, scss, scss-rails
|
42
42
|
# Custom templates should be saved in the INPUT[:templates] directory and
|
43
43
|
# referenced by their base file name.
|
44
44
|
# --------------------------------------------------------------------------- #
|
@@ -0,0 +1,145 @@
|
|
1
|
+
require "json"
|
2
|
+
require "thor/actions"
|
3
|
+
require "thor/shell"
|
4
|
+
require "thor/shell/basic"
|
5
|
+
require "thor/shell/color"
|
6
|
+
|
7
|
+
# Requires access to @options or @cli_options
|
8
|
+
module Fontcustom
|
9
|
+
module Utility
|
10
|
+
include Thor::Actions
|
11
|
+
|
12
|
+
#
|
13
|
+
# Hacks that allow Thor::Actions and Thor::Shell to be used in Fontcustom classes.
|
14
|
+
#
|
15
|
+
|
16
|
+
def self.shell
|
17
|
+
@shell || Thor::Shell::Color.new
|
18
|
+
end
|
19
|
+
|
20
|
+
def behavior
|
21
|
+
:invoke
|
22
|
+
end
|
23
|
+
|
24
|
+
def shell
|
25
|
+
Fontcustom::Utility.shell
|
26
|
+
end
|
27
|
+
|
28
|
+
def say_status(*args)
|
29
|
+
shell.say_status *args
|
30
|
+
end
|
31
|
+
|
32
|
+
def destination_root
|
33
|
+
@destination_stack ||= [_options[:project_root]]
|
34
|
+
@destination_stack.last
|
35
|
+
end
|
36
|
+
|
37
|
+
def source_paths
|
38
|
+
@source_paths ||= [File.join(Fontcustom.gem_lib, "templates")]
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# Options
|
43
|
+
#
|
44
|
+
|
45
|
+
module HashWithMethodAccess
|
46
|
+
def method_missing(method, arg = nil)
|
47
|
+
if method[-1, 1] == "="
|
48
|
+
self[method[0...-1].to_sym] = arg
|
49
|
+
else
|
50
|
+
self[method.to_sym]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def symbolize_hash(hash)
|
56
|
+
hash.inject({}) { |memo, (k, v)| memo[k.to_sym] = v; memo }
|
57
|
+
end
|
58
|
+
|
59
|
+
def methodize_hash(hash)
|
60
|
+
hash.extend HashWithMethodAccess
|
61
|
+
end
|
62
|
+
|
63
|
+
#
|
64
|
+
# Paths
|
65
|
+
#
|
66
|
+
|
67
|
+
def expand_path(path)
|
68
|
+
return path if path[0] == "/" # ignore absolute paths
|
69
|
+
File.expand_path File.join(_options[:project_root], path)
|
70
|
+
end
|
71
|
+
|
72
|
+
# TODO Is this robust enough?
|
73
|
+
def relative_to_root(path)
|
74
|
+
path = path.sub(_options[:project_root], "")
|
75
|
+
path = path[1..-1] if path[0] == "/"
|
76
|
+
path = "." if path.empty?
|
77
|
+
path
|
78
|
+
end
|
79
|
+
|
80
|
+
#
|
81
|
+
# Manifest / Files
|
82
|
+
#
|
83
|
+
|
84
|
+
def write_file(file, content = "", message = nil, message_body = nil)
|
85
|
+
File.open(file, "w") { |f| f.write(content) }
|
86
|
+
if message
|
87
|
+
body = message_body || relative_to_root(file)
|
88
|
+
say_message message, body
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def get_manifest(file = _options[:manifest])
|
93
|
+
begin
|
94
|
+
json = File.read file
|
95
|
+
JSON.parse(json, :symbolize_names => true)
|
96
|
+
rescue JSON::ParserError
|
97
|
+
raise Fontcustom::Error,
|
98
|
+
"Couldn't parse `#{relative_to_root file}`. Fix the invalid "\
|
99
|
+
"JSON or delete the file to start from scratch."
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def save_manifest
|
104
|
+
json = JSON.pretty_generate @manifest
|
105
|
+
write_file _options[:manifest], json
|
106
|
+
end
|
107
|
+
|
108
|
+
def delete_from_manifest(key)
|
109
|
+
files = @manifest[key]
|
110
|
+
return if files.empty?
|
111
|
+
begin
|
112
|
+
deleted = []
|
113
|
+
@manifest[key].each do |file|
|
114
|
+
remove_file file, :verbose => false
|
115
|
+
deleted << file
|
116
|
+
end
|
117
|
+
ensure
|
118
|
+
@manifest[key] = @manifest[key] - deleted
|
119
|
+
save_manifest
|
120
|
+
say_changed :delete, deleted
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
#
|
125
|
+
# Messages
|
126
|
+
#
|
127
|
+
|
128
|
+
def say_message(status, message, color = :yellow)
|
129
|
+
return if _options[:quiet] && status != :error
|
130
|
+
say_status status, message, color
|
131
|
+
end
|
132
|
+
|
133
|
+
def say_changed(status, changed)
|
134
|
+
return if _options[:quiet]
|
135
|
+
message = changed.map { |file| relative_to_root(file) }
|
136
|
+
say_status status, message.join("\n#{" " * 14}"), :green # magic number
|
137
|
+
end
|
138
|
+
|
139
|
+
private
|
140
|
+
|
141
|
+
def _options
|
142
|
+
@options || @cli_options
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
data/lib/fontcustom/version.rb
CHANGED
data/lib/fontcustom/watcher.rb
CHANGED
@@ -1,18 +1,25 @@
|
|
1
1
|
'Totally invalid JSON.'
|
2
2
|
{
|
3
|
-
|
3
|
+
"checksum": {
|
4
|
+
"current": "82a59e769bc60192484f2620570bbb59e225db97c1aac3f242a2e49d6060a19c",
|
5
|
+
"previous": "82a59e769bc60192484f2620570bbb59e225db97c1aac3f242a2e49d6060a19c"
|
6
|
+
},
|
7
|
+
"fonts": [
|
4
8
|
"fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.woff",
|
5
9
|
"fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.ttf",
|
6
10
|
"fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.eot",
|
7
11
|
"fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.svg"
|
8
12
|
],
|
9
|
-
"templates": [
|
10
|
-
"fontcustom.css"
|
11
|
-
],
|
12
|
-
"file_name": "fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e",
|
13
13
|
"glyphs": [
|
14
14
|
"a_r3ally-exotic-f1le-name",
|
15
15
|
"c",
|
16
16
|
"d"
|
17
|
+
],
|
18
|
+
"options": {
|
19
|
+
"foo": "bar",
|
20
|
+
"baz": "bum"
|
21
|
+
},
|
22
|
+
"templates": [
|
23
|
+
"fontcustom.css"
|
17
24
|
]
|
18
25
|
}
|
File without changes
|
@@ -1,17 +1,52 @@
|
|
1
1
|
{
|
2
|
+
"checksum": {
|
3
|
+
"current": "82a59e769bc60192484f2620570bbb59e225db97c1aac3f242a2e49d6060a19c",
|
4
|
+
"previous": "82a59e769bc60192484f2620570bbb59e225db97c1aac3f242a2e49d6060a19c"
|
5
|
+
},
|
2
6
|
"fonts": [
|
3
|
-
"
|
4
|
-
"
|
5
|
-
"
|
6
|
-
"
|
7
|
-
],
|
8
|
-
"
|
9
|
-
"
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
"
|
14
|
-
|
15
|
-
|
16
|
-
|
7
|
+
"/Users/kz/Projects/fontcustom/spec/fixtures/sandbox/test/fontcustom/fontcustom_82a59e769bc60192484f2620570bbb59.ttf",
|
8
|
+
"/Users/kz/Projects/fontcustom/spec/fixtures/sandbox/test/fontcustom/fontcustom_82a59e769bc60192484f2620570bbb59.svg",
|
9
|
+
"/Users/kz/Projects/fontcustom/spec/fixtures/sandbox/test/fontcustom/fontcustom_82a59e769bc60192484f2620570bbb59.woff",
|
10
|
+
"/Users/kz/Projects/fontcustom/spec/fixtures/sandbox/test/fontcustom/fontcustom_82a59e769bc60192484f2620570bbb59.eot"
|
11
|
+
],
|
12
|
+
"glyphs": {
|
13
|
+
"a_r3ally-exotic-f1le-name": {
|
14
|
+
"codepoint": 61696,
|
15
|
+
"source": "/Users/kz/Projects/fontcustom/spec/fixtures/sandbox/test/vectors/a_R3ally-eXotic f1Le Name.svg"
|
16
|
+
},
|
17
|
+
"c": {
|
18
|
+
"codepoint": 61697,
|
19
|
+
"source": "/Users/kz/Projects/fontcustom/spec/fixtures/sandbox/test/vectors/C.svg"
|
20
|
+
},
|
21
|
+
"d": {
|
22
|
+
"codepoint": 61698,
|
23
|
+
"source": "/Users/kz/Projects/fontcustom/spec/fixtures/sandbox/test/vectors/D.svg"
|
24
|
+
}
|
25
|
+
},
|
26
|
+
"options": {
|
27
|
+
"autowidth": false,
|
28
|
+
"config": false,
|
29
|
+
"css_prefix": "test-",
|
30
|
+
"debug": false,
|
31
|
+
"font_name": "fontcustom",
|
32
|
+
"input": {
|
33
|
+
"templates": "/Users/kz/Projects/fontcustom/spec/fixtures/sandbox/test/vectors",
|
34
|
+
"vectors": "/Users/kz/Projects/fontcustom/spec/fixtures/sandbox/test/vectors"
|
35
|
+
},
|
36
|
+
"manifest": "/Users/kz/Projects/fontcustom/spec/fixtures/sandbox/test/.fontcustom-manifest-fonts.json",
|
37
|
+
"no_hash": false,
|
38
|
+
"output": {
|
39
|
+
"css": "/Users/kz/Projects/fontcustom/spec/fixtures/sandbox/test/fontcustom",
|
40
|
+
"fonts": "/Users/kz/Projects/fontcustom/spec/fixtures/sandbox/test/fontcustom",
|
41
|
+
"preview": "/Users/kz/Projects/fontcustom/spec/fixtures/sandbox/test/fontcustom"
|
42
|
+
},
|
43
|
+
"preprocessor_path": null,
|
44
|
+
"project_root": "/Users/kz/Projects/fontcustom/spec/fixtures/sandbox/test",
|
45
|
+
"quiet": true,
|
46
|
+
"templates": [
|
47
|
+
"/Users/kz/Projects/fontcustom/lib/fontcustom/templates/fontcustom.css",
|
48
|
+
"/Users/kz/Projects/fontcustom/lib/fontcustom/templates/fontcustom-preview.html"
|
49
|
+
]
|
50
|
+
},
|
51
|
+
"templates": []
|
17
52
|
}
|
Binary file
|
@@ -0,0 +1,56 @@
|
|
1
|
+
<?xml version="1.0" standalone="no"?>
|
2
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
|
3
|
+
<!--
|
4
|
+
2013-11-10: Created.
|
5
|
+
-->
|
6
|
+
<svg xmlns="http://www.w3.org/2000/svg">
|
7
|
+
<metadata>
|
8
|
+
Created by FontForge 20120731 at Sun Nov 10 12:45:07 2013
|
9
|
+
By Kai Zau
|
10
|
+
Created by Kai Zau with FontForge 2.0 (http://fontforge.sf.net)
|
11
|
+
</metadata>
|
12
|
+
<defs>
|
13
|
+
<font id="fontcustom" horiz-adv-x="512" >
|
14
|
+
<font-face
|
15
|
+
font-family="fontcustom"
|
16
|
+
font-weight="500"
|
17
|
+
font-stretch="normal"
|
18
|
+
units-per-em="512"
|
19
|
+
panose-1="2 0 6 9 0 0 0 0 0 0"
|
20
|
+
ascent="448"
|
21
|
+
descent="-64"
|
22
|
+
bbox="0 -64 513.92 448"
|
23
|
+
underline-thickness="25.6"
|
24
|
+
underline-position="-51.2"
|
25
|
+
unicode-range="U+F100-F102"
|
26
|
+
/>
|
27
|
+
<missing-glyph />
|
28
|
+
<glyph glyph-name="uniF100" unicode=""
|
29
|
+
d="M496.112 255.934c-3.53223 0 -6.81934 1.03906 -9.58398 2.81543l-50.8467 -43.3096l54.9375 -76.9023c0.15332 0.00976562 0.306641 0.0253906 0.460938 0.0253906c5.75977 0 10.4346 -4.66895 10.4346 -10.4297c0 -5.75977 -4.66992 -10.4287 -10.4297 -10.4287
|
30
|
+
s-10.4189 4.66895 -10.4189 10.4287c0 1.35156 0.276367 2.63672 0.74707 3.81445l-57.2363 80.1543l-68.2598 40.1816c-2.20703 -2.04785 -2.62695 -3.61523 -7.74707 -4.49609v-90.5977c15.3604 -2.64746 23.8643 -14.6533 23.8643 -29.0664
|
31
|
+
c0 -5.73438 -1.74512 -11.0752 -4.57227 -15.6162l34.873 -32.374c2.6875 2.02246 6.02051 3.23145 9.64062 3.23145c8.87793 0 16.0713 -7.19922 16.0713 -16.0723c0 -8.88281 -7.19336 -16.0762 -16.0713 -16.0762s-16.0771 7.19824 -16.0771 16.0762
|
32
|
+
c0 1.04492 0.108398 2.06836 0.302734 3.05664l-36.4551 33.8486c-4.89453 -3.56836 -10.9053 -5.7041 -17.4229 -5.7041c-11.2949 0 -21.1045 6.32324 -26.1064 15.6162l-81.4902 -25.2061c-2.59082 -10.2344 -11.8379 -17.8271 -22.8916 -17.8271
|
33
|
+
c-13.0664 0 -23.6387 10.5928 -23.6387 23.6387c0 2.97461 0.69043 5.77051 1.70996 8.40234l-35.8047 25.5537c-6.41992 -6.375 -15.2627 -10.3223 -25.001 -10.3223c-5.29883 0 -10.3066 1.19824 -14.8174 3.28223l-3.63477 -4.49023l-27.4639 -40.4688
|
34
|
+
c1.22852 -2.05273 1.94531 -4.44922 1.94531 -7.01465c0 -7.57227 -6.13867 -13.7109 -13.7109 -13.7109s-13.7109 6.13867 -13.7109 13.7109c0 7.57812 6.13867 13.7119 13.7109 13.7119c0.839844 0 1.65332 -0.0869141 2.44727 -0.225586l30.582 45.0664
|
35
|
+
c-0.0205078 0.0205078 -0.0410156 0.0458984 -0.0615234 0.0712891l0.0869141 0.0673828c-6.66602 6.44531 -10.8291 15.4668 -10.8291 25.4717c0 1.84863 0.276367 3.62012 0.553711 5.40137l-0.287109 0.0976562
|
36
|
+
c0.0302734 0.0615234 0.0507812 0.123047 0.0771484 0.189453l-60.0225 27.2842c-3.36914 -3.69629 -8.20703 -6.02637 -13.6035 -6.02637c-10.1836 0 -18.4375 8.25391 -18.4375 18.4375s8.25391 18.4365 18.4375 18.4365s18.4375 -8.25293 18.4375 -18.4365
|
37
|
+
c0 -0.707031 -0.046875 -1.4082 -0.128906 -2.09473l58.7676 -26.7051c0.00488281 0.0605469 0.0205078 0.117188 0.0253906 0.178711l0.492188 -0.164062c5.97461 11.1768 17.6123 18.8623 31.1396 18.8623c7.66504 0 14.6787 -2.47266 20.4951 -6.625l42.1533 42.1729
|
38
|
+
c-2.05371 3.50781 -3.55371 7.36328 -3.55371 11.7256c0 4.25977 1.1416 8.24316 3.1084 11.6934l-75.1719 33.6689c-4.04492 -4.98145 -10.21 -8.1709 -17.1318 -8.1709c-12.1855 0 -22.0615 9.87598 -22.0615 22.0615s9.88086 22.0625 22.0615 22.0625
|
39
|
+
c12.1855 0 22.0625 -9.87695 22.0625 -22.0625c0 -1.20312 -0.123047 -2.375 -0.307617 -3.52734l79.043 -35.4043c3.52734 2.08887 7.63379 3.3125 12.0371 3.3125c1.40234 0 2.76465 -0.148438 4.0957 -0.378906l29.875 63.9385
|
40
|
+
c-2.29883 2.58496 -3.70703 5.98535 -3.70703 9.71777c0 8.08984 6.55859 14.6484 14.6484 14.6484s14.6484 -6.55371 14.6484 -14.6484c0 -1.20898 -0.164062 -2.37598 -0.44043 -3.50195l59.5098 -47.2529c3.30762 2.47266 7.39844 3.95312 11.8477 3.95312
|
41
|
+
c10.9668 0 19.8555 -8.88867 19.8555 -19.8555c0 -1.63867 -0.219727 -3.22559 -0.59375 -4.74609l65.8633 -38.7432l51.9834 44.2822c-0.706055 1.91992 -1.11035 3.9834 -1.11035 6.14453c0 9.83008 7.97168 17.8076 17.8066 17.8076
|
42
|
+
c9.83594 0 17.8076 -7.97754 17.8076 -17.8076c0 -9.83594 -7.97168 -17.8125 -17.8076 -17.8125zM312.679 128.133c0 7.43457 2.75977 14.208 7.27539 19.415l-88.1768 76.3604c-4.18848 -6.60547 -11.5459 -10.9932 -19.9531 -10.9932
|
43
|
+
c-4.36719 0 -8.2168 1.5 -11.7295 3.55371l-42.1533 -42.1738c4.11133 -5.77539 6.60547 -12.8359 6.60547 -20.4746c0 -5.56543 -1.38281 -10.7363 -3.6709 -15.4473l36.0342 -25.7129c4.09082 3.38965 9.16504 5.69922 14.9141 5.69922
|
44
|
+
c10.9678 0 20.1523 -7.47559 22.8252 -17.5879l78.208 24.1875c-0.112305 1.04395 -0.178711 2.09863 -0.178711 3.17383zM337.92 157.199v90.583c-10.2402 2.44238 -14.8223 10.0254 -14.8223 19.0205c0 2.3916 -0.194336 4.6748 0.578125 6.7998l-59.499 47.2529
|
45
|
+
c-2.18164 -1.29102 -4.70508 -2.04297 -7.41895 -2.04297c-0.235352 0 -0.450195 0.0253906 -0.686523 0.0351562l-29.6904 -63.6309c5.57031 -4.32129 9.24707 -11.0645 9.24707 -18.668c0 -0.265625 0.12793 -0.521484 0.117188 -0.788086l94.0029 -81.1318
|
46
|
+
c2.36035 1.17285 3.05176 2.05859 8.17188 2.57031z" />
|
47
|
+
<glyph glyph-name="uniF101" unicode=""
|
48
|
+
d="M256 448c141.399 0 256 -114.601 256 -255.97v-256.03h-512v256.03c0 141.369 114.632 255.97 256 255.97zM494.935 -46.9346v238.965c0 131.733 -107.202 238.899 -238.935 238.899s-238.935 -107.166 -238.935 -238.899v-238.965h477.869zM256 396.8
|
49
|
+
c113.101 0 204.8 -91.6992 204.8 -204.77v-204.83l-153.6 153.6v51.2002c0 28.2676 -22.9326 51.2002 -51.2002 51.2002s-51.2002 -22.9326 -51.2002 -51.2002v-51.2002l-153.6 -153.6v204.83c0 113.07 91.7344 204.77 204.8 204.77z" />
|
50
|
+
<glyph glyph-name="uniF102" unicode=""
|
51
|
+
d="M448 64c35.374 0 64 -28.6924 64 -64s-28.626 -64 -64 -64s-64 28.6924 -64 64c0 8.05859 1.87402 15.626 4.62891 22.748l-96.9375 69.1914c-17.3818 -17.249 -41.3184 -27.9395 -67.6914 -27.9395c-53.002 0 -96 42.998 -96 96c0 5.00195 0.74707 9.80957 1.5 14.6279
|
52
|
+
l-76.626 25.5645c-5.62109 -4.94141 -12.8154 -8.19238 -20.874 -8.19238c-17.6895 0 -32 14.3105 -32 32s14.3105 32 32 32c15.3086 0 27.5 -10.9414 30.623 -25.3135l77.0654 -25.748c16.1846 30.2539 47.6885 51.0615 84.3115 51.0615
|
53
|
+
c20.751 0 39.752 -6.69141 55.501 -17.9404l114.125 114.191c-5.56543 9.49707 -9.62598 19.9375 -9.62598 31.749c0 35.374 28.626 64 64 64s64 -28.626 64 -64s-28.626 -64 -64 -64c-11.8115 0 -22.252 4.06055 -31.7539 9.62598l-114.125 -114.187
|
54
|
+
c11.126 -15.6318 17.874 -34.75 17.874 -55.4395c0 -15.0576 -3.74805 -29.0615 -9.93848 -41.8096l97.5674 -69.6328c11.0645 9.19043 24.8164 15.4424 40.376 15.4424z" />
|
55
|
+
</font>
|
56
|
+
</defs></svg>
|
Binary file
|
Binary file
|
File without changes
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Fontcustom::Base do
|
4
|
+
context "#compile" do
|
5
|
+
context "when [:checksum][:current] equals [:checksum][:previous]" do
|
6
|
+
it "should show 'no change' message" do
|
7
|
+
Fontcustom::Base.any_instance.stub :init_manifest
|
8
|
+
Fontcustom::Base.any_instance.stub :check_fontforge
|
9
|
+
base = Fontcustom::Base.new({})
|
10
|
+
base.stub(:checksum).and_return("abc")
|
11
|
+
base.instance_variable_set :@manifest, {:checksum => {:previous => "abc", :current => ""}}
|
12
|
+
base.instance_variable_set :@options, {:quiet => false}
|
13
|
+
|
14
|
+
output = capture(:stdout) { base.compile }
|
15
|
+
output.should match(/No changes/)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context ".check_fontforge" do
|
21
|
+
it "should raise error if fontforge isn't installed" do
|
22
|
+
Fontcustom::Base.any_instance.stub :init_manifest
|
23
|
+
Fontcustom::Base.any_instance.stub(:"`").and_return("")
|
24
|
+
expect { Fontcustom::Base.new(:option => "foo") }.to raise_error Fontcustom::Error, /fontforge/
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context ".init_manifest" do
|
29
|
+
before(:each) do
|
30
|
+
Fontcustom::Base.any_instance.stub :check_fontforge
|
31
|
+
manifest = double("manifest")
|
32
|
+
manifest.should_receive(:manifest).and_return(manifest_contents)
|
33
|
+
Fontcustom::Manifest.stub(:new).and_return manifest
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should pass CLI options to FC::Options" do
|
37
|
+
opts = double "options"
|
38
|
+
opts.should_receive :options
|
39
|
+
Fontcustom::Options.should_receive(:new).with({:foo => "bar"}).and_return opts
|
40
|
+
Fontcustom::Base.new :foo => "bar"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context ".checksum" do
|
45
|
+
it "should return hash of all vectors and templates" do
|
46
|
+
pending "SHA2 is different on CI servers. Why?"
|
47
|
+
Fontcustom::Base.any_instance.stub :check_fontforge
|
48
|
+
Fontcustom::Base.any_instance.stub :init_manifest
|
49
|
+
base = Fontcustom::Base.new({})
|
50
|
+
base.instance_variable_set :@options, {
|
51
|
+
:input => {:vectors => fixture("shared/vectors")},
|
52
|
+
:templates => Dir.glob(File.join(fixture("shared/templates"), "*"))
|
53
|
+
}
|
54
|
+
hash = base.send :checksum
|
55
|
+
hash.should == "81ffd2f72877be02aad673fdf59c6f9dbfee4cc37ad0b121b9486bc2923b4b36"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "fontcustom/cli"
|
3
|
+
|
4
|
+
describe Fontcustom::CLI do
|
5
|
+
context "#compile" do
|
6
|
+
it "should generate fonts and templates (integration)", :integration => true do
|
7
|
+
live_test do |testdir|
|
8
|
+
Fontcustom::CLI.start ["compile", "vectors", "--quiet"]
|
9
|
+
manifest = File.join testdir, ".fontcustom-manifest.json"
|
10
|
+
Dir.glob(File.join(testdir, "fontcustom", "fontcustom_*\.{ttf,svg,woff,eot}")).length.should == 4
|
11
|
+
File.read(manifest).should match(/"fonts":.+sandbox\/test\/fontcustom\/fontcustom_.+\.ttf"/m)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -1,244 +1,74 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Fontcustom::Generator::Font do
|
4
|
-
|
5
|
-
|
6
|
-
Fontcustom::
|
7
|
-
end
|
8
|
-
|
9
|
-
def generator(options)
|
10
|
-
opts = Fontcustom::Options.new(options)
|
11
|
-
Fontcustom::Generator::Font.new([opts])
|
4
|
+
def generator
|
5
|
+
Fontcustom::Generator::Font.any_instance.stub(:get_manifest).and_return :options => {}
|
6
|
+
Fontcustom::Generator::Font.new("")
|
12
7
|
end
|
13
8
|
|
14
|
-
context "#
|
15
|
-
it "should
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
:
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
gen.should_receive(:empty_directory).with(fixture("create-me"), anything)
|
24
|
-
gen.prepare_output_dirs
|
9
|
+
context "#generate" do
|
10
|
+
it "should set manifest[:glyphs] (integration)", :integration => true do
|
11
|
+
live_test do |testdir|
|
12
|
+
manifest = test_manifest
|
13
|
+
gen = Fontcustom::Generator::Font.new manifest
|
14
|
+
gen.stub :create_fonts
|
15
|
+
gen.generate
|
16
|
+
File.read(manifest).should match(/"glyphs":.+"c":/m)
|
17
|
+
end
|
25
18
|
end
|
26
19
|
|
27
|
-
it "should
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
}
|
35
|
-
}
|
36
|
-
gen = generator options
|
37
|
-
gen.stub(:empty_directory)
|
38
|
-
gen.should_receive(:empty_directory).twice
|
39
|
-
gen.prepare_output_dirs
|
20
|
+
it "should generate fonts (integration)", :integration => true do
|
21
|
+
live_test do |testdir|
|
22
|
+
manifest = test_manifest
|
23
|
+
Fontcustom::Generator::Font.new(manifest).generate
|
24
|
+
Dir.glob(File.join(testdir, "fontcustom", "fontcustom_*\.{ttf,svg,woff,eot}")).length.should == 4
|
25
|
+
File.read(manifest).should match(/"fonts":.+sandbox\/test\/fontcustom\/fontcustom_.+\.ttf"/m)
|
26
|
+
end
|
40
27
|
end
|
41
28
|
end
|
42
29
|
|
43
|
-
context "
|
44
|
-
it "should
|
45
|
-
|
46
|
-
:project_root => fixture,
|
47
|
-
:input => "shared/vectors",
|
48
|
-
:quiet => true
|
49
|
-
}
|
50
|
-
gen = generator options
|
51
|
-
gen.get_manifest
|
52
|
-
data = gen.instance_variable_get("@data")
|
53
|
-
data.should == Fontcustom::DATA_MODEL
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should assign @data from data file" do
|
57
|
-
options = {
|
58
|
-
:project_root => fixture,
|
59
|
-
:config => "generators",
|
60
|
-
:input => "shared/vectors",
|
61
|
-
:output => "mixed-output",
|
62
|
-
:quiet => true
|
63
|
-
}
|
64
|
-
gen = generator options
|
65
|
-
gen.get_manifest
|
66
|
-
data = gen.instance_variable_get("@data")
|
67
|
-
data.should_not == Fontcustom::DATA_MODEL
|
68
|
-
end
|
69
|
-
|
70
|
-
it "should throw an error if the data file is corrupted." do
|
30
|
+
context ".create_output_dirs" do
|
31
|
+
it "should create empty dirs if they don't exist" do
|
32
|
+
gen = generator
|
71
33
|
options = {
|
72
|
-
:
|
73
|
-
:config => "generators",
|
74
|
-
:manifest => "generators/.fontcustom-manifest-corrupted.json",
|
75
|
-
:input => "shared/vectors",
|
76
|
-
:output => "mixed-output",
|
34
|
+
:output => {:fonts => "path/fonts", :vectors => "path/vectors"},
|
77
35
|
:quiet => true
|
78
36
|
}
|
79
|
-
gen
|
80
|
-
|
37
|
+
gen.instance_variable_set :@options, options
|
38
|
+
gen.should_receive(:empty_directory).with("path/fonts", :verbose => false)
|
39
|
+
gen.should_receive(:empty_directory).with("path/vectors", :verbose => false)
|
40
|
+
gen.send :create_output_dirs
|
81
41
|
end
|
82
42
|
end
|
83
43
|
|
84
|
-
context "
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
:output => "mixed-output",
|
90
|
-
:quiet => true
|
91
|
-
}
|
92
|
-
gen = generator options
|
93
|
-
gen.stub :remove_file
|
94
|
-
gen.stub :overwrite_file
|
95
|
-
gen.instance_variable_set(:@data, data_file_contents)
|
96
|
-
gen
|
97
|
-
end
|
98
|
-
|
99
|
-
it "should delete fonts from @data[:fonts]" do
|
100
|
-
subject.should_receive(:remove_file).exactly(4).times.with(/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e/, anything)
|
101
|
-
subject.reset_output
|
102
|
-
end
|
44
|
+
context ".set_glyph_info" do
|
45
|
+
it "should set :glyphs in manifest" do
|
46
|
+
gen = generator
|
47
|
+
gen.instance_variable_set :@options, :input => {:vectors => fixture("shared/vectors")}
|
48
|
+
gen.instance_variable_set :@manifest, :glyphs => {}
|
103
49
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
50
|
+
gen.should_receive(:save_manifest)
|
51
|
+
gen.send :set_glyph_info
|
52
|
+
manifest = gen.instance_variable_get(:@manifest)
|
53
|
+
manifest[:glyphs][:"a_r3ally-exotic-f1le-name"].should include(:codepoint => 61696)
|
54
|
+
manifest[:glyphs][:c].should include(:codepoint => 61697)
|
55
|
+
manifest[:glyphs][:d].should include(:codepoint => 61698)
|
109
56
|
end
|
110
57
|
|
111
|
-
it "should
|
112
|
-
|
113
|
-
|
114
|
-
|
58
|
+
it "should not change codepoints of existing glyphs" do
|
59
|
+
gen = generator
|
60
|
+
gen.instance_variable_set :@options, :input => {:vectors => fixture("shared/vectors")}
|
61
|
+
gen.instance_variable_set :@manifest, :glyphs => {:c => {:source => "foo", :codepoint => 61699}}
|
115
62
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
it "should be silent" do
|
123
|
-
stdout = capture(:stdout) { subject.reset_output }
|
124
|
-
stdout.should == ""
|
63
|
+
gen.should_receive(:save_manifest)
|
64
|
+
gen.send :set_glyph_info
|
65
|
+
manifest = gen.instance_variable_get(:@manifest)
|
66
|
+
manifest[:glyphs][:"a_r3ally-exotic-f1le-name"].should include(:codepoint => 61700)
|
67
|
+
manifest[:glyphs][:c].should include(:codepoint => 61699)
|
68
|
+
manifest[:glyphs][:d].should include(:codepoint => 61701)
|
125
69
|
end
|
126
70
|
end
|
127
71
|
|
128
|
-
context "
|
129
|
-
|
130
|
-
gen = generator(
|
131
|
-
:project_root => fixture,
|
132
|
-
:input => "shared/vectors",
|
133
|
-
:output => "mixed-output",
|
134
|
-
:quiet => true
|
135
|
-
)
|
136
|
-
gen.stub(:execute_and_clean).and_return [fontforge_stdout.split("\n"), fontforge_stderr, double(:status, :success? => true)]
|
137
|
-
gen
|
138
|
-
end
|
139
|
-
|
140
|
-
it "should call fontforge" do
|
141
|
-
subject.should_receive(:execute_and_clean).with(/fontforge -script/)
|
142
|
-
subject.generate
|
143
|
-
end
|
144
|
-
|
145
|
-
it "should pass options to fontforge" do
|
146
|
-
subject.should_receive(:execute_and_clean).with(/#{fixture("shared/vectors")}.+#{fixture("mixed-output")}/)
|
147
|
-
subject.generate
|
148
|
-
end
|
149
|
-
|
150
|
-
it "should assign @json" do
|
151
|
-
subject.generate
|
152
|
-
json = subject.instance_variable_get(:@json)
|
153
|
-
json.should == data_file_contents.to_json
|
154
|
-
end
|
155
|
-
|
156
|
-
it "should raise error if fontforge fails" do
|
157
|
-
gen = generator(
|
158
|
-
:project_root => fixture,
|
159
|
-
:input => "shared/vectors",
|
160
|
-
:output => "fake-dir-should-cause-failure",
|
161
|
-
:debug => true
|
162
|
-
)
|
163
|
-
expect { capture(:stdout) { gen.generate } }.to raise_error Fontcustom::Error, /failed/
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
context "#collect_data" do
|
168
|
-
it "should assign @data from @json" do
|
169
|
-
gen = generator(
|
170
|
-
:project_root => fixture,
|
171
|
-
:input => "shared/vectors",
|
172
|
-
:output => "output"
|
173
|
-
)
|
174
|
-
gen.instance_variable_set(:@data, Fontcustom::DATA_MODEL)
|
175
|
-
gen.instance_variable_set(:@json, data_file_contents.to_json)
|
176
|
-
gen.collect_data
|
177
|
-
data = gen.instance_variable_get(:@data)
|
178
|
-
data[:glyphs].should =~ ["c", "d", "a_r3ally-exotic-f1le-name"]
|
179
|
-
data[:fonts].should =~ [
|
180
|
-
fixture("output/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.eot"),
|
181
|
-
fixture("output/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.svg"),
|
182
|
-
fixture("output/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.ttf"),
|
183
|
-
fixture("output/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.woff")
|
184
|
-
]
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
context "#announce_files" do
|
189
|
-
it "should print generated files to console" do
|
190
|
-
gen = generator(
|
191
|
-
:project_root => fixture,
|
192
|
-
:input => "shared/vectors",
|
193
|
-
:output => "output"
|
194
|
-
)
|
195
|
-
gen.instance_variable_set :@data, data_file_contents
|
196
|
-
stdout = capture(:stdout) { gen.announce_files }
|
197
|
-
stdout.should =~ /create.+\.(woff|ttf|eot|svg)/
|
198
|
-
end
|
199
|
-
|
200
|
-
it "should print nothing if :quiet is set" do
|
201
|
-
gen = generator(
|
202
|
-
:project_root => fixture,
|
203
|
-
:input => "shared/vectors",
|
204
|
-
:output => "output",
|
205
|
-
:quiet => true
|
206
|
-
)
|
207
|
-
gen.instance_variable_set :@data, data_file_contents
|
208
|
-
stdout = capture(:stdout) { gen.announce_files }
|
209
|
-
stdout.should == ""
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
context "#save_data" do
|
214
|
-
it "should update data file" do
|
215
|
-
gen = generator(
|
216
|
-
:project_root => fixture,
|
217
|
-
:input => "shared/vectors",
|
218
|
-
:output => "output"
|
219
|
-
)
|
220
|
-
gen.stub :overwrite_file
|
221
|
-
gen.instance_variable_set(:@data, data_file_contents)
|
222
|
-
file = File.join fixture(".fontcustom-manifest.json")
|
223
|
-
gen.should_receive(:overwrite_file).once.with do |path, content|
|
224
|
-
path.should == file
|
225
|
-
content.should match(/"fonts":/)
|
226
|
-
content.should match(/"glyphs":/)
|
227
|
-
end
|
228
|
-
gen.save_data
|
229
|
-
end
|
230
|
-
|
231
|
-
it "should be silent if :quiet is set" do
|
232
|
-
gen = generator(
|
233
|
-
:project_root => fixture,
|
234
|
-
:input => "shared/vectors",
|
235
|
-
:output => "output",
|
236
|
-
:quiet => true
|
237
|
-
)
|
238
|
-
gen.stub :overwrite_file
|
239
|
-
gen.instance_variable_set(:@data, data_file_contents)
|
240
|
-
stdout = capture(:stdout) { gen.save_data }
|
241
|
-
stdout.should == ""
|
242
|
-
end
|
243
|
-
end
|
72
|
+
#context ".run_fontforge" do
|
73
|
+
#end
|
244
74
|
end
|