Skip to content

nhatthm/ligaturizer

Repository files navigation

Ligaturizer

GitHub Releases Build Status Go Report Card GoDevDoc Donate

Copy the ligatures (glyphs and rendering information) from Fira Code v3.1 into any other TrueType or OpenType font.

Note

The ligatures are scale-corrected, but otherwise copied as is from Fira Code; it doesn't create new ligature graphics based on the font you're modifying.

image

Table of Contents

Prerequisites

  • Python = 3.11 with fontforge python bindings
    • For Debian/Ubuntu they are available in python3-fontforge package.
    • For OpenSUSE and NixOS, they are included in the fontforge package.
    • For macOS, they are available via brew (brew install fontforge).

[table of contents]

Install

You can download the latest stable version or the nightly build (edge version).

Once downloaded, the binary can be run from anywhere. Ideally, though, you should move it into your $PATH for easy use. /usr/local/bin is a popular location for this.

If you want to build from source, run make build, the binary will be available at ./out/ligaturizer.

[table of contents]

Usage

$ ligaturizer /path/to/font-file
  --ligature-font-file /path/to/firacode-v3-otf-font-file \

For example:

$ ligaturizer /opt/fonts/DejaVuSansMono.ttf \
  --ligature-font-file /opt/fonts/FiraCode3/otf/FiraCode-Regular.otf \

Note

If you don't provide a ligature font file, you must specify the --ligature-font-dir option, point it to the directory that contains the FiraCode OTF font files. For example:

$ ls -1 /opt/fonts/FiraCode3/otf/
FiraCode-Bold.otf
FiraCode-Light.otf
FiraCode-Medium.otf
FiraCode-Regular.otf
FiraCode-Retina.otf
FiraCode-SemiBold.otf

The tool will pick a font file corresponding to the weight of the input font file.

The ligaturized font will be generated in the current working directory. If you want to specify the output directory, use --output-dir option.

For all available options, run:

$ ligaturizer -h

[table of contents]

Using docker

If you have problem with installing fontforge or python3.11, you can use the docker version instead. You don't have to specify the --ligature-font-file or --ligature-font-dir option, the docker image already contains the FiraCode font files.

$ docker run --rm \
  -v /path/to/local/font-dir:/opt/fonts/output \
  -w /opt/fonts/output \
  ghcr.io/nhatthm/ligaturizer:latest DejaVuSansMono.ttf

[table of contents]

Development

Prerequisites

  • Go >= 1.22 with cgo enabled
  • golangci-lint >= 1.55.2 (optional)
  • Python = 3.11 with fontforge python bindings

[table of contents]

Credit

  • The ligaturize script was originally written by IlyaSkriblovsky for adding ligatures to DejaVuSans Mono (dv-code-font).
  • Navid Rojiani made a few changes to generalize the script so that it works for any font.
  • ToxicFrog made a large number of contributions with the Ligaturizer project.
  • Nhat has ported the project to Golang with some improvements.

[table of contents]

Contribution

Contributions always welcome! Please submit a Pull Request, or create an Issue if you have an idea for a feature/enhancement (or bug).

[table of contents]

Related Projects

For more awesome programming fonts with ligatures, check out:

  1. FiraCode
  2. Hasklig

[table of contents]