| 1 | # Installing FontForge from source |
| 2 | |
| 3 | Install all your typical build tools, build dependencies and runtime dependencies - all the packages that allow you to build of software from source code. |
| 4 | The exact method to do this depends on your OS distribution. |
| 5 | |
| 6 | To download all dependencies on Ubuntu, run: |
| 7 | |
| 8 | ```sh |
| 9 | sudo apt-get install libjpeg-dev libtiff5-dev libpng-dev libfreetype-dev libgif-dev libgtk-3-dev libgtkmm-3.0-dev libxml2-dev libpango1.0-dev libcairo2-dev libspiro-dev libwoff-dev python3-dev ninja-build cmake build-essential gettext; |
| 10 | ``` |
| 11 | |
| 12 | Now run the build and installation scripts: |
| 13 | |
| 14 | ```sh |
| 15 | cd fontforge |
| 16 | mkdir build |
| 17 | cd build |
| 18 | cmake -GNinja .. |
| 19 | ninja |
| 20 | sudo ninja install |
| 21 | ``` |
| 22 | |
| 23 | For even more details on the build system itself, see [this wiki page](https://github.com/fontforge/fontforge/wiki/CMake-guide-for-FontForge). |
| 24 | |
| 25 | ## Python Module |
| 26 | |
| 27 | FontForge's Python bindings are also available directly from PyPI: |
| 28 | |
| 29 | ```sh |
| 30 | pip install fontforge |
| 31 | ``` |
| 32 | |
| 33 | If you install the Python module via pip, building and installing FontForge from source will detect this and skip installing the Python module to avoid conflicts. To switch back to app-installed modules, first run `pip uninstall fontforge`. |
| 34 | |
| 35 | **Attention, Designers Who Love TrueType Hinting:** |
| 36 | Run `cmake` with `-DENABLE_FREETYPE_DEBUGGER=/path/to/freetype/source`. |
| 37 | This option enables advanced features for debugging TrueType font hints, such as stepping through hinting instructions one by one. |
| 38 | |
| 39 | Note that the version of the FreeType source must *exactly* match the installed version of FreeType. |
| 40 | |
| 41 | ## Common Problems |
| 42 | ### MacOS |
| 43 | * Missing packages can be installed with Homebrew, like: |
| 44 | ``` |
| 45 | brew install cmake glib pango gtk+3 |
| 46 | ``` |
| 47 | * `msgfmt` is not found (when using Homebrew): |
| 48 | |
| 49 | ```bash |
| 50 | brew install gettext |
| 51 | brew link gettext |
| 52 | ``` |
| 53 | |
| 54 | #### Executables |
| 55 | |
| 56 | If you want to do autotracing around character images you should also download either |
| 57 | |
| 58 | - Peter Selinger's [potrace](http://potrace.sf.net/) |
| 59 | - Martin Weber's [autotrace program.](http://sourceforge.net/projects/autotrace/) |
| 60 | |
| 61 | #### Libraries |
| 62 | |
| 63 | If your system comes with a package manager, use it. |
| 64 | It makes installing these libraries easier. |
| 65 | |
| 66 | Most of these are not required for the proper compilation/execution of FontForge, if the libraries are not present they will not be used. |
| 67 | (If the machine on which your executable was built didn't have them, then you must not only install the libraries, but also **rebuild FontForge from source**. |
| 68 | If your machine doesn't have them and you want them they are available from: |
| 69 | |
| 70 | - Image Libraries (to allow FontForge to import images in those |
| 71 | formats generally used as backgrounds for autotracing) |
| 72 | - [libpng](http://www.libpng.org/pub/png/libpng.html) (and required helper [zlib](http://www.zlib.net/)) |
| 73 | - [libtiff](http://www.libtiff.org/) |
| 74 | - [libungif](http://gnuwin32.sourceforge.net/packages/libungif.htm) |
| 75 | - [libjpeg](http://www.ijg.org/) |
| 76 | - [libxml2](http://xmlsoft.org/) To parse SVG files and fonts |
| 77 | - [libspiro](https://github.com/fontforge/libspiro) Raph Levien's clothoid to bezier spline conversion routines. If this is available FontForge will allow you to edit with clothoid splines (spiro). |
| 78 | - [libiconv](http://www.gnu.org/software/libiconv/) Only important for systems with no built-in iconv(). |
| 79 | If not present FontForge contains a minimal version of the library which allows it to work. |
| 80 | But if you want to use libiconv you must configure it with `--enable-extra-encodings`, as FontForge requires Shift-JIS. |
| 81 | - [freetype](http://freetype.org/) |
| 82 | To do a better job rasterizing bitmaps, and to enable the truetype debugger. |
| 83 | Some of FontForge's commands depend on you compiling freetype with the byte code interpreter enabled. |
| 84 | It used to be disabled by default because of some [patents granted to Apple](http://freetype.org/patents.html). |
| 85 | Now that they have expired, you no longer need to worry about this, unless your setup happens to use an old library version. |
| 86 | Then you may enable the interpreter by setting the appropriate macro in `*.../include/freetype/config/ftoption.h*` before you build the library (see the README.UNX file on the top level of the freetype distribution). |
| 87 | To enable the truetype debugger, FontForge needs to have the freetype source directories available when it is built (there are some '#include' files there which it depends on). |
| 88 | - libintl Is standard on most Unixes. It is part of the fink package on the Mac. Handles UI localization. |
| 89 | - [libpython](http://www.python.org/) If present when FontForge is compiled, allows the user to execute python scripts within FontForge (and you can configure FontForge so that FontForge's functionality can be imported into python -- that is FontForge both *extends* and *embeds* python) |
| 90 | - [libX](http://x.org/) Normally FontForge depends on the X11 windowing system, but if you are just interested in the scripting engines (with no user interface), it may be built on systems without X (the configure script should figure this out). |
| 91 | - [libcairo](http://www.cairographics.org/) Cairo handles drawing anti-aliased splines in the outline glyph view. It is dependent on libfontconfig, libXft, and perhaps other libraries. |
| 92 | - [libpango](http://www.pango.org/) Pango draws text for complex scripts. It depends on glib-2.0, libfontconfig, libfreetype, libXft, and perhaps other libraries. |
| 93 | - [Unifont](http://savannah.gnu.org/projects/unifont) includes glyphs for all Unicode codepoints, and FontForge will use it if it is installed. |