fontcustom 1.1.0.pre2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50485d013861fa91e2ae86ed2741630ad3b285ff
4
- data.tar.gz: 5b30887bf48000f2faf726c1995fea6f2bcb9ba8
3
+ metadata.gz: 3c910ad06fd6a63497415cf449da20e6c72f3471
4
+ data.tar.gz: 85b86e23d8aed1278bacede23d4f9c8980408df6
5
5
  SHA512:
6
- metadata.gz: ac4e3f33a7748d4884995e8bdd3725dfb71bc51c1642ebd4d57fd1c9a2ac695c6b1775c73d276aec5b973bbd4316c0bf2b304a5f5939ce3cc798b57dfb36af5e
7
- data.tar.gz: a768dd51e28c43b2f3634ecb0b082edde1510a34f563c1598a4ee9add5e8708ab2141d867284c99759ee8628e8d47bff2190572932fcbe6e3d3611fbbc9f36e4
6
+ metadata.gz: 4e82e218abb14391f1c9c3f95e4da315417052ca6675604dbdc50eae9bac0df27c1d543131023d796db1a53b892d135b5854ad7e0bcc4cadc6e3baf3e8f4e98f
7
+ data.tar.gz: 7b73f06d71838bdb39064a1f8fdc628db26a99056150e363e105e1d308fbca274c5c14add4ee9855ac51885d41508c0bd3689710298650d68673c05ba6691087
data/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## 1.1.0 (9/22/2013)
2
+
3
+ More customizable interface for vastly improved workflow.
4
+
5
+ * Specify where input vectors/templates are stored ([#89](https://github.com/FontCustom/fontcustom/issues/89))
6
+ * Specify where output fonts/templates are saved ([#89](https://github.com/FontCustom/fontcustom/issues/89))
7
+ * Stock templates are saved as `#{font_name}.css` instead of `_fontcustom.css`
8
+ * More robust path handling (relative paths, customizable `project_root`)
9
+ * User-friendly variables for usage in custom templates
10
+ * Rails-friendly template
11
+ * Enable HTML data-attributes usage ([#118](https://github.com/FontCustom/fontcustom/pull/118))
12
+ * Helper characters in preview ([#107](https://github.com/FontCustom/fontcustom/pull/107))
13
+ * More robust execution of fontforge command ([#114](https://github.com/FontCustom/fontcustom/pull/114))
14
+ * Allow captial letters in font names ([#92](https://github.com/FontCustom/fontcustom/issues/92))
15
+ * More helpful, colorful messages
16
+ * More intuitive flags (`--verbose=false` => `--quiet`, `--file-hash=false` => `--no-hash`)
17
+ * More intuitive version (`fontcustom version` => `fontcustom --version`) ([#115](https://github.com/FontCustom/fontcustom/issues/115))
18
+
1
19
  ## 1.0.1 (7/21/2013)
2
20
 
3
21
  Various bugfixes.
data/CONTRIBUTING.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Contributor Guidelines
2
2
 
3
- Thanks for helping make Font Custom better. This project was born out of an over-heard conversation between two devs in a coffee shop — it's come a long ways thanks to the support of folks like you.
3
+ Thanks for helping make Font Custom better. This project was born out of an overheard conversation between two devs in a NYC coffee shop — it's come a long ways thanks to the support of folks like you.
4
4
 
5
5
  ## Conventions
6
6
 
@@ -11,8 +11,7 @@ If you catch a typo or a particularly unsightly piece of code — please _do_ le
11
11
  ## Process
12
12
 
13
13
  * Visit [issues](https://github.com/FontCustom/fontcustom/issues) for ideas.
14
- * Fork the repo if you haven't done so already.
15
- * `master` == current stable release
14
+ * Fork the repo.
16
15
  * Create a topic branch. `git checkout -b my_sweet_feature`
17
16
  * Add your tests. Run tests with `rake`.
18
17
  * Develop your feature.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # FontCustom v1.0.1
1
+ # FontCustom v1.1.0
2
2
 
3
- **Generate custom icon webfonts from the comfort of the command line.**
3
+ **Generate icon webfonts from the comfort of the command line.**
4
4
 
5
5
  [Full documentation](http://fontcustom.com)<br/>
6
6
  [Changelog](https://github.com/FontCustom/fontcustom/blob/master/CHANGELOG.md)<br/>
@@ -17,21 +17,46 @@ gem install fontcustom
17
17
  ## Quick Start
18
18
 
19
19
  ```sh
20
- fontcustom compile path/to/vectors # Compiles into `fontcustom`
21
- fontcustom compile path/to/vectors -o assets/fonts # Compiles into `assets/fonts`
22
- fontcustom watch path/to/vectors -t=scss preview # Compiles when vectors are changed/added/deleted
23
- # and includes a scss partial and glyph preview
20
+ fontcustom compile path/to/vectors # Compiles icons into `fontcustom/`
21
+ fontcustom watch path/to/vectors # Compiles when vectors are changed/added/removed
24
22
 
25
- fontcustom help # to see all options
23
+ fontcustom compile # Uses configuration options from `fontcustom.yml`
24
+ fontcustom watch # or `config/fontcustom.yml`
25
+
26
+ fontcustom help # See all options
26
27
  ```
27
28
 
28
- ## Config
29
+ ## Configuration
29
30
 
30
- To avoid finger-fatigue, include a fontcustom.yml configuration file with your vectors:
31
+ To avoid finger-fatigue, create a configuration file with `fontcustom config`. Typically, this should live in the directory where you plan on running `fontcustom` commands.
31
32
 
32
- ```sh
33
- fontcustom config path/to/vectors # Creates annotated config file
34
- vim path/to/vectors/fontcustom.yml # Edit your fontcustom options
33
+ ```yml
34
+ # Available Options (defaults shown)
35
+ font_name: fontcustom # Names the font (also sets name and directory of generated files)
36
+ project_root: (working dir) # Context for all relative paths
37
+ input: (project_root) # Where vectors and templates are located
38
+ output: (project_root)/(font name) # Where generated files will be saved
39
+ file_hash: true # Include an asset-busting hash
40
+ css_prefix: icon- # CSS class prefix
41
+ preprocessor_path: "" # Font path used in CSS proprocessor templates
42
+ data_cache: (same as fontcustom.yml) # Sets location of data file
43
+ debug: false # Output raw messages from fontforge
44
+ verbose: true # Set to false to silence
45
+ templates: [ css, preview ] # Templates to generate alongside fonts
46
+ # Possible values: preview, css, scss, scss-rails, bootstrap,
47
+ # bootstrap-scss, bootstrap-ie7, bootstrap-ie7-scss
48
+
49
+ # Advanced input/output
50
+ # Set input or output as a hash for more control
51
+ input:
52
+ vectors: path/to/vectors # required
53
+ templates: path/to/templates
54
+
55
+ output:
56
+ fonts: app/assets/fonts # required
57
+ css: app/assets/stylesheets
58
+ preview: app/views/styleguide
59
+ custom-template.yml: custom/path # set paths of custom templates by referencing their file name
35
60
  ```
36
61
 
37
62
  ---
data/Rakefile CHANGED
@@ -1,8 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
- require 'rspec/core/rake_task'
2
+ require "rspec/core/rake_task"
3
3
 
4
- RSpec::Core::RakeTask.new 'spec' do |s|
5
- s.rspec_opts = '--color --format documentation'
4
+ RSpec::Core::RakeTask.new "spec" do |s|
5
+ s.rspec_opts = "--color --format documentation"
6
6
  end
7
7
 
8
8
  task :default => :spec
data/fontcustom.gemspec CHANGED
@@ -1,27 +1,28 @@
1
1
  # -*- encoding: utf-8 -*-
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'fontcustom/version'
4
+ require "fontcustom/version"
5
5
 
6
6
  Gem::Specification.new do |gem|
7
7
  gem.name = "fontcustom"
8
8
  gem.version = Fontcustom::VERSION
9
9
  gem.authors = ["Kai Zau", "Joshua Gross"]
10
10
  gem.email = ["kai@kaizau.com", "joshua@gross.is"]
11
- gem.summary = %q{Generate custom icon webfonts from the comfort of the command line.}
12
- gem.description = %q{Transforms EPS and SVG vectors into icon webfonts. Generates CSS (or any custom template) for easy inclusion in your projects.}
11
+ gem.summary = "Generate icon webfonts from the comfort of the command line."
12
+ gem.description = "Transforms EPS and SVG vectors into icon webfonts. Generates CSS or other template files for your projects."
13
13
  gem.homepage = "http://fontcustom.com"
14
+ gem.post_install_message = " >> Thanks for installing Font Custom! Please ensure that fontforge is installed before compiling any icons."
14
15
 
15
16
  gem.files = `git ls-files`.split($/)
16
17
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
19
  gem.require_paths = ["lib"]
19
20
 
20
- gem.add_dependency 'json', '~>1.8.0'
21
- gem.add_dependency 'thor', '~>0.18.1'
22
- gem.add_dependency 'listen', '~>1.2.2'
21
+ gem.add_dependency "json", "~>1.8.0"
22
+ gem.add_dependency "thor", "~>0.18.1"
23
+ gem.add_dependency "listen", "~>1.3.1"
23
24
 
24
- gem.add_development_dependency 'rake'
25
- gem.add_development_dependency 'bundler'
26
- gem.add_development_dependency 'rspec'
25
+ gem.add_development_dependency "rake"
26
+ gem.add_development_dependency "bundler"
27
+ gem.add_development_dependency "rspec"
27
28
  end
data/lib/fontcustom.rb CHANGED
@@ -1,20 +1,19 @@
1
1
  require "fontcustom/version"
2
2
  require "fontcustom/error"
3
- require "fontcustom/options"
4
3
  require "fontcustom/util"
4
+ require "fontcustom/options"
5
5
  require "fontcustom/generator/font"
6
6
  require "fontcustom/generator/template"
7
- require "thor/core_ext/hash_with_indifferent_access"
8
7
 
9
8
  module Fontcustom
10
9
  ##
11
10
  # Clean Ruby API to workaround Thor
12
11
  def compile(options)
13
- opts = Fontcustom::Options.new options
14
- Fontcustom::Generator::Font.start [opts]
15
- Fontcustom::Generator::Template.start [opts]
12
+ opts = Options.new options
13
+ Generator::Font.start [opts]
14
+ Generator::Template.start [opts]
16
15
  rescue Fontcustom::Error => e
17
- puts "ERROR: #{e.message}"
16
+ opts.say_message :error, e.message, :red
18
17
  end
19
18
 
20
19
  def gem_lib
@@ -27,33 +26,30 @@ module Fontcustom
27
26
  # These are used in Thor CLI but overridden when the Options class is built
28
27
  EXAMPLE_OPTIONS = {
29
28
  :project_root => "`pwd`",
30
- :output => "PROJECT_ROOT/FONT_NAME"
29
+ :output => "PROJECT_ROOT/FONT_NAME",
30
+ :config => "PROJECT_ROOT/fontcustom.yml OR PROJECT_ROOT/config/fontcustom.yml",
31
+ :templates => "css preview",
32
+ :data_cache => "CONFIG_DIR/.fontcustom-data OR at PROJECT_ROOT/.fontcustom-data"
31
33
  }
32
34
 
33
- ##
34
- #
35
- DEFAULT_OPTIONS = Thor::CoreExt::HashWithIndifferentAccess.new({
35
+ DEFAULT_OPTIONS = {
36
36
  :project_root => Dir.pwd,
37
37
  :input => nil,
38
38
  :output => nil,
39
39
  :config => nil,
40
- :data_cache => nil,
41
40
  :templates => %w|css preview|,
42
41
  :font_name => "fontcustom",
43
- :file_hash => true,
44
42
  :css_prefix => "icon-",
45
- :preprocessor_path => "",
43
+ :data_cache => nil,
44
+ :preprocessor_path => nil,
45
+ :no_hash => false,
46
46
  :debug => false,
47
- :verbose => true
48
- })
47
+ :quiet => false
48
+ }
49
49
 
50
- DATA_MODEL = Thor::CoreExt::HashWithIndifferentAccess.new({
50
+ DATA_MODEL = {
51
51
  :fonts => [],
52
52
  :templates => [],
53
- :glyphs => [],
54
- :paths => {
55
- :css_to_fonts => "",
56
- :preprocessor_to_fonts => ""
57
- }
58
- })
53
+ :glyphs => []
54
+ }
59
55
  end
@@ -5,52 +5,50 @@ require "fontcustom/watcher"
5
5
 
6
6
  module Fontcustom
7
7
  class CLI < Thor
8
- include Actions
8
+ include Thor::Actions
9
9
 
10
10
  default_task :show_help
11
11
 
12
12
  class_option :project_root, :aliases => "-r", :type => :string,
13
- :desc => "The root context for any relative paths (INPUT, OUTPUT, CONFIG).",
13
+ :desc => "The root context for relative paths (INPUT, OUTPUT, CONFIG).",
14
14
  :default => EXAMPLE_OPTIONS[:project_root]
15
15
 
16
16
  class_option :output, :aliases => "-o", :type => :string,
17
- :desc => "Where generated files are saved. Can be fine-tuned if a configuration file is used.",
17
+ :desc => "Where generated files are saved. Set different locations for different file types via a configuration file.",
18
18
  :default => EXAMPLE_OPTIONS[:output]
19
19
 
20
20
  class_option :config, :aliases => "-c", :type => :string,
21
- :desc => "Optional configuration file. PROJECT_ROOT/fontcustom.yml and PROJECT_ROOT/config/fontcustom.yml are loaded automatically."
22
-
23
- class_option :data_cache, :aliases => "-d", :type => :string,
24
- :desc => "Optional path to `.fontcustom-data`. Used for garbage collection."
21
+ :desc => "Optional path to a configuration file.",
22
+ :default => EXAMPLE_OPTIONS[:config]
25
23
 
26
24
  class_option :templates, :aliases => "-t", :type => :array,
27
- :desc => "Space-delinated array of templates to generate alongside fonts.",
25
+ :desc => "Space-delinated list of templates to generate alongside fonts.",
28
26
  :enum => %w|preview css scss scss-rails bootstrap bootstrap-scss bootstrap-ie7 bootstrap-ie7-scss|,
29
- :default => DEFAULT_OPTIONS[:templates]
27
+ :default => EXAMPLE_OPTIONS[:templates]
30
28
 
31
29
  class_option :font_name, :aliases => "-f", :type => :string,
32
- :desc => "Set the font's name.",
30
+ :desc => "The font's name. Also determines the file names of generated templates.",
33
31
  :default => DEFAULT_OPTIONS[:font_name]
34
32
 
35
33
  class_option :css_prefix, :aliases => "-p", :type => :string,
36
34
  :desc => "Prefix for each glyph's CSS class.",
37
35
  :default => DEFAULT_OPTIONS[:css_prefix]
38
36
 
37
+ class_option :data_cache, :aliases => "-d", :type => :string,
38
+ :desc => "Path to a manifest of generated files. Used for garbage collection.",
39
+ :default => EXAMPLE_OPTIONS[:data_cache]
40
+
39
41
  class_option :preprocessor_path, :aliases => "-s", :type => :string,
40
- :desc => "Special path used in CSS proprocessor templates."
42
+ :desc => "Optional font path for CSS proprocessor templates."
41
43
 
42
- # TODO make this negative (no file hash)
43
- class_option :file_hash, :type => :boolean,
44
- :desc => "Option to generate font files with asset-busting hashes.",
45
- :default => DEFAULT_OPTIONS[:file_hash]
44
+ class_option :no_hash, :aliases => "-h", :type => :boolean,
45
+ :desc => "Generate fonts without asset-busting hashes."
46
46
 
47
- class_option :debug, :type => :boolean,
48
- :desc => "Display debug messages from fontforge.",
49
- :default => DEFAULT_OPTIONS[:debug]
47
+ class_option :debug, :aliases => "-g", :type => :boolean,
48
+ :desc => "Display debugging messages."
50
49
 
51
- class_option :verbose, :type => :boolean,
52
- :desc => "Display verbose messages.",
53
- :default => DEFAULT_OPTIONS[:verbose]
50
+ class_option :quiet, :aliases => "-q", :type => :boolean,
51
+ :desc => "Hide status messages."
54
52
 
55
53
  # Required for Thor::Actions#template
56
54
  def self.source_root
@@ -60,23 +58,24 @@ module Fontcustom
60
58
  desc "compile [INPUT] [OPTIONS]", "Generates webfonts and templates from *.svg and *.eps files in INPUT. Default: `pwd`"
61
59
  def compile(input = nil)
62
60
  opts = options.merge :input => input
63
- opts = Fontcustom::Options.new(opts)
64
- Fontcustom::Generator::Font.start [opts]
65
- Fontcustom::Generator::Template.start [opts]
61
+ opts = Options.new(opts)
62
+ Generator::Font.start [opts]
63
+ Generator::Template.start [opts]
66
64
  rescue Fontcustom::Error => e
67
- say_status :error, e.message
65
+ opts.say_message :error, e.message, :red
68
66
  end
69
67
 
70
68
  desc "watch [INPUT] [OPTIONS]", "Watches INPUT for changes and regenerates files automatically. Ctrl + C to stop. Default: `pwd`"
71
- method_option :skip_first, :type => :boolean,
69
+ method_option :skip_first, :type => :boolean,
72
70
  :desc => "Skip the initial compile upon watching.",
73
71
  :default => false
74
72
  def watch(input = nil)
73
+ say "Font Custom is watching your icons. Press Ctrl + C to stop.", :yellow unless options[:quiet]
75
74
  opts = options.merge :input => input, :skip_first => !! options[:skip_first]
76
- opts = Fontcustom::Options.new(opts)
77
- Fontcustom::Watcher.new(opts).watch
75
+ opts = Options.new(opts)
76
+ Watcher.new(opts).watch
78
77
  rescue Fontcustom::Error => e
79
- say_status :error, e.message
78
+ opts.say_message :error, e.message, :red
80
79
  end
81
80
 
82
81
  desc "config [DIR]", "Generates an annotated configuration file (fontcustom.yml) in DIR. Default: `pwd`"
@@ -88,7 +87,7 @@ module Fontcustom
88
87
  method_option :version, :aliases => "-v", :type => :boolean, :default => false
89
88
  def show_help
90
89
  if options[:version]
91
- puts "fontcustom-#{Fontcustom::VERSION}"
90
+ puts "fontcustom-#{VERSION}"
92
91
  else
93
92
  help
94
93
  end
@@ -1,8 +1,8 @@
1
1
  require "json"
2
+ require "open3"
2
3
  require "thor"
3
4
  require "thor/group"
4
5
  require "thor/actions"
5
- require "thor/core_ext/hash_with_indifferent_access"
6
6
 
7
7
  module Fontcustom
8
8
  module Generator
@@ -18,7 +18,7 @@ module Fontcustom
18
18
  dirs = opts.output.values.uniq
19
19
  dirs.each do |dir|
20
20
  unless File.directory? dir
21
- empty_directory dir, :verbose => opts.verbose
21
+ empty_directory dir, :verbose => ! opts.quiet
22
22
  end
23
23
  end
24
24
  end
@@ -28,9 +28,9 @@ module Fontcustom
28
28
  begin
29
29
  data = File.read opts.data_cache
30
30
  data = JSON.parse(data, :symbolize_names => true) unless data.empty?
31
- @data = data.is_a?(Hash) ? Thor::CoreExt::HashWithIndifferentAccess.new(data) : Fontcustom::DATA_MODEL.dup
32
- rescue JSON::ParserError
33
- raise Fontcustom::Error, "#{opts.data_cache} is corrupted. Fix the JSON or delete the file to start from scratch."
31
+ @data = data.is_a?(Hash) ? symbolize_hash(data) : Fontcustom::DATA_MODEL.dup
32
+ rescue
33
+ raise Fontcustom::Error, "Couldn't parse `#{relative_to_root(opts.data_cache)}`. Delete it to start from scratch. Any previously generated files will need to be deleted manually."
34
34
  end
35
35
  else
36
36
  @data = Fontcustom::DATA_MODEL.dup
@@ -54,38 +54,18 @@ module Fontcustom
54
54
  end
55
55
 
56
56
  def generate
57
- # TODO align option naming conventions with python script
58
- # TODO remove name arg if default is already set in python (or rm from python)
59
- name = opts.font_name ? " --name " + opts.font_name : ""
60
- hash = opts.file_hash ? "" : " --nohash"
61
- cmd = "fontforge -script #{Fontcustom.gem_lib}/scripts/generate.py #{opts.input[:vectors]} #{opts.output[:fonts] + name + hash} 2>&1"
62
-
63
- output = `#{cmd}`.split("\n")
64
- @json = output[3] # JSON
65
-
66
- # fontforge wrongly returns the following error message if only a single glyph.
67
- # We can strip it out and ignore it.
68
- if @json == 'Warning: Font contained no glyphs'
69
- @json = output[4]
70
- output = output[5..-1]
71
- else
72
- @json = output[3]
73
- output = output[4..-1]
74
- end
75
-
76
- if opts.debug
77
- shell.say "DEBUG: (raw output from fontforge)"
78
- shell.say output
79
- end
80
-
81
- unless $?.success?
82
- raise Fontcustom::Error, "Compilation failed unexpectedly. Check your options and try again with --debug get more details."
83
- end
57
+ cmd = "fontforge -script #{Fontcustom.gem_lib}/scripts/generate.py #{opts.input[:vectors]} #{opts.output[:fonts]} --name #{opts.font_name}"
58
+ cmd += " --nohash" if opts.no_hash
59
+ cmd += " --debug" if opts.debug
60
+ output, err, status = execute_and_clean(cmd)
61
+ @json = output.delete_at(0)
62
+ say_status :debug, "#{err}\n#{' ' * 14}#{output}", :red if opts.debug
63
+ raise Fontcustom::Error, "`fontforge` compilation failed. Try again with --debug for more details." unless status.success?
84
64
  end
85
65
 
86
66
  def collect_data
87
- @json = JSON.parse(@json, :symbolize_names => true)
88
- @data.merge! @json
67
+ json = JSON.parse(@json, :symbolize_names => true)
68
+ @data.merge! json
89
69
  @data[:glyphs].map! { |glyph| glyph.gsub(/\W/, "-") }
90
70
  @data[:fonts].map! { |font| File.join(opts.output[:fonts], font) }
91
71
  end
@@ -98,6 +78,15 @@ module Fontcustom
98
78
  json = JSON.pretty_generate @data
99
79
  overwrite_file opts.data_cache, json
100
80
  end
81
+
82
+ private
83
+
84
+ def execute_and_clean cmd
85
+ stdout, stderr, status = Open3::capture3(cmd)
86
+ stdout = stdout.split("\n")
87
+ stdout = stdout[1..-1] if stdout[0] == "CreateAllPyModules()"
88
+ [stdout, stderr, status]
89
+ end
101
90
  end
102
91
  end
103
92
  end