hieroglyph 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +54 -0
- data/Rakefile +2 -0
- data/bin/hieroglyph +5 -0
- data/hieroglyph.gemspec +19 -0
- data/lib/hieroglyph/assets/footer +3 -0
- data/lib/hieroglyph/assets/glyphs/C-checkcircle.svg +10 -0
- data/lib/hieroglyph/assets/glyphs/a-star.svg +20 -0
- data/lib/hieroglyph/assets/glyphs/c-check.svg +8 -0
- data/lib/hieroglyph/assets/glyphs/d-downcaret.svg +8 -0
- data/lib/hieroglyph/assets/header +9 -0
- data/lib/hieroglyph/character_sheet.rb +46 -0
- data/lib/hieroglyph/command_line.rb +60 -0
- data/lib/hieroglyph/font.rb +60 -0
- data/lib/hieroglyph/glyph.rb +90 -0
- data/lib/hieroglyph/version.rb +3 -0
- data/lib/hieroglyph.rb +25 -0
- metadata +87 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Doug Avery
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# Hieroglyph
|
2
|
+
|
3
|
+
Convert a folder full of icons into an SVG icon font, ready for use on the web.
|
4
|
+
To produce the remaining web filetypes (eot, ttf, woff) run the gem through [Fontsquirrel generator](http://www.fontsquirrel.com/fontface/generator).
|
5
|
+
If rmagick is installed (optional), hieroglyph will also create a neat little character sheet.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
gem install hieroglyph
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
Create a directory full of SVG glyphs, and run:
|
14
|
+
|
15
|
+
hieroglyph -n FontName -g path/to/glyphs -o destination/path
|
16
|
+
|
17
|
+
Arguments:
|
18
|
+
|
19
|
+
-n, --name NAME name of the font you want generated (defaults to MyFont)
|
20
|
+
-o, --output OUTPUT_FOLDER where to output the generated font (defaults to current folder)
|
21
|
+
-g, --glyphs GLYPH_FOLDER where to find glyphs to generate from (defaults to "glyphs")
|
22
|
+
-e, --example output set of example glyphs
|
23
|
+
-v, --version display Hieroglyph version
|
24
|
+
-h, --help display this info
|
25
|
+
|
26
|
+
Using the -e or -v arguments will NOT output a font.
|
27
|
+
|
28
|
+
## Making Glyphs
|
29
|
+
|
30
|
+
- In a vector editor (Illustrator, Inkscape), create a 1000pt x 1000pt canvas
|
31
|
+
- Draw your icon as a single compound path
|
32
|
+
- Center it horizontally
|
33
|
+
- Vertically, fit it between ~y288 and ~y1025
|
34
|
+
- Tip: Use Illustrator's Transform palette to set the icon to 737pt high, with a y of 656 and x of 500
|
35
|
+
- Save it as a-[iconname].svg in your glyphs folder, 'a' being the letter you want to map the glyph to. [iconname] can be anything, it's just to help you remember which icon you used.
|
36
|
+
|
37
|
+
## Known Issues
|
38
|
+
|
39
|
+
- If ImageMagick is installed without Ghostscript fonts, the character sheet process will throw an error. The font is still generated correctly, though.
|
40
|
+
|
41
|
+
## Thanks
|
42
|
+
|
43
|
+
- [Chris Coyier](http://chriscoyier.net/), for brining attention to the [icon fonts.](http://css-tricks.com/using-fonts-for-icons/)
|
44
|
+
- [Stephen Wyatt Bush](http://stephenwyattbush.com/), for his in-depth [tutorial.](http://blog.stephenwyattbush.com/2012/02/01/making-an-icon-font)
|
45
|
+
- [Jeremy Holland](http://www.jeremypholland.com/), for the [Savage SVG parsing gem.](https://github.com/awebneck/savage)
|
46
|
+
- [Inkscape contributors](https://launchpad.net/inkscape/+topcontributors), who provided the original SVG font tool I used a lot on this project.
|
47
|
+
|
48
|
+
## Todo
|
49
|
+
|
50
|
+
- Clean up Glyph class. It's crazy!
|
51
|
+
- Parse from EPS _or_ SVG. Not sure if this is doable with available open-source technology.
|
52
|
+
- Use private use unicode symbols, for accessibility reasons:
|
53
|
+
- http://twitter.com/#!/danscotton/statuses/180321697449263106
|
54
|
+
- http://en.wikipedia.org/wiki/Private_Use_(Unicode)
|
data/Rakefile
ADDED
data/bin/hieroglyph
ADDED
data/hieroglyph.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/hieroglyph/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Doug Avery"]
|
6
|
+
gem.email = ["dougunderscorenelson@gmail.com"]
|
7
|
+
gem.description = "Generate a web-ready SVG font from a directory of SVG icons"
|
8
|
+
gem.summary = "Icon font creator"
|
9
|
+
gem.homepage = "http://github.com/averyvery/hieroglyph"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "hieroglyph"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Hieroglyph::VERSION
|
17
|
+
gem.add_dependency("nokogiri", ">= 0")
|
18
|
+
gem.add_dependency("savage", ">= 0")
|
19
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
3
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
4
|
+
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
5
|
+
width="1000px" height="1000px" viewBox="0 0 1000 1000" enable-background="new 0 0 1000 1000" xml:space="preserve">
|
6
|
+
<path fill="#0B0B0B" d="M499.969,287.5c-203.459,0-368.516,164.966-368.516,368.516c0,203.58,164.994,368.484,368.516,368.484
|
7
|
+
c203.584,0,368.578-164.967,368.578-368.484C868.547,452.521,703.553,287.5,499.969,287.5z M442.059,872.52L255.41,680.097
|
8
|
+
l85.249-85.253c0,0,73.045,73.494,101.938,104.123c39.248-39.271,197.062-197.361,216.028-216.293
|
9
|
+
c25.124,25.034,86.683,86.596,86.683,86.596L442.059,872.52z"/>
|
10
|
+
</svg>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
3
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
4
|
+
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
5
|
+
width="1000px" height="1000px" viewBox="0 0 1000 1000" enable-background="new 0 0 1000 1000" xml:space="preserve">
|
6
|
+
<path fill="#050606" d="M859.99,566.467c-7.105-8.475-14.604-11.277-20.729-13.07c-6.258-1.662-11.994-2.117-17.959-2.117
|
7
|
+
l-206.608-0.131c-1.923,0.131-6.355-1.174-10.038-4.041c-3.781-2.805-6.16-6.682-6.584-8.541l-59.842-215.115
|
8
|
+
c-1.988-6.779-4.173-12.906-8.671-19.557c-4.105-5.996-13.135-16.003-29.562-16.395c-16.329,0.326-25.455,10.332-29.562,16.395
|
9
|
+
c-4.498,6.715-6.714,12.843-8.604,19.621L401.99,538.502c-0.393,1.891-2.869,5.801-6.617,8.539
|
10
|
+
c-3.65,2.869-8.083,4.172-10.006,4.105l-206.642,0.066c-7.953,0.129-15.386,0.65-24.381,4.465
|
11
|
+
c-4.433,1.988-9.646,5.051-14.242,10.725c-4.661,5.475-7.855,14.016-7.726,21.674c0.261,12.256,5.41,19.719,9.647,24.902
|
12
|
+
c4.498,5.246,9.19,8.963,14.472,12.449l166.519,109.74c2.968,1.271,8.183,10.496,7.726,16.689c0,1.531-0.195,2.77-0.456,3.717
|
13
|
+
l-64.73,212.117c-1.792,6.127-3.16,12.059-3.227,19.295c0.098,6.061,0.814,13.947,6.941,22.814
|
14
|
+
c5.933,9.125,19.101,14.828,28.097,14.275c17.014-0.912,24.119-7.627,32.527-14.016l162.805-138.619
|
15
|
+
c1.336-1.238,4.726-2.674,8.538-2.674c3.685,0,6.91,1.305,8.246,2.479l171.604,139.76c8.507,6.16,15.481,12.549,32.104,13.461
|
16
|
+
c0.393,0,0.815,0.033,1.206,0.033c8.572,0,20.566-5.184,26.435-13.854c6.258-8.801,7.04-16.816,7.104-22.75
|
17
|
+
c-0.064-7.789-1.598-14.016-3.781-20.631l-72.748-213.455c-0.325-0.912-0.555-2.215-0.555-3.846
|
18
|
+
c-0.424-5.736,4.303-13.949,7.008-15.123L843.53,625.49c5.28-3.488,10.007-7.236,14.505-12.482c4.172-5.217,9.354-12.646,9.583-24.9
|
19
|
+
C867.812,580.48,864.618,571.941,859.99,566.467z"/>
|
20
|
+
</svg>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
3
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
4
|
+
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
5
|
+
width="1000px" height="1000px" viewBox="0 0 1000 1000" enable-background="new 0 0 1000 1000" xml:space="preserve">
|
6
|
+
<path fill="#0B0B0B" d="M442.597,698.967c-28.893-30.629-101.938-104.123-101.938-104.123l-85.249,85.253L442.059,872.52
|
7
|
+
l303.249-303.25c0,0-61.559-61.562-86.683-86.596C639.658,501.605,481.845,659.696,442.597,698.967z"/>
|
8
|
+
</svg>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
3
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
4
|
+
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
5
|
+
width="1000px" height="1000px" viewBox="0 0 1000 1000" enable-background="new 0 0 1000 1000" xml:space="preserve">
|
6
|
+
<polygon fill="#151514" points="745.365,410.643 499.029,656.965 252.729,410.643 131.5,531.97 377.77,778.218 377.759,778.229
|
7
|
+
500.882,901.357 868.5,533.771 "/>
|
8
|
+
</svg>
|
@@ -0,0 +1,9 @@
|
|
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
|
+
<svg xmlns="http://www.w3.org/2000/svg">
|
4
|
+
<defs>
|
5
|
+
<font id="{{NAME}}" horiz-adv-x="1024" >
|
6
|
+
<font-face units-per-em="1024" ascent="819" descent="-205" />
|
7
|
+
<missing-glyph horiz-adv-x="500" />
|
8
|
+
<glyph d="M0 0h1000v1024h-1000v-1024z" />
|
9
|
+
<glyph d="M0 0h1000v1024h-1000v-1024z" />
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Hieroglyph
|
2
|
+
|
3
|
+
class CharacterSheet
|
4
|
+
|
5
|
+
def initialize(options)
|
6
|
+
if Hieroglyph.rmagick_installed?
|
7
|
+
require 'rmagick'
|
8
|
+
@options = options
|
9
|
+
@output_path = File.join(@options[:output_folder], @options[:name]) + "_characters.png"
|
10
|
+
if File.exist? @output_path
|
11
|
+
Hieroglyph.log " #{@output_path} exists, deleting"
|
12
|
+
File.delete @output_path
|
13
|
+
end
|
14
|
+
@characters = Magick::ImageList.new
|
15
|
+
else
|
16
|
+
Hieroglyph.log " ImageMagick not installed, skipping character sheet"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def add(file, name)
|
21
|
+
if Hieroglyph.rmagick_installed?
|
22
|
+
character = Magick::Image::read(file).first
|
23
|
+
character['Label'] = name
|
24
|
+
@characters.push character
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def save
|
29
|
+
if Hieroglyph.rmagick_installed?
|
30
|
+
name = @options[:name]
|
31
|
+
img = @characters.montage do
|
32
|
+
self.background_color = "#ffffff"
|
33
|
+
self.border_width = 20
|
34
|
+
self.border_color = "#ffffff"
|
35
|
+
self.fill = "#000000"
|
36
|
+
self.geometry = "150x150+10+5"
|
37
|
+
self.matte_color = "#ffffff"
|
38
|
+
self.title = name
|
39
|
+
end
|
40
|
+
img.write(@output_path)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require "optparse"
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../hieroglyph')
|
3
|
+
|
4
|
+
module Hieroglyph
|
5
|
+
|
6
|
+
class CommandLine
|
7
|
+
|
8
|
+
BANNER = <<-EOS
|
9
|
+
|
10
|
+
Usage: hieroglyph OPTIONS
|
11
|
+
|
12
|
+
Run hieroglyph to generate an SVG font from a folder of SVG glyphs.
|
13
|
+
|
14
|
+
Options:
|
15
|
+
EOS
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
@execute = true
|
19
|
+
parse_options
|
20
|
+
if @execute
|
21
|
+
Hieroglyph.make @options
|
22
|
+
Hieroglyph.log "", " Saved to #{@options[:output_folder]}", "", "=== #{@options[:name]} generated ===", ""
|
23
|
+
Hieroglyph.log "To create a full set of webfonts, upload to:", "http://www.fontsquirrel.com/fontface/generator", ""
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def parse_options
|
28
|
+
@options = {
|
29
|
+
:name => "MyFont",
|
30
|
+
:output_folder => "./",
|
31
|
+
:glyph_folder => "glyphs"
|
32
|
+
}
|
33
|
+
@option_parser = OptionParser.new do |opts|
|
34
|
+
opts.on("-n", "--name NAME", "name of the font you want generated") do |name|
|
35
|
+
@options[:name] = name
|
36
|
+
end
|
37
|
+
opts.on("-o", "--output OUTPUT_FOLDER", "where to output the generated font") do |output_folder|
|
38
|
+
@options[:output_folder] = output_folder
|
39
|
+
end
|
40
|
+
opts.on("-g", "--glyphs GLYPH_FOLDER", "where to find glyphs to generate from") do |glyph_folder|
|
41
|
+
@options[:glyph_folder] = glyph_folder
|
42
|
+
end
|
43
|
+
opts.on("-e", "--example", "output set of example glyphs") do |output_folder|
|
44
|
+
@execute = false
|
45
|
+
Hieroglyph.log "Example glyphs saved to #{Dir.pwd}/glyphs"
|
46
|
+
glyphs_path = File.join(File.dirname(__FILE__), "assets/glyphs")
|
47
|
+
exec "cp -r #{glyphs_path} ./"
|
48
|
+
end
|
49
|
+
opts.on_tail('-v', '--version', 'display Hieroglyph version') do
|
50
|
+
@execute = false
|
51
|
+
Hieroglyph.log "Hieroglyph version #{Hieroglyph::VERSION}"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
@option_parser.banner = BANNER
|
55
|
+
@option_parser.parse!(ARGV)
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Hieroglyph
|
2
|
+
|
3
|
+
class Font
|
4
|
+
|
5
|
+
def initialize(options)
|
6
|
+
@options = options
|
7
|
+
@output_path = File.join(@options[:output_folder], @options[:name] + ".svg")
|
8
|
+
@contents = ""
|
9
|
+
setup
|
10
|
+
add_glyphs
|
11
|
+
finish
|
12
|
+
end
|
13
|
+
|
14
|
+
def add_header
|
15
|
+
header_path = File.join(File.dirname(__FILE__), "assets/header")
|
16
|
+
header = File.open(header_path).read
|
17
|
+
header.gsub!("{{NAME}}", @options[:name])
|
18
|
+
add header
|
19
|
+
end
|
20
|
+
|
21
|
+
def add_footer
|
22
|
+
footer_path = File.join(File.dirname(__FILE__), "assets/footer")
|
23
|
+
footer = File.open(footer_path).read
|
24
|
+
add footer
|
25
|
+
end
|
26
|
+
|
27
|
+
def setup
|
28
|
+
Hieroglyph.log "", "=== Generating #{@options[:name]} ===", ""
|
29
|
+
if File.exist? @output_path
|
30
|
+
Hieroglyph.log " #{@output_path} exists, deleting"
|
31
|
+
File.delete @output_path
|
32
|
+
end
|
33
|
+
@character_sheet = CharacterSheet.new(@options)
|
34
|
+
add_header
|
35
|
+
end
|
36
|
+
|
37
|
+
def finish
|
38
|
+
add_footer
|
39
|
+
File.open(@output_path, "w") do |file|
|
40
|
+
file.puts @contents
|
41
|
+
file.close
|
42
|
+
end
|
43
|
+
@character_sheet.save
|
44
|
+
end
|
45
|
+
|
46
|
+
def add(str)
|
47
|
+
@contents << str
|
48
|
+
end
|
49
|
+
|
50
|
+
def add_glyphs
|
51
|
+
Hieroglyph.log "", " Reading from #{@options[:glyph_folder]}...", ""
|
52
|
+
Dir.glob(File.join(@options[:glyph_folder], "*.svg")).each do |file|
|
53
|
+
glyph = Glyph.new(file, @options[:glyph_folder])
|
54
|
+
@character_sheet.add(file, glyph.name)
|
55
|
+
add glyph.to_node
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require "nokogiri"
|
2
|
+
require "savage"
|
3
|
+
|
4
|
+
module Hieroglyph
|
5
|
+
|
6
|
+
class Glyph
|
7
|
+
|
8
|
+
attr_accessor :name
|
9
|
+
|
10
|
+
def initialize(file, source)
|
11
|
+
@name = file.gsub(source, "").gsub("/", "").each_char.first
|
12
|
+
Hieroglyph.log " #{@name} -> reading..."
|
13
|
+
@contents = Nokogiri::XML(File.new(file))
|
14
|
+
@polygon = @contents.root.at_css("polygon")
|
15
|
+
@path = @polygon.nil? ? convert_path: convert_polygon
|
16
|
+
flip_paths
|
17
|
+
end
|
18
|
+
|
19
|
+
def flip_paths
|
20
|
+
@path.subpaths.each do |subpath|
|
21
|
+
subpath.directions.each do |direction|
|
22
|
+
case direction
|
23
|
+
when Savage::Directions::MoveTo
|
24
|
+
if(direction.absolute?)
|
25
|
+
direction.target.y = flip_y(direction.target.y)
|
26
|
+
else
|
27
|
+
direction.target.y = -1 * direction.target.y
|
28
|
+
end
|
29
|
+
when Savage::Directions::VerticalTo
|
30
|
+
if(direction.absolute?)
|
31
|
+
direction.target = flip_y(direction.target)
|
32
|
+
else
|
33
|
+
direction.target = -1 * direction.target
|
34
|
+
end
|
35
|
+
when Savage::Directions::LineTo
|
36
|
+
if(direction.absolute?)
|
37
|
+
direction.target.y = flip_y(direction.target.y)
|
38
|
+
else
|
39
|
+
direction.target.y = -1 * direction.target.y
|
40
|
+
end
|
41
|
+
when Savage::Directions::CubicCurveTo
|
42
|
+
if(direction.absolute?)
|
43
|
+
direction.control.y = flip_y(direction.control.y)
|
44
|
+
direction.target.y = flip_y(direction.target.y)
|
45
|
+
if(defined?(direction.control_1) && defined?(direction.control_1.y))
|
46
|
+
direction.control_1.y = flip_y(direction.control_1.y)
|
47
|
+
end
|
48
|
+
else
|
49
|
+
direction.control.y = -1 * direction.control.y
|
50
|
+
direction.target.y = -1 * direction.target.y
|
51
|
+
if(defined?(direction.control_1) && defined?(direction.control_1.y))
|
52
|
+
direction.control_1.y = -1 * direction.control_1.y
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def convert_path
|
61
|
+
@path = @contents.root.at_css("path")["d"]
|
62
|
+
@path = Savage::Parser.parse @path
|
63
|
+
end
|
64
|
+
|
65
|
+
def convert_polygon
|
66
|
+
Hieroglyph.log " -> converting polygon to path"
|
67
|
+
points = @polygon["points"].split(" ")
|
68
|
+
Savage::Path.new do |path|
|
69
|
+
start_position = points.shift.split(",")
|
70
|
+
path.move_to(start_position[0], start_position[1])
|
71
|
+
points.each do |point|
|
72
|
+
position = point.split(",")
|
73
|
+
path.line_to(position[0], position[1])
|
74
|
+
end
|
75
|
+
path.close_path
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def flip_y(value)
|
80
|
+
value = value.to_f
|
81
|
+
value = (value - 500) * -1 + 500
|
82
|
+
end
|
83
|
+
|
84
|
+
def to_node
|
85
|
+
return "<glyph unicode=\"#{@name}\" d=\"#{@path.to_command}\" />\n"
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
data/lib/hieroglyph.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'hieroglyph/glyph'
|
2
|
+
require 'hieroglyph/font'
|
3
|
+
require 'hieroglyph/character_sheet'
|
4
|
+
|
5
|
+
module Hieroglyph
|
6
|
+
|
7
|
+
VERSION = "0.1"
|
8
|
+
|
9
|
+
def self.log(*args)
|
10
|
+
args.each do |arg|
|
11
|
+
puts arg
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.make(options)
|
16
|
+
Font.new(options)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.rmagick_installed?
|
20
|
+
Gem::Specification.find_by_name("rmagick")
|
21
|
+
rescue Gem::LoadError
|
22
|
+
false
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hieroglyph
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Doug Avery
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-19 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: nokogiri
|
16
|
+
requirement: &70103367137480 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70103367137480
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: savage
|
27
|
+
requirement: &70103367136980 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70103367136980
|
36
|
+
description: Generate a web-ready SVG font from a directory of SVG icons
|
37
|
+
email:
|
38
|
+
- dougunderscorenelson@gmail.com
|
39
|
+
executables:
|
40
|
+
- hieroglyph
|
41
|
+
extensions: []
|
42
|
+
extra_rdoc_files: []
|
43
|
+
files:
|
44
|
+
- .gitignore
|
45
|
+
- Gemfile
|
46
|
+
- LICENSE
|
47
|
+
- README.md
|
48
|
+
- Rakefile
|
49
|
+
- bin/hieroglyph
|
50
|
+
- hieroglyph.gemspec
|
51
|
+
- lib/hieroglyph.rb
|
52
|
+
- lib/hieroglyph/assets/footer
|
53
|
+
- lib/hieroglyph/assets/glyphs/C-checkcircle.svg
|
54
|
+
- lib/hieroglyph/assets/glyphs/a-star.svg
|
55
|
+
- lib/hieroglyph/assets/glyphs/c-check.svg
|
56
|
+
- lib/hieroglyph/assets/glyphs/d-downcaret.svg
|
57
|
+
- lib/hieroglyph/assets/header
|
58
|
+
- lib/hieroglyph/character_sheet.rb
|
59
|
+
- lib/hieroglyph/command_line.rb
|
60
|
+
- lib/hieroglyph/font.rb
|
61
|
+
- lib/hieroglyph/glyph.rb
|
62
|
+
- lib/hieroglyph/version.rb
|
63
|
+
homepage: http://github.com/averyvery/hieroglyph
|
64
|
+
licenses: []
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
requirements: []
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 1.8.15
|
84
|
+
signing_key:
|
85
|
+
specification_version: 3
|
86
|
+
summary: Icon font creator
|
87
|
+
test_files: []
|