These instructions are for users who wish to build the C programs in the AFDKO on their own. If you have obtained the AFDKO through PyPI (
pip), you can ignore this, as everything is pre-built for distribution on PyPI. These are really only for users who need to build on platforms that are not officially supported, or wish to make other custom changes.
The FDK directory tree is pretty straightforward. The basic structure is:
afdko/ └── c/ └── <component>/ └── source/
When a tool uses a library there are additional directories for its include files and the library sources:
└── c/ └── <component>/ └── include/ └── lib/<library>/source └── source/
rotatefont share a common set of libraries and resource files. These libraries are grouped under the shared directory in:
afdko/ └── c/ └── shared/ └── include/ └── resource/ └── source/<library>
AFDKO now uses CMake as its build system. To build the programs with the default options run these commands in the top-level directory (above “c”):
cmake -S . -B build cmake --build build
Note that unless you are using macOS or Windows you must have
libuuid and its header files installed in order to build
makeotfexe. These will typically be part of a package named
libuuid is a dependency of the Antlr 4 Cpp runtime, which is built by
cmake/ExternalAntlr4Cpp.cmake. If you have build trouble after installing the library the Antlr 4 Cpp runtime documentation may help.)
If the build is successful each program (e.g. makeotfexe) will be built as
build/bin/[program]. If you would like to install them in
/usr/local/bin you can then run
cmake --build build -- install.
These options can be added to the end of the first CMake command above:
/usr/localby default) to
CMakeLists.txtfiles. Just open the main project folder.
-Gand the platform with
-A, as in
cmake -G "Visual Studio 16 2019" -A Win32. See Visual Studio Generators in the CMake documentation for more information.
memory, etc. (This currently only works with compilers that support GCC-style directives.) The top-level
CMakeLists.txtwill also honor an
ADD_SANITIZERenvironment variable with the same values.
Tests for both the C and Python programs are written in the Python
pytest framework. If you have installed the
afdko package using
pip (or an equivalent) you can make
tests your working directory and run
python -m pytest to run the tests.
You can also run the tests before installation using CMake’s
ctest program or the
test build target, assuming that you have both Python 3 and the
pytest package installed. (For example, if you are building with ninja you can run
ninja test.) Using
ctest you can run the tests for one or more individual programs but not at a finer grain.
To run the tests manually/individually before installation you need to set a few environment variables. If the repository directory is
[AFDKO] and the CMake build directory is
[AFDKO]/build then the compiled programs will be in
[AFDKO]/build/bin. Add this to the front of the
PATH environment variable. Then add
[AFDKO]/python to the front of the
PYTHONPATH environment variable. Finally set the
AFDKO_TEST_SKIP_CONSOLE variable to
True. (The latter allows the tests to succeed without
console_script wrappers for the Python EntryPoints.) The tests should now succeed or fail based on the current status of the build and python file changes.
The Antlr 4 build process downloads its
utfcpp dependency using a
git protocol URL. In some situations this action can time out. As a workaround you can substitute the more reliable
https URL by running this command (which will modify your git configuration):
git config --global url.https://github.com/.insteadOf git://github.com/
You may have trouble building the Antlr 4 Cpp runtime on Windows due to git being conservative about filename lengths. If you see an error like
error: unable to create file googletest/xcode/Samples/FrameworkSample/WidgetFramework.xcodeproj/project.pbxproj: Filename too long
git config --system core.longpaths true