I tried to create python that makes a font which substitutes the string xn--e28h for the ligature but im not sure Im going about this correctly. Id like to do this for the ~1150 fully qualified unicode 15 emoji that are single code point but just testing with the smiley face for now.
from fontTools.ttLib import TTFont
from fontTools.unicode import Unicode
from fontTools.varLib.builder import addOpenTypeLigature
# Create a new font
font = TTFont()
# Define ligature glyph data
ligature_name = "xn--e28h"
ligature_unicode = [0x1F604] # Unicode code point for the smiley face emoji
# Create a ligature glyph
ligature_glyph = font.getGlyphSet().get(ligature_name)
ligature_glyph.width = 1000
# Update cmap and GSUB tables
font["cmap"].tables[0].addMapping(Unicode(*ligature_unicode), ligature_name)
# Create a GSUB lookup for ligature substitution
gsub_table = font.getGSUB()
lookup = gsub_table.table.LookupList.Lookup[0] # Replace with the appropriate lookup index
addOpenTypeLigature(lookup, ligature_name, ['x', 'n', '-', '-', 'e', '2', '8', 'h'])
# Save the font
font.save("custom_font.otf")
script errors:
line 3, in <module> from fontTools.varLib.builder import addOpenTypeLigature ImportError: cannot import name 'addOpenTypeLigature' from 'fontTools.varLib.builder' (/usr/local/lib64/python3.12/site-packages/fontTools/varLib/builder.py)