hieroglyph 0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +2 -0
- data/README.md +8 -4
- data/bin/hieroglyph +0 -0
- data/hieroglyph.gemspec +7 -1
- data/lib/hieroglyph.rb +12 -8
- data/lib/hieroglyph/character_sheet.rb +16 -13
- data/lib/hieroglyph/version.rb +1 -1
- data/spec/lib/hieroglyph/character_sheet_spec.rb +49 -0
- data/spec/lib/hieroglyph/font_spec.rb +5 -0
- data/spec/lib/hieroglyph/glyph_spec.rb +5 -0
- data/spec/spec_helper.rb +23 -0
- metadata +60 -7
data/.rspec
ADDED
data/README.md
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
# Hieroglyph
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
Icon fonts are a great way to put sharp, highly-malleable icons onto your website using @font-face. [Chris Coyier thinks they're a good idea](http://css-tricks.com/using-fonts-for-icons/), and you should too.
|
4
|
+
|
5
|
+
Hieroglyph lets you turn a directory of SVG icons into an SVG font, all simple-like.
|
6
|
+
To produce the remaining web filetypes (eot, ttf, woff) run the font file through [Fontsquirrel's generator](http://www.fontsquirrel.com/fontface/generator).
|
7
|
+
|
8
|
+
If rmagick is installed (optional), hieroglyph will also draw a character sheet PNG for you.
|
6
9
|
|
7
10
|
## Installation
|
8
11
|
|
@@ -40,13 +43,14 @@ Using the -e or -v arguments will NOT output a font.
|
|
40
43
|
|
41
44
|
## Thanks
|
42
45
|
|
43
|
-
- [Chris Coyier](http://chriscoyier.net/), for
|
46
|
+
- [Chris Coyier](http://chriscoyier.net/), for bringing attention to the [icon font technique.](http://css-tricks.com/using-fonts-for-icons/)
|
44
47
|
- [Stephen Wyatt Bush](http://stephenwyattbush.com/), for his in-depth [tutorial.](http://blog.stephenwyattbush.com/2012/02/01/making-an-icon-font)
|
45
48
|
- [Jeremy Holland](http://www.jeremypholland.com/), for the [Savage SVG parsing gem.](https://github.com/awebneck/savage)
|
46
49
|
- [Inkscape contributors](https://launchpad.net/inkscape/+topcontributors), who provided the original SVG font tool I used a lot on this project.
|
47
50
|
|
48
51
|
## Todo
|
49
52
|
|
53
|
+
- Tests
|
50
54
|
- Clean up Glyph class. It's crazy!
|
51
55
|
- Parse from EPS _or_ SVG. Not sure if this is doable with available open-source technology.
|
52
56
|
- Use private use unicode symbols, for accessibility reasons:
|
data/bin/hieroglyph
CHANGED
File without changes
|
data/hieroglyph.gemspec
CHANGED
@@ -9,11 +9,17 @@ Gem::Specification.new do |gem|
|
|
9
9
|
gem.homepage = "http://github.com/averyvery/hieroglyph"
|
10
10
|
|
11
11
|
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split($\)
|
12
13
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
-
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
14
|
gem.name = "hieroglyph"
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = Hieroglyph::VERSION
|
17
|
+
|
17
18
|
gem.add_dependency("nokogiri", ">= 0")
|
18
19
|
gem.add_dependency("savage", ">= 0")
|
20
|
+
|
21
|
+
gem.add_development_dependency "rspec"
|
22
|
+
gem.add_development_dependency "mocha"
|
23
|
+
gem.add_development_dependency "bourne"
|
24
|
+
gem.add_development_dependency "rmagick"
|
19
25
|
end
|
data/lib/hieroglyph.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
|
-
|
2
|
-
require '
|
3
|
-
|
1
|
+
RMAGICK_INSTALLED = begin
|
2
|
+
require 'rmagick'
|
3
|
+
true
|
4
|
+
rescue Gem::LoadError
|
5
|
+
false
|
6
|
+
end
|
4
7
|
|
5
8
|
module Hieroglyph
|
6
9
|
|
7
|
-
VERSION = "0.1"
|
10
|
+
VERSION = "0.1.1"
|
8
11
|
|
9
12
|
def self.log(*args)
|
10
13
|
args.each do |arg|
|
@@ -17,9 +20,10 @@ module Hieroglyph
|
|
17
20
|
end
|
18
21
|
|
19
22
|
def self.rmagick_installed?
|
20
|
-
|
21
|
-
rescue Gem::LoadError
|
22
|
-
false
|
23
|
+
::RMAGICK_INSTALLED
|
23
24
|
end
|
24
|
-
|
25
25
|
end
|
26
|
+
|
27
|
+
require 'hieroglyph/glyph'
|
28
|
+
require 'hieroglyph/font'
|
29
|
+
require 'hieroglyph/character_sheet'
|
@@ -1,10 +1,9 @@
|
|
1
1
|
module Hieroglyph
|
2
2
|
|
3
|
-
|
3
|
+
if rmagick_installed?
|
4
|
+
class CharacterSheet
|
4
5
|
|
5
|
-
|
6
|
-
if Hieroglyph.rmagick_installed?
|
7
|
-
require 'rmagick'
|
6
|
+
def initialize(options)
|
8
7
|
@options = options
|
9
8
|
@output_path = File.join(@options[:output_folder], @options[:name]) + "_characters.png"
|
10
9
|
if File.exist? @output_path
|
@@ -12,21 +11,15 @@ module Hieroglyph
|
|
12
11
|
File.delete @output_path
|
13
12
|
end
|
14
13
|
@characters = Magick::ImageList.new
|
15
|
-
else
|
16
|
-
Hieroglyph.log " ImageMagick not installed, skipping character sheet"
|
17
14
|
end
|
18
|
-
end
|
19
15
|
|
20
|
-
|
21
|
-
if Hieroglyph.rmagick_installed?
|
16
|
+
def add(file, name)
|
22
17
|
character = Magick::Image::read(file).first
|
23
18
|
character['Label'] = name
|
24
19
|
@characters.push character
|
25
|
-
end
|
26
|
-
end
|
20
|
+
end
|
27
21
|
|
28
|
-
|
29
|
-
if Hieroglyph.rmagick_installed?
|
22
|
+
def save
|
30
23
|
name = @options[:name]
|
31
24
|
img = @characters.montage do
|
32
25
|
self.background_color = "#ffffff"
|
@@ -41,6 +34,16 @@ module Hieroglyph
|
|
41
34
|
end
|
42
35
|
end
|
43
36
|
|
37
|
+
else
|
38
|
+
# No-op
|
39
|
+
class CharacterSheet
|
40
|
+
def initialize(*)
|
41
|
+
end
|
42
|
+
def add(file, name)
|
43
|
+
end
|
44
|
+
def save
|
45
|
+
end
|
46
|
+
end
|
44
47
|
end
|
45
48
|
|
46
49
|
end
|
data/lib/hieroglyph/version.rb
CHANGED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hieroglyph::CharacterSheet do
|
4
|
+
context "A CharacterSheet" do
|
5
|
+
before :each do
|
6
|
+
@characters = stub(:push)
|
7
|
+
Magick::ImageList.stubs(:new).returns(@characters)
|
8
|
+
|
9
|
+
@character_sheet = Hieroglyph::CharacterSheet.new({:output_folder => '/tmp', :name => 'sheet'})
|
10
|
+
end
|
11
|
+
|
12
|
+
it "adds a file with a given name" do
|
13
|
+
character = stub(:[]=)
|
14
|
+
Magick::Image.stubs(:read).returns([character])
|
15
|
+
|
16
|
+
@character_sheet.add('a file', 'some name')
|
17
|
+
|
18
|
+
Magick::Image.should have_received(:read).with('a file')
|
19
|
+
character.should have_received(:[]=).with('Label', 'some name')
|
20
|
+
@characters.should have_received(:push).with(character)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'saves the files into one image' do
|
24
|
+
image = stub(:write)
|
25
|
+
|
26
|
+
@characters.stubs(:montage).yields.returns(image)
|
27
|
+
|
28
|
+
@character_sheet.stubs(:background_color=)
|
29
|
+
@character_sheet.stubs(:border_width=)
|
30
|
+
@character_sheet.stubs(:border_color=)
|
31
|
+
@character_sheet.stubs(:fill=)
|
32
|
+
@character_sheet.stubs(:geometry=)
|
33
|
+
@character_sheet.stubs(:matte_color=)
|
34
|
+
@character_sheet.stubs(:title=)
|
35
|
+
|
36
|
+
@character_sheet.save
|
37
|
+
|
38
|
+
@character_sheet.should have_received(:background_color=).with("#ffffff")
|
39
|
+
@character_sheet.should have_received(:border_width=).with(20)
|
40
|
+
@character_sheet.should have_received(:border_color=).with("#ffffff")
|
41
|
+
@character_sheet.should have_received(:fill=).with("#000000")
|
42
|
+
@character_sheet.should have_received(:geometry=).with("150x150+10+5")
|
43
|
+
@character_sheet.should have_received(:matte_color=).with("#ffffff")
|
44
|
+
@character_sheet.should have_received(:title=).with('sheet')
|
45
|
+
|
46
|
+
image.should have_received(:write).with('/tmp/sheet_characters.png')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper.rb"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
require 'bundler'
|
8
|
+
Bundler.setup(:test)
|
9
|
+
|
10
|
+
require 'rspec'
|
11
|
+
require 'mocha'
|
12
|
+
require 'bourne'
|
13
|
+
|
14
|
+
require File.expand_path('../../lib/hieroglyph', __FILE__)
|
15
|
+
|
16
|
+
Dir["./spec/support/**/*.rb"].each {|f| require f}
|
17
|
+
|
18
|
+
RSpec.configure do |config|
|
19
|
+
# config.treat_symbols_as_metadata_keys_with_true_values = true
|
20
|
+
# config.run_all_when_everything_filtered = true
|
21
|
+
# config.filter_run :focus
|
22
|
+
config.mock_with :mocha
|
23
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hieroglyph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-24 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
16
|
-
requirement: &
|
16
|
+
requirement: &70178521601540 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70178521601540
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: savage
|
27
|
-
requirement: &
|
27
|
+
requirement: &70178521601040 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,51 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70178521601040
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec
|
38
|
+
requirement: &70178521600660 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70178521600660
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: mocha
|
49
|
+
requirement: &70178521600200 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70178521600200
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: bourne
|
60
|
+
requirement: &70178521599780 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70178521599780
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rmagick
|
71
|
+
requirement: &70178521599360 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70178521599360
|
36
80
|
description: Generate a web-ready SVG font from a directory of SVG icons
|
37
81
|
email:
|
38
82
|
- dougunderscorenelson@gmail.com
|
@@ -42,6 +86,7 @@ extensions: []
|
|
42
86
|
extra_rdoc_files: []
|
43
87
|
files:
|
44
88
|
- .gitignore
|
89
|
+
- .rspec
|
45
90
|
- Gemfile
|
46
91
|
- LICENSE
|
47
92
|
- README.md
|
@@ -60,6 +105,10 @@ files:
|
|
60
105
|
- lib/hieroglyph/font.rb
|
61
106
|
- lib/hieroglyph/glyph.rb
|
62
107
|
- lib/hieroglyph/version.rb
|
108
|
+
- spec/lib/hieroglyph/character_sheet_spec.rb
|
109
|
+
- spec/lib/hieroglyph/font_spec.rb
|
110
|
+
- spec/lib/hieroglyph/glyph_spec.rb
|
111
|
+
- spec/spec_helper.rb
|
63
112
|
homepage: http://github.com/averyvery/hieroglyph
|
64
113
|
licenses: []
|
65
114
|
post_install_message:
|
@@ -84,4 +133,8 @@ rubygems_version: 1.8.15
|
|
84
133
|
signing_key:
|
85
134
|
specification_version: 3
|
86
135
|
summary: Icon font creator
|
87
|
-
test_files:
|
136
|
+
test_files:
|
137
|
+
- spec/lib/hieroglyph/character_sheet_spec.rb
|
138
|
+
- spec/lib/hieroglyph/font_spec.rb
|
139
|
+
- spec/lib/hieroglyph/glyph_spec.rb
|
140
|
+
- spec/spec_helper.rb
|