mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-15 14:08:49 +00:00
Introduce Docker Image for font building (#870)
* Add dockerfile * Make the dockerfile work * try docker container for font building * remove workflow dep * add docker compose file * test docker image * update build font flow * update to v3 * cleanup * add filter options for installs * test * revert filter on install * optimize font building * Rename workflow * test and compare workflows * test workflow * test * try with filter * test old script github actions * Fix old script * this works? * test script * finialize font script * remove workspace packages * add pnpm-lock.yaml in workflows
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
## This Dockerfile is for building image for github actions
|
||||
FROM debian:stable-slim
|
||||
|
||||
RUN apt-get update
|
||||
RUN apt-get install zlib1g-dev fontforge git build-essential ruby-full -y
|
||||
|
||||
# sfnt2woff
|
||||
RUN git clone https://github.com/bramstein/sfnt2woff-zopfli.git sfnt2woff-zopfli
|
||||
WORKDIR /sfnt2woff-zopfli
|
||||
RUN make
|
||||
RUN cp sfnt2woff-zopfli /usr/local/bin/sfnt2woff
|
||||
|
||||
# WOFF2
|
||||
WORKDIR /
|
||||
RUN git clone --recursive https://github.com/google/woff2.git
|
||||
WORKDIR /woff2
|
||||
RUN make clean all
|
||||
RUN mv woff2_compress /usr/local/bin/
|
||||
RUN mv woff2_decompress /usr/local/bin/
|
||||
|
||||
RUN gem install fontcustom
|
||||
@@ -1,81 +0,0 @@
|
||||
import { promises as fs } from 'fs';
|
||||
import outlineStroke from 'svg-outline-stroke';
|
||||
import { parse, stringify } from 'svgson';
|
||||
import getArgumentOptions from 'minimist';
|
||||
|
||||
const inputDir = `./icons/`;
|
||||
const cliArguments = getArgumentOptions(process.argv.slice(2));
|
||||
const { outputDir } = cliArguments;
|
||||
|
||||
const widthMap = {
|
||||
'converted_icons-200': '1',
|
||||
'converted_icons-300': '1.5',
|
||||
converted_icons: '2',
|
||||
'converted_icons-500': '2.5',
|
||||
'converted_icons-600': '3',
|
||||
};
|
||||
|
||||
function transformForward(node) {
|
||||
if (node.name === 'svg') {
|
||||
return {
|
||||
...node,
|
||||
attributes: {
|
||||
...node.attributes,
|
||||
width: 960,
|
||||
height: 960,
|
||||
},
|
||||
};
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
function transformBackwards(node) {
|
||||
if (node.name === 'svg') {
|
||||
const { width, height, ...attributes } = node.attributes;
|
||||
return {
|
||||
...node,
|
||||
attributes,
|
||||
};
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
async function init() {
|
||||
console.time('icon outliner');
|
||||
try {
|
||||
await fs.mkdir(`./${outputDir}`);
|
||||
|
||||
const icons = await fs.readdir(inputDir);
|
||||
const parsedIconNodes = await Promise.all(
|
||||
icons.map(async (file) => {
|
||||
const iconContent = await fs.readFile(`${inputDir}${file}`);
|
||||
const iconNode = await parse(iconContent.toString(), {
|
||||
transformNode: transformForward,
|
||||
});
|
||||
return [file, iconNode];
|
||||
}),
|
||||
);
|
||||
|
||||
if (widthMap?.[outputDir] === undefined) {
|
||||
throw new Error(`Could not find the directory: ${outputDir}.`);
|
||||
}
|
||||
|
||||
await Promise.all(
|
||||
parsedIconNodes.map(async ([file, iconNode]) => {
|
||||
iconNode.attributes['stroke-width'] = widthMap[outputDir];
|
||||
const outlined = await outlineStroke(stringify(iconNode));
|
||||
const outlinedWithoutAttrs = await parse(outlined, {
|
||||
transformNode: transformBackwards,
|
||||
});
|
||||
|
||||
await fs.writeFile(`./${outputDir}/${file}`, stringify(outlinedWithoutAttrs));
|
||||
}),
|
||||
);
|
||||
|
||||
console.timeEnd('icon outliner');
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
|
||||
init();
|
||||
Reference in New Issue
Block a user