Build multiple font weights in action (#355)
* Build multiple font thicknesses * Fontcustom empties directory during compilation
This commit is contained in:
10
.github/workflows/font.yml
vendored
10
.github/workflows/font.yml
vendored
@@ -46,10 +46,16 @@ jobs:
|
||||
run: sudo yarn add svg-outline-stroke -W
|
||||
|
||||
- name: "Outline SVG"
|
||||
run: mkdir converted_icons && node scripts/outline_svg.js
|
||||
run: node scripts/outline_svg.js
|
||||
|
||||
- name: Build 'Lucide'
|
||||
run: echo "Building Lucide font" && fontcustom compile ./converted_icons -h -n Lucide -o build -F
|
||||
run: |
|
||||
mkdir build
|
||||
list=(_200 _300 "" _500 _600)
|
||||
for name in "${list[@]}"
|
||||
do
|
||||
fontcustom compile "./converted_icons${name}" -h -n "Lucide${name}" -o ./tmp -F && mv ./tmp/* build
|
||||
done
|
||||
|
||||
- name: Zip 'Lucide'
|
||||
run: zip -r Lucide.zip build
|
||||
|
||||
@@ -3,21 +3,34 @@ const outlineStroke = require('svg-outline-stroke');
|
||||
const { parse, stringify } = require('svgson');
|
||||
|
||||
const inputDir = `./icons/`;
|
||||
const outputDir = `./converted_icons/`;
|
||||
const outputDirs = {
|
||||
'converted_icons_200': '1',
|
||||
'converted_icons_300': '1.5',
|
||||
'converted_icons': '2',
|
||||
'converted_icons_500': '2.5',
|
||||
'converted_icons_600': '3'
|
||||
}
|
||||
|
||||
async function init() {
|
||||
try {
|
||||
for (const directory of Object.keys(outputDirs)) {
|
||||
await fs.mkdir(`./${directory}`);
|
||||
}
|
||||
|
||||
const files = await fs.readdir(inputDir);
|
||||
for (const file of files) {
|
||||
const icon = await fs.readFile(`${inputDir}${file}`);
|
||||
const scaled = await parse(icon.toString(), {
|
||||
transformNode: transformForward,
|
||||
});
|
||||
const outlined = await outlineStroke(stringify(scaled));
|
||||
const outlinedWithoutAttrs = await parse(outlined, {
|
||||
transformNode: transformBackwards,
|
||||
});
|
||||
await fs.writeFile(`${outputDir}${file}`, stringify(outlinedWithoutAttrs));
|
||||
for (const [directory, width] of Object.entries(outputDirs)) {
|
||||
scaled.attributes['stroke-width'] = width;
|
||||
const outlined = await outlineStroke(stringify(scaled));
|
||||
const outlinedWithoutAttrs = await parse(outlined, {
|
||||
transformNode: transformBackwards,
|
||||
});
|
||||
await fs.writeFile(`./${directory}/${file}`, stringify(outlinedWithoutAttrs));
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
|
||||
Reference in New Issue
Block a user