fontcustom 1.0.1 → 1.1.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/README.md +1 -1
  4. data/TODO.md +6 -0
  5. data/lib/fontcustom.rb +1 -1
  6. data/lib/fontcustom/actions.rb +28 -0
  7. data/lib/fontcustom/cli.rb +16 -15
  8. data/lib/fontcustom/generator/font.rb +31 -35
  9. data/lib/fontcustom/generator/template.rb +49 -34
  10. data/lib/fontcustom/options.rb +17 -11
  11. data/lib/fontcustom/scripts/generate.py +1 -1
  12. data/lib/fontcustom/templates/_fontcustom-bootstrap-ie7.scss +4 -3
  13. data/lib/fontcustom/templates/_fontcustom-bootstrap.scss +9 -14
  14. data/lib/fontcustom/templates/_fontcustom.scss +8 -14
  15. data/lib/fontcustom/templates/fontcustom-bootstrap-ie7.css +3 -2
  16. data/lib/fontcustom/templates/fontcustom-bootstrap.css +9 -8
  17. data/lib/fontcustom/templates/fontcustom-preview.html +2 -3
  18. data/lib/fontcustom/templates/fontcustom.css +7 -7
  19. data/lib/fontcustom/templates/fontcustom.yml +25 -66
  20. data/lib/fontcustom/util.rb +108 -31
  21. data/lib/fontcustom/version.rb +1 -1
  22. data/lib/fontcustom/watcher.rb +24 -8
  23. data/spec/fixtures/{mixed-output → generators}/.fontcustom-data +0 -0
  24. data/spec/fixtures/{mixed-output → generators/mixed-output}/another-font.ttf +0 -0
  25. data/spec/fixtures/{mixed-output → generators/mixed-output}/dont-delete-me.bro +0 -0
  26. data/spec/fixtures/{mixed-output → generators/mixed-output}/fontcustom.css +0 -0
  27. data/spec/fixtures/{mixed-output → generators/mixed-output}/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.eot +0 -0
  28. data/spec/fixtures/{mixed-output → generators/mixed-output}/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.svg +0 -0
  29. data/spec/fixtures/{mixed-output → generators/mixed-output}/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.ttf +0 -0
  30. data/spec/fixtures/{mixed-output → generators/mixed-output}/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.woff +0 -0
  31. data/spec/fixtures/{not-a-dir → shared/not-a-dir} +0 -0
  32. data/spec/fixtures/shared/templates/custom.css +1 -0
  33. data/spec/fixtures/shared/templates/regular.css +1 -0
  34. data/spec/fixtures/{empty → shared/vectors-empty}/no_vectors_here.txt +0 -0
  35. data/spec/fixtures/{vectors → shared/vectors}/C.svg +0 -0
  36. data/spec/fixtures/{vectors → shared/vectors}/D.svg +0 -0
  37. data/spec/fixtures/vectors/a_R3ally-eXotic f1Le Name.svg b/data/spec/fixtures/shared/vectors/a_R3ally-eXotic f1Le → Name.svg +0 -0
  38. data/spec/fixtures/util/config-is-in-dir/fontcustom.yml +1 -0
  39. data/spec/fixtures/util/fontcustom-malformed.yml +1 -0
  40. data/spec/fixtures/{fontcustom.yml → util/fontcustom.yml} +0 -0
  41. data/spec/fixtures/util/rails-like/config/fontcustom.yml +1 -0
  42. data/spec/fontcustom/actions_spec.rb +22 -0
  43. data/spec/fontcustom/generator/font_spec.rb +107 -62
  44. data/spec/fontcustom/generator/template_spec.rb +124 -29
  45. data/spec/fontcustom/util_spec.rb +299 -53
  46. data/spec/fontcustom/watcher_spec.rb +56 -10
  47. data/spec/spec_helper.rb +8 -3
  48. metadata +46 -34
  49. data/spec/fixtures/empty-data/.fontcustom-data +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: efd1bb1c3cf2ffcac93eb4eae10d08a7c21043b5
4
- data.tar.gz: 23dd672e77766afbbbf86c6956dc1b186a773c4a
3
+ metadata.gz: d394a232cd9bca5b67961598fe0696c677241fdf
4
+ data.tar.gz: 33d86584a9255b4a937551c69342718bde7e7134
5
5
  SHA512:
6
- metadata.gz: 616614a6418bf68ed0f8c82290244ac0753612d843be5f7f1d3e986805f8e4eba96672c85288349d1b78cbf8cc74529f2b89e19c31a446171c23a80ee813ea55
7
- data.tar.gz: 0d96d2ac5ad266f077e201420a77992a635e04229353b4f786e106f93d880199f2b0dd02486136dc7d774d7ea1bd8cb4d6e34fc4327ac29f55592fc8580511a6
6
+ metadata.gz: f96ad328c2b67b55eb1379bb362ee42c6e2240a7566976dae7abb615b737da7d6c36d8f1fc23a13d6cb644e65ad8dab5b2d60a5a988c5e5776cc99c37bd0b667
7
+ data.tar.gz: c1126c9542867c77421d60c04afacf87eaa9844747d833e5b6dc74c23a312212dcf846560ed2282efdc0e1ea015706ff1da5f2acbbcaab5fa8e154c05d6b3268
@@ -1,3 +1,11 @@
1
+ ## 1.0.1 (7/21/2013)
2
+
3
+ Various bugfixes.
4
+
5
+ * Set glyph widths automatically ([#95](https://github.com/FontCustom/fontcustom/issues/95))
6
+ * Fixes Ruby 1.8.7 syntax error ([#94](https://github.com/FontCustom/fontcustom/issues/94))
7
+ * More robust fontforge error handling ([#99](https://github.com/FontCustom/fontcustom/issues/99))
8
+
1
9
  ## 1.0.0 (4/18/2013)
2
10
 
3
11
  Big changes, more flexibility, better workflow. Be sure to check out the [docs](http://fontcustom.com) to see how it all ties together.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # FontCustom v1.0.0
1
+ # FontCustom v1.0.1
2
2
 
3
3
  **Generate custom icon webfonts from the comfort of the command line.**
4
4
 
data/TODO.md ADDED
@@ -0,0 +1,6 @@
1
+ ## TODO
2
+
3
+ * `clear_file` and `append_to_file` can probably be combined
4
+ * Handle error through Fontcustom::Actions
5
+ * Messages for improper config, default settings, etc.
6
+ * Colors for thor :say
@@ -2,11 +2,11 @@ require "fontcustom/version"
2
2
  require "fontcustom/options"
3
3
  require "fontcustom/error"
4
4
  require "fontcustom/util"
5
+ require "fontcustom/actions"
5
6
  require "fontcustom/generator/font"
6
7
  require "fontcustom/generator/template"
7
8
 
8
9
  module Fontcustom
9
-
10
10
  ##
11
11
  # Clean Ruby API to workaround Thor
12
12
  def compile(options)
@@ -0,0 +1,28 @@
1
+ require "thor/actions"
2
+ require "thor/shell"
3
+ require "thor/shell/basic"
4
+ require "thor/shell/color"
5
+
6
+ module Fontcustom
7
+ module Actions
8
+ def self.included(base)
9
+ base.send :include, Thor::Actions
10
+ end
11
+
12
+ # TODO Currently not sure how Thor classes inherit `say_status` from Thor::Shell.
13
+ # Using the instance variable as a workaround.
14
+ def say_changed(status, changed)
15
+ return unless opts[:verbose]
16
+ message = changed.map do |file|
17
+ file.gsub!(opts[:project_root], "")
18
+ file = file[1..-1] if file[0] == "/"
19
+ file
20
+ end
21
+ @shell.say_status status, message.join(" ")
22
+ end
23
+
24
+ def clear_file(file)
25
+ File.open(file, "w") {}
26
+ end
27
+ end
28
+ end
@@ -8,23 +8,24 @@ module Fontcustom
8
8
  include Thor::Actions
9
9
 
10
10
  # Actual defaults are stored in Fontcustom::DEFAULT_OPTIONS instead of Thor
11
- class_option :output, :aliases => "-o", :desc => "The output directory (will be created if it doesn't exist). Default: INPUT/fontcustom/"
12
- class_option :config, :aliases => "-c", :desc => "Path to or containing directory of the config file. Default: INPUT/fontcustom.yml"
13
- class_option :templates, :aliases => "-t", :type => :array, :desc => "List of templates to compile alongside fonts. Accepts 'preview css scss bootstrap bootstrap-scss bootstrap-ie7 bootstrap-ie7-scss' or arbitrary paths relative to INPUT or PWD. Default: 'css preview'"
14
- class_option :font_name, :aliases => "-n", :desc => "The font name used in your templates (automatically normalized to lowercase spinal case). Default: 'fontcustom'"
15
- class_option :file_hash, :aliases => "-h", :type => :boolean, :desc => "Generate font files with asset-busting hashes. Default: true"
11
+ class_option :project_root, :aliases => "-r", :desc => "The base directory that all inputs and outputs are relative to. Default: working directory"
12
+ class_option :output, :aliases => "-o", :desc => "The output directory (will be created if it doesn't exist). Default: PROJECT_ROOT/FONT_NAME/"
13
+ class_option :config, :aliases => "-c", :desc => "Path to an optional configuration file. Files at PROJECT_ROOT/fontcustom.yml and PROJECT_ROOT/config/fontcustom.yml are loaded automatically."
14
+ class_option :templates, :aliases => "-t", :type => :array, :desc => "List of templates to compile alongside fonts. Accepts 'preview css scss bootstrap bootstrap-scss bootstrap-ie7 bootstrap-ie7-scss' or custom templates (advanced, run `fontcustom config` and read the example for more details). Default: 'css preview'"
15
+ class_option :font_name, :aliases => "-n", :desc => "The font name used in your templates. Also determines the default OUTPUT directory name. Default: 'fontcustom'"
16
+ class_option :file_hash, :aliases => "-h", :type => :boolean, :desc => "Option to generate font files with asset-busting hashes. Default: true"
16
17
  class_option :css_prefix, :aliases => "-p", :desc => "The prefix for each glyph's CSS class. Default: 'icon-'"
17
- class_option :font_face_path, :alias => "-f", :desc => "The http path used in @font-face declarations. Only used in .scss partials. Default: none"
18
+ class_option :preprocessor_font_path, :alias => "-s", :desc => "The font path passed to CSS preprocessors (used instead of normal paths in preprocessed CSS templates). Default: none"
18
19
  class_option :debug, :aliases => "-d", :type => :boolean, :desc => "Display debug messages from fontforge. Default: false"
19
- class_option :verbose, :aliases => "-v", :type => :boolean, :desc => "Display output messages. Default: true"
20
+ class_option :verbose, :aliases => "-v", :type => :boolean, :desc => "Display verbose messages. Default: true"
20
21
 
21
22
  # Required for Thor::Actions#template
22
23
  def self.source_root
23
24
  File.join Fontcustom::Util.gem_lib_path, "templates"
24
25
  end
25
26
 
26
- desc "compile [INPUT]", "Generates webfonts and CSS from *.svg and *.eps files in INPUT."
27
- def compile(input)
27
+ desc "compile [INPUT] [OPTIONS]", "Generates webfonts and CSS from *.svg and *.eps files in INPUT."
28
+ def compile(input = nil)
28
29
  opts = options.merge :input => input
29
30
  opts = Fontcustom::Util.collect_options opts
30
31
  Fontcustom::Generator::Font.start [opts]
@@ -33,9 +34,9 @@ module Fontcustom
33
34
  puts "ERROR: #{e.message}"
34
35
  end
35
36
 
36
- desc "watch [INPUT]", "Watches INPUT for changes and regenerates webfonts and CSS automatically. Ctrl + C to stop."
37
- method_option :skip_first, :aliases => "-s", :type => :boolean, :desc => "Compile immediately upon watching. Default: false"
38
- def watch(input)
37
+ desc "watch [INPUT] [OPTIONS]", "Watches INPUT for changes and regenerates files automatically. Ctrl + C to stop."
38
+ method_option :skip_first, :aliases => "-s", :type => :boolean, :desc => "Skip the initial compile upon watching. Default: false"
39
+ def watch(input = nil)
39
40
  opts = options.merge :input => input, :skip_first => !! options[:skip_first]
40
41
  opts = Fontcustom::Util.collect_options opts
41
42
  Fontcustom::Watcher.new(opts).watch
@@ -43,9 +44,9 @@ module Fontcustom
43
44
  puts "ERROR: #{e.message}"
44
45
  end
45
46
 
46
- desc "config [INPUT]", "Adds an annotated fontcustom.yml to INPUT (created if it doesn't exists)."
47
- def config(input)
48
- template "fontcustom.yml", File.join(input, "fontcustom.yml")
47
+ desc "config [DIR]", "Adds an annotated fontcustom.yml to DIR. Default: working directory"
48
+ def config(dir = Dir.pwd)
49
+ template "fontcustom.yml", File.join(dir, "fontcustom.yml")
49
50
  end
50
51
 
51
52
  desc "version", "Shows the version information."
@@ -1,59 +1,56 @@
1
1
  require "json"
2
2
  require "thor"
3
3
  require "thor/group"
4
- require "thor/actions"
4
+ require "thor/core_ext/hash_with_indifferent_access"
5
5
 
6
6
  module Fontcustom
7
7
  module Generator
8
8
  class Font < Thor::Group
9
- include Thor::Actions
9
+ include Actions
10
10
 
11
11
  # Instead of passing each option individually we're passing the entire options hash as an argument.
12
12
  # This is DRYier, easier to maintain.
13
13
  argument :opts
14
14
 
15
- def check_input
16
- if ! File.directory? opts[:input]
17
- raise Fontcustom::Error, "#{opts[:input]} doesn't exist or isn't a directory."
18
- elsif Dir[File.join(opts[:input], "*.{svg,eps}")].empty?
19
- raise Fontcustom::Error, "#{opts[:input]} doesn't contain any vectors (*.svg or *.eps files)."
15
+ def prepare_output_dirs
16
+ dirs = opts[:output].values.uniq
17
+ dirs.each do |dir|
18
+ unless File.directory? dir
19
+ empty_directory dir, :verbose => opts[:verbose]
20
+ end
20
21
  end
21
22
  end
22
23
 
23
- def check_output
24
- if File.exists? File.join(opts[:output], ".fontcustom-data")
25
- # Skip ahead, everything is in order
26
- elsif File.exists?(opts[:output]) && ! File.directory?(opts[:output])
27
- raise Fontcustom::Error, "#{opts[:output]} already exists but isn't a directory."
24
+ def get_data
25
+ datafile = File.join opts[:project_root], ".fontcustom-data"
26
+ if File.exists? datafile
27
+ begin
28
+ data = File.read datafile
29
+ data = JSON.parse(data, :symbolize_names => true) unless data.empty?
30
+ @data = data.is_a?(Hash) ? Thor::CoreExt::HashWithIndifferentAccess.new(data) : Fontcustom::DATA_MODEL.dup
31
+ rescue JSON::ParserError
32
+ raise Fontcustom::Error, "The .fontcustom-data file at #{datafile} is corrupted. Fix the JSON or delete the file to start from scratch."
33
+ end
28
34
  else
29
- # creates opts[:output] as well
30
- add_file File.join(opts[:output], ".fontcustom-data"), :verbose => opts[:verbose]
35
+ @data = Fontcustom::DATA_MODEL.dup
31
36
  end
32
37
  end
33
38
 
34
- def get_data
35
- # file has already been verified/created
36
- data = File.read File.join(opts[:output], ".fontcustom-data")
37
- data = JSON.parse(data, :symbolize_names => true) unless data.empty?
38
- @data = data.is_a?(Hash) ? data : Fontcustom::DATA_MODEL.dup
39
- rescue JSON::ParserError
40
- raise Fontcustom::Error, "The .fontcustom-data file in #{opts[:output]} is corrupted. Fix the JSON or delete the file to start from scratch."
41
- end
42
-
43
39
  def reset_output
44
40
  return if @data[:fonts].empty?
45
41
  begin
46
42
  deleted = []
47
43
  @data[:fonts].each do |file|
48
- remove_file File.join(opts[:output], file), :verbose => opts[:verbose]
44
+ remove_file file, :verbose => false
49
45
  deleted << file
50
46
  end
51
47
  ensure
52
48
  @data[:fonts] = @data[:fonts] - deleted
53
49
  json = JSON.pretty_generate @data
54
- file = File.join(opts[:output], ".fontcustom-data")
55
- Fontcustom::Util.clear_file(file)
56
- append_to_file file, json, :verbose => false # clear data file silently
50
+ file = File.join(opts[:project_root], ".fontcustom-data")
51
+ clear_file(file)
52
+ append_to_file file, json, :verbose => false
53
+ say_changed :removed, deleted
57
54
  end
58
55
  end
59
56
 
@@ -62,7 +59,7 @@ module Fontcustom
62
59
  # TODO remove name arg if default is already set in python (or rm from python)
63
60
  name = opts[:font_name] ? " --name " + opts[:font_name] : ""
64
61
  hash = opts[:file_hash] ? "" : " --nohash"
65
- cmd = "fontforge -script #{Fontcustom::Util.gem_lib_path}/scripts/generate.py #{opts[:input]} #{opts[:output] + name + hash} 2>&1"
62
+ cmd = "fontforge -script #{Fontcustom::Util.gem_lib_path}/scripts/generate.py #{opts[:input][:vectors]} #{opts[:output][:fonts] + name + hash} 2>&1"
66
63
 
67
64
  output = `#{cmd}`.split("\n")
68
65
  @json = output[3] # JSON
@@ -87,20 +84,19 @@ module Fontcustom
87
84
  def collect_data
88
85
  @json = JSON.parse(@json, :symbolize_names => true)
89
86
  @data.merge! @json
90
- @data[:glyphs].map! { |glyph| glyph.gsub(/\W/, "-").downcase }
87
+ @data[:glyphs].map! { |glyph| glyph.gsub(/\W/, "-") }
88
+ @data[:fonts].map! { |font| File.join(@opts[:output][:fonts], font) }
91
89
  end
92
90
 
93
91
  def announce_files
94
- if opts[:verbose]
95
- @data[:fonts].each { |file| shell.say_status(:create, File.join(opts[:output], file)) }
96
- end
92
+ say_changed :created, @data[:fonts]
97
93
  end
98
94
 
99
95
  def save_data
100
96
  json = JSON.pretty_generate @data
101
- file = File.join(opts[:output], ".fontcustom-data")
102
- Fontcustom::Util.clear_file(file)
103
- append_to_file file, json, :verbose => opts[:verbose]
97
+ file = File.join(opts[:project_root], ".fontcustom-data")
98
+ clear_file(file)
99
+ append_to_file file, json, :verbose => false
104
100
  end
105
101
  end
106
102
  end
@@ -1,16 +1,16 @@
1
1
  require "json"
2
+ require "pathname"
2
3
  require "thor"
3
4
  require "thor/group"
4
- require "thor/actions"
5
5
 
6
6
  module Fontcustom
7
7
  module Generator
8
8
  class Template < Thor::Group
9
- include Thor::Actions
10
-
11
- # Instead of passing each option individually we're passing the entire options hash as an argument.
9
+ include Actions
10
+
11
+ # Instead of passing each option individually we're passing the entire options hash as an argument.
12
12
  # This is DRYier, easier to maintain.
13
- argument :opts
13
+ argument :opts
14
14
 
15
15
  # Required for Thor::Actions#template
16
16
  def self.source_root
@@ -18,61 +18,76 @@ module Fontcustom
18
18
  end
19
19
 
20
20
  def get_data
21
- data = File.join(opts[:output], ".fontcustom-data")
21
+ data = File.join(opts[:project_root], ".fontcustom-data")
22
22
  if File.exists? data
23
- @data = JSON.parse(File.read(data), :symbolize_names => true)
23
+ @data = JSON.parse(File.read(data), :symbolize_names => true)
24
24
  else
25
- raise Fontcustom::Error, "There's no .fontcustom-data file in #{opts[:output]}. Try again?"
25
+ raise Fontcustom::Error, "There's no .fontcustom-data file in #{opts[:project_root]}. Try again?"
26
26
  end
27
- rescue JSON::ParserError
27
+ rescue JSON::ParserError
28
28
  # Catches both empty and and malformed files
29
- raise Fontcustom::Error, "The .fontcustom-data file in #{opts[:output]} is empty or corrupted. Try deleting the file and running Fontcustom::Generator::Font again to regenerate .fontcustom-data."
30
- end
31
-
32
- def check_templates
33
- if opts[:templates].empty?
34
- raise Fontcustom::Error, "No templates were specified. Check your options and try again?"
35
- end
36
- end
37
-
38
- def update_source_paths
39
- source_paths # assigns @source_paths
40
- @source_paths.unshift(opts[:input], Dir.pwd)
29
+ raise Fontcustom::Error, "The .fontcustom-data file in #{opts[:project_root]} is empty or corrupted. Try deleting the file and running Fontcustom::Generator::Font again to regenerate .fontcustom-data."
41
30
  end
42
31
 
43
32
  def reset_output
44
33
  return if @data[:templates].empty?
45
34
  begin
46
35
  deleted = []
47
- @data[:templates].each do |file|
48
- remove_file File.join(opts[:output], file), :verbose => opts[:verbose]
36
+ @data[:templates].each do |file|
37
+ remove_file file, :verbose => false
49
38
  deleted << file
50
39
  end
51
40
  ensure
52
41
  @data[:templates] = @data[:templates] - deleted
53
42
  json = JSON.pretty_generate @data
54
- file = File.join(opts[:output], ".fontcustom-data")
55
- Fontcustom::Util.clear_file(file)
56
- append_to_file file, json, :verbose => false # clear data file silently
43
+ file = File.join(opts[:project_root], ".fontcustom-data")
44
+ clear_file(file)
45
+ append_to_file file, json, :verbose => false
46
+ say_changed :removed, deleted
47
+ end
48
+ end
49
+
50
+ def make_relative_paths
51
+ name = File.basename @data[:fonts].first, File.extname(@data[:fonts].first)
52
+ fonts = Pathname.new opts[:output][:fonts]
53
+ css = Pathname.new opts[:output][:css]
54
+ preview = Pathname.new opts[:output][:preview]
55
+ @data[:paths][:css_to_fonts] = File.join fonts.relative_path_from(css).to_s, name
56
+ @data[:paths][:preview_to_css] = File.join css.relative_path_from(preview).to_s, "fontcustom.css"
57
+ @data[:paths][:preprocessor_to_fonts] = if opts[:preprocessor_font_path] != ""
58
+ File.join opts[:preprocessor_font_path], name
59
+ else
60
+ @data[:paths][:css_to_fonts]
57
61
  end
58
62
  end
59
63
 
60
64
  def generate
61
65
  @opts = opts # make available to templates
62
- begin
66
+ begin
63
67
  created = []
64
68
  opts[:templates].each do |source|
65
69
  name = File.basename source
66
- destination = File.join opts[:output], name
67
- template source, destination, :verbose => opts[:verbose]
68
- created << name
70
+ ext = File.extname name
71
+ target = if opts[:output].keys.include? name
72
+ File.join opts[:output][name], name
73
+ elsif %w|.css .scss .sass .less .stylus|.include? ext
74
+ File.join opts[:output][:css], name
75
+ elsif name == "fontcustom-preview.html"
76
+ File.join opts[:output][:preview], name
77
+ else
78
+ File.join opts[:output][:fonts], name
79
+ end
80
+
81
+ template source, target, :verbose => false
82
+ created << target
69
83
  end
70
84
  ensure
71
- @data[:templates] = (@data[:templates] + created).uniq # TODO better way of cleaning up templates
85
+ @data[:templates] = (@data[:templates] + created).uniq
72
86
  json = JSON.pretty_generate @data
73
- file = File.join(opts[:output], ".fontcustom-data")
74
- Fontcustom::Util.clear_file(file)
75
- append_to_file file, json, :verbose => opts[:verbose]
87
+ file = File.join(opts[:project_root], ".fontcustom-data")
88
+ clear_file(file)
89
+ append_to_file file, json, :verbose => false
90
+ say_changed :created, created
76
91
  end
77
92
  end
78
93
  end
@@ -1,21 +1,27 @@
1
+ require "thor/core_ext/hash_with_indifferent_access"
2
+
1
3
  module Fontcustom
2
- DEFAULT_OPTIONS = {
3
- :input => Dir.pwd,
4
- :output => false, # used to assign default, if necessary
5
- :config => false,
6
- :templates => %w|css preview|,
4
+ # :output and :config are build from arguments
5
+ DEFAULT_OPTIONS = Thor::CoreExt::HashWithIndifferentAccess.new({
6
+ :project_root => Dir.pwd,
7
+ :input => "",
8
+ :templates => %w|css preview|,
7
9
  :font_name => "fontcustom",
8
10
  :file_hash => true,
9
11
  :css_prefix => "icon-",
10
- :font_face_path => false,
12
+ :preprocessor_font_path => "",
11
13
  :debug => false,
12
14
  :verbose => true
13
- }
15
+ })
14
16
 
15
- DATA_MODEL = {
17
+ DATA_MODEL = Thor::CoreExt::HashWithIndifferentAccess.new({
16
18
  :fonts => [],
17
19
  :templates => [],
18
- :file_name => "",
19
- :glyphs => []
20
- }
20
+ :glyphs => [],
21
+ :paths => {
22
+ :css_to_fonts => "",
23
+ :preprocessor_to_fonts => "",
24
+ :preview_to_css => ""
25
+ }
26
+ })
21
27
  end
@@ -126,4 +126,4 @@ subprocess.call('ttfautohint -s -n ' + fontfile + '.ttf ' + fontfile + '-hinted.
126
126
 
127
127
  # Describe output in JSON
128
128
  outname = os.path.basename(fontfile)
129
- print json.dumps({'fonts': [outname + '.ttf', outname + '.woff', outname + '.eot', outname + '.svg'], 'glyphs': files, 'file_name': outname})
129
+ print json.dumps({'fonts': [outname + '.ttf', outname + '.woff', outname + '.eot', outname + '.svg'], 'glyphs': files})
@@ -1,6 +1,7 @@
1
- /*
2
- * Font Custom: Bootstrap CSS for IE7
3
- */
1
+ //
2
+ // Icon Font: <%= @opts[:font_name] %>
3
+ // Bootstrap IE7 Enabler
4
+ //
4
5
 
5
6
  [class^="<%= @opts[:css_prefix] %>"],
6
7
  [class*=" <%= @opts[:css_prefix] %>"] {
@@ -1,20 +1,15 @@
1
- <%
2
- file_name = if @opts[:font_face_path]
3
- File.join @opts[:font_face_path], @data[:file_name]
4
- else
5
- @data[:file_name]
6
- end
7
- %>/*
8
- * Font Custom: Bootstrap CSS
9
- */
1
+ //
2
+ // Icon Font: <%= @opts[:font_name] %>
3
+ // Bootstrap Override
4
+ //
10
5
 
11
6
  @font-face {
12
7
  font-family: "<%= @opts[:font_name] %>";
13
- src: url("<%= file_name %>.eot");
14
- src: url("<%= file_name %>.eot?#iefix") format("embedded-opentype"),
15
- url("<%= file_name %>.woff") format("woff"),
16
- url("<%= file_name %>.ttf") format("truetype"),
17
- url("<%= file_name %>.svg#<%= @opts[:font_name] %>") format("svg");
8
+ src: url("<%= @data[:paths][:preprocessor_to_fonts] %>.eot");
9
+ src: url("<%= @data[:paths][:preprocessor_to_fonts] %>.eot?#iefix") format("embedded-opentype"),
10
+ url("<%= @data[:paths][:preprocessor_to_fonts] %>.woff") format("woff"),
11
+ url("<%= @data[:paths][:preprocessor_to_fonts] %>.ttf") format("truetype"),
12
+ url("<%= @data[:paths][:preprocessor_to_fonts] %>.svg#<%= @opts[:font_name] %>") format("svg");
18
13
  font-weight: normal;
19
14
  font-style: normal;
20
15
  }