@nartallax/icon-font-tool
v1.0.9
Published
A tool to work with icon fonts
Readme
Icon font tool
A tool to work with icon fonts.
Very far from "swiss army knife of icon tools"; more like "a tool that fits just my exact needs".
Install
npm install --save-dev @nartallax/icon-font-toolUse
Full list of options is available at
./node_modules/.bin/icon-font-tool --help...but here's an example:
./node_modules/.bin/icon-font-tool \
--svg-dir ./icons \
--font-path target/my_icon_font \
--ts-path target/icon_font.ts \
--css-path target/icon_font_style.cssCommand above will:
- take all SVGs in
./iconsdirectory; - Make a
woff2font out of it (there's option to control formats) and put it in./target/my_icon_font.woff2; - Generate CSS file with classes related to icons and put that CSS file at
./target/icon_font_style.css; - Generate TS file that will import CSS file and export const enum with all the icons.
As you can see, this tool expects that your build process supports CSS importing. The idea behind all of those steps is that you can just import icons from TS file and let builder do all the work regarding delivery of the fonts/styles.
If your CSS file ends with .module.css, then TS file will look a bit different - instead of const enum, it will export an object under the same name. That's not as optimal as const enum, but will work the same way, and if you want names of the icons to be mangled - you can go that route.
Development
# clone the repo
git clone ssh://[email protected]:nartallax/icon-font-tool
# get into repo's dir
cd icon-font-tool
# set up signing
# also, make sure that `git config --get user.email` is equal to your email in forgejo
git config gpg.format ssh
git config user.signingKey "~/.ssh/id_rsa"
# this one is optional. forgejo will show commits as signed without this step
# but git can panic about missing keys sometimes
echo "$(git config --get user.email) namespaces=\"git\" $(cat ~/.ssh/id_rsa.pub)" >> allowed_signers
git add . && git commit -m "Add new key to allowed_signers" && git push
# enable signing by default
git config commit.gpgsign true