Effortless Local Font Integration
local-font
is a command-line tool that streamlines the process of downloading web fonts and seamlessly integrating them into your projects.
- Provide the URL of a CSS file containing font references, and
local-font
will fetch both the CSS and the referenced fonts. - Specify the exact location where you want the fonts and the modified CSS file to be stored.
- Define a path or URL to replace the original font URLs in the CSS, ensuring they point to the correct location within your project structure.
Go to the releases and download the zip for your os or compile it yourself
Requirements
- git
- go
- gosec
- make
To compile it for your platform only run the command make <os>-<arch>
(e.g. make darwin-arm64
).
You can find the binary under ./build/<os>-<arch>/local-font
(e.g. ./build/darwin-arm64/local-font
).
The url of the css file is required and can be specified with -u
or --url
By default, the css file is saved under ./css/fonts.css
and the fonts under ./css/fonts
.
The urls in the css file are adapted accordingly with e.g. /css/fonts/my-font.woff2
.
Usage:
local-font [flags]
local-font [command]
Available Commands:
completion Generate the autocompletion script for the specified shell
help Help about any command
version Print the version
Flags:
-c, --css-dir string Directory to save the css file (default "./src")
-e, --css-ext string Extension of the css file (default "scss")
-f, --css-file string Name of the css file (default "typography")
--debug Log debug messages
-d, --font-dir string Directory to save the font file (default "./public/fonts")
-h, --help help for local-font
-r, --replace string Replaces the font url in the css file (default "/fonts")
-u, --url string URL of the font file
-a, --user-agent string User agent to use for the HTTP request (default "Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36")
Use "local-font [command] --help" for more information about a command.