svg2glyph 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/svg2glyph +10 -3
- metadata +1 -1
data/bin/svg2glyph
CHANGED
@@ -1,15 +1,21 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'fileutils'
|
3
3
|
|
4
|
-
source_file = ARGV[0]
|
4
|
+
source_file = ARGV[0]
|
5
5
|
target_dir = ARGV[1].nil? ? 'glyphs' : ARGV[1]
|
6
6
|
|
7
|
+
abort("An input svg file must be specified") if ARGV[0].nil?
|
7
8
|
abort("The specified svg file does not exist: #{source_file}") unless File.exists? source_file
|
8
9
|
|
9
10
|
FileUtils.mkdir_p target_dir unless Dir.exists? target_dir
|
10
11
|
|
11
|
-
File.open(source_file).read.scan(/id="(.*?)".*?d="(.*?)"/m) do |m|
|
12
|
-
|
12
|
+
#File.open(source_file).read.scan(/id="(.*?)".*?d="(.*?)"/m) do |m|
|
13
|
+
count=0
|
14
|
+
File.open(source_file).read.scan(/id="(.*?)".*?<path.*?d="(.*?)"/m) do |m|
|
15
|
+
path = "#{target_dir}/#{m[0]}.svg"
|
16
|
+
puts "creating #{path}"
|
17
|
+
count = count+1
|
18
|
+
File.open(path, "w+") do |out|
|
13
19
|
out.write <<eos
|
14
20
|
<?xml version="1.0" encoding="utf-8"?>
|
15
21
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
@@ -20,3 +26,4 @@ File.open(source_file).read.scan(/id="(.*?)".*?d="(.*?)"/m) do |m|
|
|
20
26
|
eos
|
21
27
|
end
|
22
28
|
end
|
29
|
+
puts "Finished creating #{count} glyphs"
|