Skip to content

Instantly share code, notes, and snippets.

@dongyuwei
Created September 21, 2018 01:40
Show Gist options
  • Save dongyuwei/0261a6f0bead1d66ebd1ab5b913cde21 to your computer and use it in GitHub Desktop.
Save dongyuwei/0261a6f0bead1d66ebd1ab5b913cde21 to your computer and use it in GitHub Desktop.
find the svg which fontcustom failed to compile
files = `ls ./svg_icons/*.svg`
bad_files = []
files.split("\n").each {|f|
`rm -rf ./tmp ./tmp2`
`mkdir ./tmp`
`cp #{f} ./tmp`
ok = system("fontcustom compile ./tmp/ -o tmp2")
if $?.exitstatus != 0
puts "bad file: #{f}"
bad_files.push f
end
}
puts "bad_files", bad_files
@dongyuwei
Copy link
Author

dongyuwei commented Sep 21, 2018

svg with <polygon> such as

<polygon  stroke-opacity="0.00784313771" stroke="#000000" stroke-width="1.33333335e-11" points="0 0 23.9999985 0 23.9999985 23.9999985 0 23.9999985"></polygon>

will failed to compile.

id中含有中文字符的fontcustom也会编译失败

@dongyuwei
Copy link
Author

二分查找应该会更快。但是对于100多个svg来说,上面顺序查找也很快。

@dongyuwei
Copy link
Author

去掉背景色框:
删除下列类似代码:

 <g id="Color/Neutral/Grey-Icon" mask="url(#mask-2)" fill="#94A0B6">
                <g transform="translate(-3.000000, -3.000000)" id="Base">
                    <rect x="0" y="0" width="24" height="24"></rect>
                </g>
            </g>

@dongyuwei
Copy link
Author

dongyuwei commented Oct 24, 2018

遇到不合预期(编译报错或者有背景黑色等常见问题)时,二分法注释掉svg部分代码可以很快定位问题,排除法 是比较有效的方法。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment