Export works

This commit is contained in:
Jake Pearson 2012-05-04 12:02:10 -06:00
parent c46c7f0e1c
commit 5f44b9dce9
2 changed files with 25 additions and 21 deletions

View File

@ -9,8 +9,8 @@
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="32" width="900"
height="32" height="900"
id="svg6044" id="svg6044"
version="1.1" version="1.1"
inkscape:version="0.48.2 r9819" inkscape:version="0.48.2 r9819"
@ -24,9 +24,9 @@
borderopacity="1.0" borderopacity="1.0"
inkscape:pageopacity="0.0" inkscape:pageopacity="0.0"
inkscape:pageshadow="2" inkscape:pageshadow="2"
inkscape:zoom="11" inkscape:zoom="0.12153398"
inkscape:cx="14.519665" inkscape:cx="-785.06398"
inkscape:cy="17.277308" inkscape:cy="-68.264027"
inkscape:current-layer="layer1" inkscape:current-layer="layer1"
showgrid="true" showgrid="true"
inkscape:document-units="px" inkscape:document-units="px"
@ -35,7 +35,11 @@
inkscape:window-height="627" inkscape:window-height="627"
inkscape:window-x="1616" inkscape:window-x="1616"
inkscape:window-y="258" inkscape:window-y="258"
inkscape:window-maximized="0" /> inkscape:window-maximized="0"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0" />
<metadata <metadata
id="metadata6049"> id="metadata6049">
<rdf:RDF> <rdf:RDF>
@ -52,9 +56,9 @@
id="layer1" id="layer1"
inkscape:label="Layer 1" inkscape:label="Layer 1"
inkscape:groupmode="layer" inkscape:groupmode="layer"
transform="translate(0,-31.999983)"> transform="translate(0.0625,0.0625)">
<path <path
style="fill:#000000;stroke:#000000;stroke-width:0.03897692000000000px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:1" style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.03897692px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="###INSERTGLYPH###" d="###INSERTGLYPH###"
id="path6054" id="path6054"
inkscape:connector-curvature="0" /> inkscape:connector-curvature="0" />

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -1,13 +1,8 @@
icons = {} icons = {}
glyphs = {} glyphs = {}
sass_file = File.open('../sass/font-awesome.sass') sass_lines = File.open('../sass/font-awesome.sass').readlines
sass_lines = sass_file.readlines svg_lines = File.open('../font/fontawesome-webfont.svg').readlines
sass_file.close
svg_file = File.open('../font/fontawesome-webfont.svg')
svg_lines = svg_file.readlines
svg_file.close
index = 0 index = 0
while index < sass_lines.length while index < sass_lines.length
@ -23,7 +18,6 @@ while index < sass_lines.length
end end
index += 1 index += 1
end end
puts icons.length
index = 0 index = 0
while index < svg_lines.length while index < svg_lines.length
@ -32,13 +26,19 @@ while index < svg_lines.length
if line.start_with? '<glyph unicode="&#x' and d_index != nil if line.start_with? '<glyph unicode="&#x' and d_index != nil
icon_code = line[19.. 22] icon_code = line[19.. 22]
start_index = d_index + 3 start_index = d_index + 3
icon_glyph = line[start_index .. line.length - 4] icon_glyph = line[start_index .. line.length - 6]
glyphs[icon_code] = icon_glyph glyphs[icon_code] = icon_glyph
puts "#{icon_code}: " #puts "#{icon_code}: '#{icon_glyph}'"
end end
index += 1 index += 1
end end
icons.each_pair do |icon_name, icon_code| # icons.each_pair do |icon_name, icon_code|
puts "#{icon_name}: #{glyphs[icon_code]}" # puts "#{icon_name}: #{glyphs[icon_code]}"
end # end
requested_icon = ARGV[0]
requested_glyph = glyphs[icons[requested_icon]]
blank_svg_content = File.open('empty.svg').read
output_svg = blank_svg_content.sub '###INSERTGLYPH###', requested_glyph
File.open("#{requested_icon}.svg", 'w') {|out_svg| out_svg.write(output_svg) }