The steps are written assuming you are in a Ubuntu distro. Please adjust the installation instructions according to your distros. Follow the official docs for other environments.
Steps:
-
Make sure you have python3 installed in your system
-
Download the required script and helper files: archive
-
Extract the zip file
-
Collect the source font files and put them somewhere in a folder
-
Download the dependencies:
sudo apt install fontforge python3-fontforge
-
If your default python version is not set to Python 3, open the
font-patcher
file from the extracted directory and change the first line: from#!/usr/bin/env python
to#!/usr/bin/env python3
-
Now execute the following command:
./font-patcher --complete --adjust-line-height --out , <DESIRED OUTPUT LOCATION> <FONT FILE PATH>
Example:
./font-patcher --complete --adjust-line-height --out output/ fonts/JetBrainsMono-Regular.ttf
You should see the output something like this:
Adding 169 Glyphs from Octicons Set
╢████████████████████████████████████████╟ 100%
Adding 1 Glyphs from Octicons Set
╢████████████████████████████████████████╟ 100%
Adding 1 Glyphs from Octicons Set
╢████████████████████████████████████████╟ 100%
Adding 139 Glyphs from Octicons Set
╢████████████████████████████████████████╟ 100%
You may see some messages like the following, somewhere during the execution:
The glyph named ampersand is mapped to U+F0A8D.
But its name indicates it should be mapped to U+0026.
The glyph named diamond is mapped to U+F0B8A.
But its name indicates it should be mapped to U+2666.
The glyph named bullet is mapped to U+F0CF3.
But its name indicates it should be mapped to U+2022.
The glyph named comma is mapped to U+F0E23.
But its name indicates it should be mapped to U+002C.
The glyph named rectangle is mapped to U+F0E5E.
But its name indicates it should be mapped to U+25AD.
But you can ignore most of them.
After this you should be able to install the output font files in your desired environment.
To patch a lot of font files in a folder together, you can write a script say (patch-all):
for file in <PATH TO THE FOLDER CONTAINTING THE SOURCE FONTS>/*.<FONT FILE EXTENSION>'
do
./font-patcher --complete --adjust-line-height --out output/ $file
done
For example:
for file in fonts/*.ttf
do
./font-patcher --complete --adjust-line-height --out output/ $file
done
Don't forget to make the script executable with the following command:
chmod +x <YOUR SCRIPT NAME>
You can now run your script like this:
./patch-all
to create the output font files in your specified output location
Thanks 🙏