• Stars
    star
    2,182
  • Rank 20,593 (Top 0.5 %)
  • Language
    Python
  • License
    GNU General Publi...
  • Created almost 7 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Programming Fonts with Ligatures added (& a script to add them to other fonts)

Ligaturizer

Add ligatures to any coding font!

This script copies the ligatures (glyphs and rendering information) from Fira Code into any other TrueType or OpenType font. (Note that 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.)

This repo contains a Fontforge python script that you can use to add the Fira Code ligatures to any font, as well as submodules for some popular coding fonts and another script for ligaturizing all of them at once.

Pre-ligaturized versions are available under releases.

Here's a couple examples of the fonts generated: SF Mono & Menlo with ligatures (note the != and ->):

Requirements

This Repo: You'll need the repo and its submodules, so git clone with --recurse-submodules.

Using the Fonts: See the FiraCode README for a list of supported editors.

Script: This script requires FontForge python bindings. For Debian/Ubuntu they are available in python-fontforge package. For OpenSUSE and NixOS, they are included in the fontforge package. For macOS, they are available via brew (brew install fontforge).

Using the Script

Automatic

Use automatic mode to easily convert 1 or more font(s).

  1. Put the font(s) you want into fonts/.
  2. Edit ligatures.py to disable any ligatures you don't want, and/or enable any (non-ligature) characters you want from Fira Code in addition to the ligatures.
  3. Edit build.py to add your new font(s) to the prefixed_fonts list. It supports globbing, so if (e.g.) you want to ligaturize all the different weights of FooFont you can add 'FooFont*' to the list.
  4. Run make.
  5. Retrieve the ligaturized fonts from fonts/output/.
  6. The output fonts will be renamed with the prefix "Liga".

Manual

  1. Move/copy the font you want to ligaturize into fonts/ (or somewhere else convenient).

  2. Edit ligatures.py to disable any ligatures you don't want.

  3. Run the script:

    $ fontforge -lang py -script ligaturize.py path/to/input/font.ttf
        --output-dir=path/to/output/dir/ \
        --output-name='Name of Ligaturized Font'
    

    e.g.

    $ fontforge -lang py -script ligaturize.py fonts/Cousine-Regular.ttf
        --output-dir='fonts/output/' \
        --output-name='Ligaturized Cousine'
    

    Which will produce fonts/output/LigaturizedCousine-Regular.ttf.

The font weight will be inherited from the original file; the font name will be replaced with whatever you specified in --output-name. You can also use --prefix instead, in which case the original name will be preserved and whatever you put in --prefix will be prepended to it.

ligatures.py supports some additional command line options to (e.g.) change which font ligatures are copied from or enable copying of individual character glyphs; run fontforge -lang=py ligaturize.py --help to list them.

Misc.

Credit

This 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 has made a large number of contributions.

Contributions

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

Related Projects

For more awesome programming fonts with ligatures, check out:

  1. FiraCode
  2. Hasklig

More Repositories

1

vstruct

A Lua library for packing and unpacking binary data, supporting arbitrary (byte-aligned) widths, named fields, and repetition.
Lua
106
star
2

bltool

A tool for command line interaction with backloggery.com
Clojure
78
star
3

doom-mods

A Doom mod of semi-random weapon upgrades, compatible with most iwads and other mods
ZenScript
22
star
4

ss1edit

Editing and data viewing tools for System Shock 1
Lua
9
star
5

kessler

Mods for Kerbal Space Program.
9
star
6

doomrl-server

A dgamelaunch-like frontend for DoomRL, supporting recording, spectators, and shared high scores
JavaScript
8
star
7

steamtools

A set of simple tools for working with Steam installs
Lua
8
star
8

luautil

A convenient utility library for Lua used by some of my other projects.
Lua
7
star
9

Enceladus

A program to 'freeze' a lua script and its supporting (lua) libraries into a self-contained executable.
C
6
star
10

Felt

A networked card/game table suitable for playing board and card games, using Lua and GTK+
C
5
star
11

SublimeLinter-contrib-clj-kondo

SublimeLinter support for the clj-kondo Clojure linter
Python
4
star
12

ttymor

a tty-based Dungeons of Dredmor demake
Lua
4
star
13

avr-bits

A small stack-based language for ATMega MCUs
4
star
14

ifirc

A bidirectional IFMUD <-> IRC proxy
Clojure
3
star
15

EmuFun

A frontend for launching emulators and other programs using a gamepad
Lua
2
star
16

seirc

Python
1
star
17

nono

A curses-style nonogram puzzle game
Clojure
1
star
18

mkrescue

Script to build bootable rescue USB sticks
Shell
1
star
19

xclua

A Lua plugin for the X-Chat IRC client
C
1
star
20

luapilot

Lua bindings for the Pilot high-performance cluster computing library
Shell
1
star
21

etc-nixos

nixos configuration files for the ancilla network
Nix
1
star
22

gtkspellcast

A client-server, GTK+Lua version of Andrew Plotkin's "spellcast"
Lua
1
star