package fontforge-of-ocaml

  1. Overview
  2. Docs
OCaml binding of FontForge


Dune Dependency






Library providing OCaml binding of FontForge Python API


font fontforge binding

Published: 05 Apr 2022


Copyright (C) 2017-2022, P. Baudin (

OCaml binding to FontForge

Library usage

The fontforge-of-ocaml library is published under the LGPL v2.1 license and its API is documented in the file src/FontForge.mli.

Example of use

Look at the included test file tests/


The binding is incomplete, but don't forget that the library is able to load .fea (OpenType Feature) files to design complex fonts.


The library can easily be installed from source-based package manager Opam from a pin to this GitHub repository:

$ opam pin

On Ubuntu, the library relies on python3-fontforge package that contains the python3 binding to FontForge:

$ sudo apt-get install -y python3-fontforge


Since the library meets my needs, I won't complete the binding from myself. Nevertheless, if you want to contribute you are welcome. Don't hesitate to open an issue for that and why not propose a pull request.

The story


This library was developed in 2017 and used for the design of several Advanced Cross-Stitch Fonts. Five years later, it time to publish the fontforge-of-ocaml library even if the binding is incomplete.


The first version of that library was written in OCaml and used the Lymp library allowing you to use Python functions and objects of FontForge API from OCaml world.

The FontForge API imposes type constraints between the arguments of the functions managing the contextual font tables. In order to offer an OCaml API as close as the FontForge API, the use of Generalized Algebraic Data Type of OCaml was seen as an opportunity. That has not been so much used due to some bugs in the Lymp library raised by the hudge number of calls from OCaml to Python. A work around has been found in generating an intermediate file (specifying the OpenType Feature Data to use in a .fea file) to build the final fonts from FontForge Python API and the OCaml binding. That explains why the development of the FontForge binding was stopped earlier that expected.

In the meantime, Fontforge API migrated to Python 3 and the Lymp library was no more able to perform the binding with newer versions of OCaml compiler and various libraries. Nevertheless, with few effort the Lymp library was easily replaced by the PyMl library.

Dependencies (6)

  1. ppx_python >= "v0.12.0"
  2. pyml >= "20200518"
  3. fmt >= "0.8.9"
  4. base >= "v0.12.2"
  5. ocaml >= "4.09.0"
  6. dune >= "2.8"

Dev Dependencies (1)

  1. odoc with-doc

Used by


Conflicts (1)

  1. headache < "1.05"

Innovation. Community. Security.