Skip to content

Commit 76d57d5

Browse files
committed
allow sub-directories in input vectors
1 parent 9188eb7 commit 76d57d5

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

lib/fontcustom/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def check_fontforge
3838

3939
# Calculates a hash of vectors, options, and templates (content and filenames)
4040
def checksum
41-
files = Dir.glob(File.join(@options[:input][:vectors], "*.svg")).select { |fn| File.file?(fn) }
41+
files = Dir.glob(File.join(@options[:input][:vectors], "**/*.svg")).select { |fn| File.file?(fn) }
4242
files += Dir.glob(File.join(@options[:input][:templates], "*")).select { |fn| File.file?(fn) }
4343
content = files.map { |file| File.read(file) }.join
4444
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)