You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First I tried with FontForge but found that it does not support color emoji. So Im trying my hand at fonttools...
I want to create a font that substitutes all punycodes "xn--e28h" with their equivalant emoji "😀" I would create a table or array used by the python script instead of trying to rely on parsing noto-emoji.ttf or idna tools. Here was my attempt at a proof of concept but it didnt work (error at bottom). Can anyone steer me in the right direction?
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"
#not sure if this is right, maybe need "U+000A U+1F600" or ?
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("punycode.otf")
Error:
python3 emoji4.py
Traceback (most recent call last):
File "/home/punycode.py", 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)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
First I tried with FontForge but found that it does not support color emoji. So Im trying my hand at fonttools...
I want to create a font that substitutes all punycodes "xn--e28h" with their equivalant emoji "😀" I would create a table or array used by the python script instead of trying to rely on parsing noto-emoji.ttf or idna tools. Here was my attempt at a proof of concept but it didnt work (error at bottom). Can anyone steer me in the right direction?
Error:
Beta Was this translation helpful? Give feedback.
All reactions