|0.2.0||Apr 17, 2023|
|0.1.0||Apr 14, 2023|
#24 in Multimedia
FontPM: the font package manager
FontPM is a package manager-like command line utility that allows you to install fonts swiftly, similar to how many package managers allow you to install packages.
Step 1: Install FontPM
Cargo (the recommended way)
FontPM can be installed through cargo simply by running
cargo install fontpm.
This is the recommended way of doing things.
Building and installing from source (the slightly more complex way)
FontPM can also be installed by building it from source. At the moment, there isn't a stable branch, so you'll just have to figure out which commit you want to build from. No guarantees are made about the stability of the dev branch.
The first step is to clone the repository using Git:
git clone https://github.com/tecc/fontpm.git.
After that's done, you can install FontPM by running
cargo install --path <path-to-fontpm>/cli (where
<path-to-fontpm> is whichever directory FontPM was closed into).
A full script for building and installing from source looks something like this:
git clone https://github.com/tecc/fontpm.git cd fontpm cargo install --path ./cli
Step 2: Refresh the font index
The first thing you need to do before using FontPM is refreshing the local font index.
You can do this using
Refreshing the local font index
FontPM downloads indices of available fonts for each source, but it doesn't do this automatically for you. To refresh
To your machine
Installing fonts globally may not work on all platforms. It should work with any XDG Base Directory-compliant Linux system, but beyond that it's untested.
To install a font to your machine, simply run the following command:
fontpm install <font-id...>
<font-id> with whatever font you want to install. This is usually in
kebab-case, so if you want to install Noto Sans you'd write
To install multiple fonts, simply list font IDs separated by spaces.
To a directory (e.g. for a project)
Installing fonts to a specific directory is done similarly to installing them globally.
Simply run the following command, substituting
<font-id> for whatever fonts you want to use and
<directory> for whatever directory you want to install the font
fontpm install -d <directory> <font-id...>
Additionally, you can specify how you'd like FontPM to organise the files by using the
It only supports 2 modes as of now -
fontpm install -d <directory> -f <format> <font-id...>
If you use
flat, the files will look a bit like this:
<directory> |_ font1-italic.ttf |_ font1-regular.ttf |_ font2-italic.ttf |_ font2-regular.ttf
flat-directory separates them into directories based on the font ID, meaning it looks a bit like this:
<directory> |_ font1 | |_ italic.ttf | |_ regular.ttf |_ font2 | |_ italic.ttf | |_ regular.ttf
Purging FontPM data
This command has the ability to delete all FontPM files irrevocably. Be sure of what you're doing.
In some cases, you may decide you want to purge FontPM-created files (perhaps to save storage space on your device).
This can be done using the
fontpm purge <target>
target argument specifies what you want to delete. It currently allows three values:
cache (which targets the cached files that FontPM uses),
installed-fonts, which targets all installed fonts), and
all (which targets both of the former targets).
FontPM's configuration (
config.toml) resides in a platform-specific directory:
- On Linux it will be in
$XDG_CONFIG_HOME/fontpmwhich normally is (and defaults to if
$XDG_CONFIG_HOMEis not set)
- On Windows it will be in the Roaming AppData directory (example:
- On Mac it will be
[fontpm] # The main section of the configuration # enabled_sources: array<string> # A list of source IDs. # All the sources included in this array, FontPM will use at runtime. enabled_sources = ["google-fonts"] # cache_dir: path # Path to the directory where FontPM should cache files. # This directory will contain the local index files and all downloaded font files. # If this is not provided, it will create a default at runtime. cache_dir = "~/.cache/fontpm" # font_install_dir: path # Path to the directory where installed fonts should reside. # If this is not provided, it will create a default at runtime. font_install_dir = "~/.local/share/fonts/fontpm"
Copyright (c) 2023 tecc Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.