From 04f48be5696f729f6d37ab2177127ce774ff5795 Mon Sep 17 00:00:00 2001 From: Cory Todd Date: Sun, 15 Mar 2026 10:36:37 -0700 Subject: [PATCH 1/2] feature: support GSUB 6 and 4 (contextual ligs) Generate rules for when to replace the sequence with a ligature. This is based on my understanding of the Fira code approach where a marker glyph is used to prevent matching in forbidden sequences. Currently, the sequence may only trigger when surrounded by white space. --- README.md | 8 +- examples/test_liga.html | 4 + main.py | 246 +++++++++++++++++++++++++++++----------- 3 files changed, 189 insertions(+), 69 deletions(-) diff --git a/README.md b/README.md index d60999a..2065318 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ # Logo Lig Injects a PNG logo into a TTF font as a ligature. Type a trigger sequence -in any ligature-aware tool and the logo renders in place of the text. +in any ligature-aware tool and the logo renders in place of the text. The +replacement is context aware and will only trigger when the sequence is +surrounded by whitespace. ``` uv run font-lig --font input.ttf --logo cool.png --out output.ttf --sequence "cool" --family-name "Font + Cool" @@ -25,10 +27,6 @@ ligature-free fonts should all work. `--family-name` is required. Always give the output font a new name. Installing it under the original name will shadow the real font and confuse applications. -## Missing Features - -- GSUB type 5 and 6 support so patterns don't match inside a string, e.g 11 - ## Learned **Transparency.** I couldn't figure out how to make vtracer handle alpha. I kept diff --git a/examples/test_liga.html b/examples/test_liga.html index efeaaac..b109419 100644 --- a/examples/test_liga.html +++ b/examples/test_liga.html @@ -44,6 +44,10 @@

light: 219

dark: 219

red: 219

+

light: 1219

+

dark: 12191

+

red: 2191

+

red: a219