Created
November 4, 2024 11:22
-
-
Save ravshansbox/b79d0b58a7af1cc949c8d6543d2a7177 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/fontforge | |
import fontforge | |
import sys | |
# Check if input and output paths are provided | |
if len(sys.argv) < 3: | |
print("Usage: fontforge -script remove_features.py input.ttf output.ttf") | |
sys.exit(1) | |
input_font = sys.argv[1] | |
output_font = sys.argv[2] | |
# Open the font | |
font = fontforge.open(input_font) | |
# Remove 'calt' (Contextual Alternates) feature if it exists | |
if font.gsub_lookups is not None: | |
for lookup in font.gsub_lookups: | |
for feature, script_lang_list in font.getLookupInfo(lookup)[2]: | |
if feature == 'calt': | |
font.removeLookup(lookup) | |
# Remove 'liga' (Standard Ligatures) feature if it exists | |
if font.gsub_lookups is not None: | |
for lookup in font.gsub_lookups: | |
for feature, script_lang_list in font.getLookupInfo(lookup)[2]: | |
if feature == 'liga': | |
font.removeLookup(lookup) | |
# Generate the modified font | |
font.generate(output_font) | |
font.close() | |
print(f"Successfully removed 'calt' and 'liga' features from {input_font} and saved to {output_font}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment