Skip to content

Instantly share code, notes, and snippets.

@allansideas
Created March 27, 2012 00:35
Show Gist options
  • Save allansideas/2211041 to your computer and use it in GitHub Desktop.
Save allansideas/2211041 to your computer and use it in GitHub Desktop.
Little util for extracting fontsquirrel fontpacks renaming url( to font_url( for scss, and creating a fonts.css.scss file with all style rules. Put zips and script in vendor fonts, run, and copy fonts.css.scss to stylesheets dir and include in applicatio
#!/usr/bin/env ruby
#Extracts files to current dir, substitutes url( for font_url( and appends stylesheet to fonts.css.scss
completed_files = Array.new
current_directory = Dir.getwd
File.open('fonts.css.scss', "w") {}
Dir.foreach(current_directory) do |file_name|
if (file_name.include?(".zip") && !completed_files.include?(file_name))
system("unzip -o #{file_name}")
completed_files << file_name
style = File.read('stylesheet.css')
style = style.gsub(/url\(/, "font_url(")
File.open('fonts.css.scss', "a") do |f|
puts style
f << style
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment