The easiest way I found to do this, is using one of the following two methods.
- Use fontforge scripting and call it from php
- Use REST font conversion apis like the one found here.
Personally I prefer the later since it works well on any environment and you don't have to mess with compiling fontforge for your host and wrapping it in php.