savage-fontgen 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bin/savage-fontgen +79 -0
- data/lib/generate.py +55 -0
- data/savage-conf/config.yaml +11 -0
- data/savage-conf/templates/preview.html.erb +77 -0
- data/savage-conf/templates/style.css.erb +30 -0
- metadata +79 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ecc612f989d52d5f1cc4ea53d678f468a7a49b72
|
4
|
+
data.tar.gz: 40192fd4acea770530e13165d2e68a15af6e3212
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 280f541aff40e5706850e39d15fa5a383a63f807dc5abedf821e3b2806c627f2837c953f624b62ad6ec2710c1e49344cd96ba6cc46fd1964176e081f7afa1cd0
|
7
|
+
data.tar.gz: aef47213ca798b6345048f337559f560c72eb3c0ae59ba70416b7b6116ac4098467531f0001050529b3930e8ff0671a29fa16fe5f4cf40196878a915ba9d539f
|
data/bin/savage-fontgen
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require 'optparse'
|
5
|
+
require 'colorize'
|
6
|
+
require 'erubis'
|
7
|
+
require 'yaml'
|
8
|
+
|
9
|
+
VERSION = '0.1.0'
|
10
|
+
|
11
|
+
options = {}
|
12
|
+
OptionParser.new do |opts|
|
13
|
+
opts.banner = "Usage: savage-fontgen SOURCE [-o DEST] [options]"
|
14
|
+
|
15
|
+
opts.on "-o DEST", "--out", "output path" do |o| options[:dest_path] = o end
|
16
|
+
|
17
|
+
# ==========================
|
18
|
+
# = Configuration Options: =
|
19
|
+
# ==========================
|
20
|
+
|
21
|
+
opts.separator ""
|
22
|
+
opts.separator "Configuration options:"
|
23
|
+
|
24
|
+
opts.on "-q", "--quiet", "Surpress output" do |o| options[:quiet] = o end
|
25
|
+
|
26
|
+
opts.on "--edit-conf", "Edit vhosts.yml" do |o|
|
27
|
+
system Vhost.conf['editor'], Vhost.conf_file
|
28
|
+
exit
|
29
|
+
end
|
30
|
+
|
31
|
+
# ==================
|
32
|
+
# = Common Options =
|
33
|
+
# ==================
|
34
|
+
|
35
|
+
opts.separator ""
|
36
|
+
opts.separator "Common options:"
|
37
|
+
|
38
|
+
opts.on "-v", "--version", "Print version" do
|
39
|
+
puts "vhost - version #{VERSION}", ""
|
40
|
+
exit
|
41
|
+
end
|
42
|
+
|
43
|
+
opts.on "-h", "--help", "Prints this help" do
|
44
|
+
puts opts
|
45
|
+
exit
|
46
|
+
end
|
47
|
+
|
48
|
+
end.parse!
|
49
|
+
|
50
|
+
# abort "Usage: savage-fontgen source_dir [-o out_path] [options]" if options.empty? and ARGV[0].nil?
|
51
|
+
|
52
|
+
@options = options
|
53
|
+
def puts(*args)
|
54
|
+
super(*args) unless @options[:quiet]
|
55
|
+
end
|
56
|
+
|
57
|
+
@source_path = ARGV[0]
|
58
|
+
@dest_path = options[:dest_path] || './out'
|
59
|
+
@conf_path = 'savage-conf'
|
60
|
+
|
61
|
+
`python lib/generate.py #{@source_path} #{@dest_path} #{File.join(@conf_path, 'config.yaml')}`
|
62
|
+
|
63
|
+
conf = YAML.load_file File.join(@conf_path, 'config.yaml')
|
64
|
+
glyphs = YAML.load_file File.join(@dest_path, 'glyphs.yaml')
|
65
|
+
nocache = Time.now.to_i.to_s
|
66
|
+
|
67
|
+
glyphs.each do |name, unicode|
|
68
|
+
puts "#{name} => #{unicode.to_s(16)}"
|
69
|
+
end
|
70
|
+
|
71
|
+
File.open File.join(@dest_path, "#{conf["familyname"]}.css"), "w" do |f|
|
72
|
+
template = Erubis::Eruby.new File.read(File.join(@conf_path, "templates/style.css.erb"))
|
73
|
+
f.write template.result(nocache: nocache, glyphs: glyphs, conf: conf)
|
74
|
+
end
|
75
|
+
|
76
|
+
File.open File.join(@dest_path, "preview.html"), "w" do |f|
|
77
|
+
template = Erubis::Eruby.new File.read(File.join(@conf_path, "templates/preview.html.erb"))
|
78
|
+
f.write template.result(nocache: nocache, glyphs: glyphs, conf: conf)
|
79
|
+
end
|
data/lib/generate.py
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
import fontforge, os, os.path, yaml, sys
|
2
|
+
|
3
|
+
stream = open(sys.argv.pop(), "r")
|
4
|
+
config = yaml.load(stream)
|
5
|
+
dest = sys.argv.pop()
|
6
|
+
src = sys.argv.pop()
|
7
|
+
|
8
|
+
def _mkdir(newdir):
|
9
|
+
"""works the way a good mkdir should :)
|
10
|
+
- already exists, silently complete
|
11
|
+
- regular file in the way, raise an exception
|
12
|
+
- parent directory(ies) does not exist, make them as well
|
13
|
+
"""
|
14
|
+
if os.path.isdir(newdir):
|
15
|
+
pass
|
16
|
+
elif os.path.isfile(newdir):
|
17
|
+
raise OSError("a file with the same name as the desired " \
|
18
|
+
"dir, '%s', already exists." % newdir)
|
19
|
+
else:
|
20
|
+
head, tail = os.path.split(newdir)
|
21
|
+
if head and not os.path.isdir(head):
|
22
|
+
_mkdir(head)
|
23
|
+
if tail:
|
24
|
+
os.mkdir(newdir)
|
25
|
+
|
26
|
+
# create an empty font in memory
|
27
|
+
font = fontforge.font()
|
28
|
+
font.fontname = config['fontname']
|
29
|
+
font.familyname = config['familyname']
|
30
|
+
|
31
|
+
unicode = 2304 # ऀ
|
32
|
+
|
33
|
+
glyphs = dict()
|
34
|
+
|
35
|
+
for root, _, files in os.walk(src):
|
36
|
+
for f in files:
|
37
|
+
if f[0] == '.':
|
38
|
+
continue
|
39
|
+
name = os.path.splitext(f)[0]
|
40
|
+
# print unicode, " => ", name
|
41
|
+
glyphs[name] = unicode
|
42
|
+
glyph = font.createChar(unicode, name)
|
43
|
+
# Import the glyph info
|
44
|
+
glyph.importOutlines(os.path.join(src, "{}.svg".format(name)))
|
45
|
+
glyph.width = config['glyphwidth']
|
46
|
+
unicode = unicode + 1
|
47
|
+
|
48
|
+
_mkdir(os.path.join(dest, 'fonts'))
|
49
|
+
|
50
|
+
with open(os.path.join(dest, 'glyphs.yaml'), 'w') as outfile:
|
51
|
+
outfile.write( yaml.dump(glyphs) )
|
52
|
+
|
53
|
+
# Write the font from memory to a TTF file
|
54
|
+
for ext in config['formats']:
|
55
|
+
font.generate(os.path.join(dest, 'fonts', "{}.{}".format(config['fontname'], ext)))
|
@@ -0,0 +1,77 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<title>Preview — <%= conf['familyname'] %></title>
|
5
|
+
<link rel="stylesheet" href="<%= conf['familyname'] %>.css" type="text/css">
|
6
|
+
<style>
|
7
|
+
* {
|
8
|
+
box-sizing: border-box;
|
9
|
+
}
|
10
|
+
html, body {
|
11
|
+
padding: 0;
|
12
|
+
margin: 0;
|
13
|
+
min-height: 100%;
|
14
|
+
}
|
15
|
+
body {
|
16
|
+
font-family: helvetica, sans-serif;
|
17
|
+
color: #555;
|
18
|
+
}
|
19
|
+
body > ul {
|
20
|
+
list-style-type: none;
|
21
|
+
}
|
22
|
+
body > ul > li {
|
23
|
+
display: inline-block;
|
24
|
+
padding: 10px;
|
25
|
+
margin: 5px;
|
26
|
+
border-radius: 2px;
|
27
|
+
background-color: #F0f0f0;
|
28
|
+
min-width: 30%;
|
29
|
+
}
|
30
|
+
h2 {
|
31
|
+
padding: 0;
|
32
|
+
margin: 0.3em 0 0.2em;
|
33
|
+
}
|
34
|
+
h2:first-child {
|
35
|
+
margin-top: 0;
|
36
|
+
}
|
37
|
+
input {
|
38
|
+
padding: 0.3em;
|
39
|
+
border: none;
|
40
|
+
border-radius: 2px;
|
41
|
+
}
|
42
|
+
ul li ul {
|
43
|
+
list-style-type: none;
|
44
|
+
margin: 0;
|
45
|
+
padding: 5px 0;
|
46
|
+
}
|
47
|
+
ul li ul li {
|
48
|
+
padding: 5px 0;
|
49
|
+
margin: 0;
|
50
|
+
}
|
51
|
+
.left, .right {
|
52
|
+
display: inline-block;
|
53
|
+
vertical-align: middle;
|
54
|
+
padding: 5px;
|
55
|
+
}
|
56
|
+
.left .<%= conf['familyname'] %> {
|
57
|
+
font-size: 3em;
|
58
|
+
}
|
59
|
+
</style>
|
60
|
+
</head>
|
61
|
+
<body>
|
62
|
+
<ul>
|
63
|
+
<% glyphs.each do |glyph, unicode| %>
|
64
|
+
<li>
|
65
|
+
<div class="left"><i class="<%= "#{conf['familyname']} #{conf["classprefix"]}#{glyph}" %>"></i></div>
|
66
|
+
<div class="right">
|
67
|
+
<h4><%= "#{conf['classprefix']}#{glyph}" %></h4>
|
68
|
+
<ul>
|
69
|
+
<li>entity: <input type="text" value="&#x<%= unicode.to_s(16) %>"></li>
|
70
|
+
<li>content: <input type="text" value="\<%= unicode.to_s(16) %>"></li>
|
71
|
+
</ul>
|
72
|
+
</div>
|
73
|
+
</li>
|
74
|
+
<% end %>
|
75
|
+
</ul>
|
76
|
+
</body>
|
77
|
+
</html>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<% nocache = Time.now.to_i.to_s %>
|
2
|
+
|
3
|
+
@font-face {
|
4
|
+
font-family: '<%= conf['familyname'] %>';
|
5
|
+
src: url('fonts/<%= conf['fontname'] %>.eot?cache=<%= nocache %>');
|
6
|
+
src: url('fonts/<%= conf['fontname'] %>.eot?cache=<%= nocache %>') format('embedded-opentype'),
|
7
|
+
url('fonts/<%= conf['fontname'] %>.ttf?cache=<%= nocache %>') format('truetype'),
|
8
|
+
url('fonts/<%= conf['fontname'] %>.woff?cache=<%= nocache %>') format('woff'),
|
9
|
+
url('fonts/<%= conf['fontname'] %>.svg?cache=<%= nocache %>') format('svg');
|
10
|
+
font-weight: normal;
|
11
|
+
font-style: normal;
|
12
|
+
}
|
13
|
+
|
14
|
+
.<%= conf['familyname'] %> {
|
15
|
+
font-family: '<%= conf['familyname'] %>';
|
16
|
+
speak: none;
|
17
|
+
font-style: normal;
|
18
|
+
font-weight: normal;
|
19
|
+
font-variant: normal;
|
20
|
+
text-transform: none;
|
21
|
+
line-height: 1;
|
22
|
+
font-size: 1.5em;
|
23
|
+
|
24
|
+
-webkit-font-smoothing: antialiased;
|
25
|
+
-moz-osx-font-smoothing: grayscale;
|
26
|
+
}
|
27
|
+
|
28
|
+
<% glyphs.each do |name, unicode| %>
|
29
|
+
.<%= "#{conf['classprefix']}#{name}" %>:before { content: "\<%= unicode.to_s(16) %>"; }
|
30
|
+
<% end %>
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: savage-fontgen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex Clink
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: colorize
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: erubis
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.7'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.7'
|
41
|
+
description: Use individual svg files to generate a font file. Created for use in
|
42
|
+
generating webfont icon sets. Also generates a css and html preview file.
|
43
|
+
email: code@alexclink.com
|
44
|
+
executables:
|
45
|
+
- savage-fontgen
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- bin/savage-fontgen
|
50
|
+
- lib/generate.py
|
51
|
+
- savage-conf/config.yaml
|
52
|
+
- savage-conf/templates/preview.html.erb
|
53
|
+
- savage-conf/templates/style.css.erb
|
54
|
+
homepage: https://github.com/SleepingInsomniac/Savage-fontgen
|
55
|
+
licenses:
|
56
|
+
- MIT
|
57
|
+
metadata: {}
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
- savage-conf
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 2.4.5.1
|
76
|
+
signing_key:
|
77
|
+
specification_version: 4
|
78
|
+
summary: Generate font files from svgs.
|
79
|
+
test_files: []
|