### Configure svg_dir = 'app/assets/images/iconfont' font_family = 'icons' types = %w[svg ttf woff woff2] baseline_adjustment = 0 # How far to move the icons below the baseline ### Prepare font_name = font_family.underscore font_height = 2000 # Should be > 1000 to avoid rounding issues svg_glob = Rails.root.join svg_dir, '*.svg' font_dir = Rails.root.join 'app/assets/fonts', font_name json_path = Rails.root.join 'app/assets/stylesheets/shared', font_name, 'variables.json' options = [ "--out #{font_dir}", "--height #{font_height}", "--name #{font_family}", "--prefix #{font_family.parameterize.singularize}", # "--silent", "--descent #{baseline_adjustment}", "--types #{types.join(',')}", "--html true", # Font demo page "--css true", # Generate CSS styles # "--csspath" # Rendering the CSS file to assets/stylesheets breaks the HTML font demo "--json true", # Help updating _variables.scss "--jsonpath #{json_path}", ] ### Perform FileUtils.mkdir_p font_dir `icon-font-generator #{svg_glob} #{options.join(' ')}`