Skip to content

Commit c589621

Browse files
committed
allow sub-directories in input vectors
1 parent 4ff2fbf commit c589621

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

lib/fontcustom/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def check_woff2
5050

5151
# Calculates a hash of vectors, options, and templates (content and filenames)
5252
def checksum
53-
files = Dir.glob(File.join(@options[:input][:vectors], "*.svg")).select { |fn| File.file?(fn) }
53+
files = Dir.glob(File.join(@options[:input][:vectors], "**/*.svg")).select { |fn| File.file?(fn) }
5454
files += Dir.glob(File.join(@options[:input][:templates], "*")).select { |fn| File.file?(fn) }
5555
content = files.map { |file| File.read(file) }.join
5656
content << files.join

lib/fontcustom/generator/font.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ def set_glyph_info
4747
0xf100
4848
end
4949

50-
files = Dir.glob File.join(@options[:input][:vectors], "*.svg")
50+
files = Dir.glob File.join(@options[:input][:vectors], "**/*.svg")
5151
glyphs = {}
5252
files.each do |file|
53-
name = File.basename file, ".svg"
53+
name = file.sub(/^#{@options[:input][:vectors]}\/?/, '').sub(/\.svg$/, '')
5454
name = name.strip.gsub(/\W/, "-")
5555
glyphs[name.to_sym] = { :source => file }
5656
if File.read(file).include? "rgba"

lib/fontcustom/options.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def set_input_paths
119119
@options[:input] = { :vectors => input, :templates => input }
120120
end
121121

122-
if Dir[File.join(@options[:input][:vectors], "*.svg")].empty?
122+
if Dir.glob(File.join(@options[:input][:vectors], "**/*.svg")).empty?
123123
raise Fontcustom::Error, "`#{@options[:input][:vectors]}` doesn't contain any SVGs."
124124
end
125125
end

0 commit comments

Comments
 (0)