This post is meant to help those using CircleCI as current posts on SO just say "recompile with freetype" and don't provide any details for CircleCI.
Our unit tests use PHP GD and the PHP binary on the circleci servers has not been compiled with freetype so we get errors like:
Fatal error: Call to undefined function imagettftext()
CircleCI support says they may fix this in the future, but in the meantime we need to recompile PHP with freetype. How can we do this?