This is a tiny cross-platform utility which simply lists the available installed fonts in a JSON format to stdout.
This code is derived from the font-manager NodeJS module, but makes it a separate executable and not a node module which needs to be rebuilt everytime you install it or change node versions. It is quite simple and only implements font-manager's getAvailableFonts() method.
Example output:
[
{
"path": "/usr/share/fonts/truetype/noto/NotoSansDisplay-Bold.ttf",
"postscriptName": "NotoSansDisplay-Bold",
"family": "Noto Sans Display",
"style": "Bold",
"weight": 700,
"width": 5,
"italic": false,
"oblique": false,
"monospace": true
}
]
The output is a JSON array of objects where each object describes a font with the following fields:
Note that italic, oblique and monospace fields tend not to be reliablely reported by most operating systems.
The build system is based on CMake. Make sure you have a recent version installed.
Make sure you have Xcode's C/C++ compiler installed, and then from the root of this git repository run:
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make
The executable is left in the build folder.
First ensure you have a working C/C++ compiler and the fontconfig development files installed. Now run:
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make
The executable is left in the build directory.
It is also possible to build the Linux binary via Docker. That advantage is that you don't need any extra tooling installed and the resulting executable should have greater compatibilitywith older Linux distributions.
Run the script:
./build_linux_in_docker.sh
The executable is left in the build directory.
Make sure you have CMake installed and a "Visual Studio Visual C/C++ Build Tools 2015" or similar installed.
From PowerShell run:
mkdir build
cd build
cmake ..
Now open up a suitable "Visual C/C++ 2015 x64 Native Build Tools Command Promp", go to the build directory and run:
msbuild ALL_BUILD.vcxproj /p:Configuration=Release
The exe should now be in the Release/ directory.
MIT
Simon Edwards [email protected]