Blame apply_featurefile.py

Packit 7e316a
#!/usr/bin/python
Packit 7e316a
# Copyright (C) 2012, Aravinda VK <hallimanearavind@gmail.com>
Packit 7e316a
#                          http://aravindavk.in
Packit 7e316a
Packit 7e316a
# This program is free software: you can redistribute it and/or modify
Packit 7e316a
# it under the terms of the GNU General Public License as published by
Packit 7e316a
# the Free Software Foundation, either version 3 of the License, or
Packit 7e316a
# (at your option) any later version.
Packit 7e316a
Packit 7e316a
# This program is distributed in the hope that it will be useful,
Packit 7e316a
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 7e316a
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Packit 7e316a
# GNU General Public License for more details.
Packit 7e316a
Packit 7e316a
# You should have received a copy of the GNU General Public License
Packit 7e316a
# along with this program. If not, see <http://www.gnu.org/licenses/>.
Packit 7e316a
Packit 7e316a
import sys
Packit 7e316a
import fontforge
Packit 7e316a
Packit 7e316a
Packit 7e316a
if __name__ == "__main__":
Packit 7e316a
    if len(sys.argv) < 3:
Packit 7e316a
        print("USAGE: python apply_featurefile.py <sfd file> <featurefile>")
Packit 7e316a
    else:
Packit 7e316a
        font = fontforge.open(sys.argv[1])
Packit 7e316a
Packit 7e316a
        # Remove all GSUB lookups
Packit 7e316a
        for lookup in font.gsub_lookups:
Packit 7e316a
            font.removeLookup(lookup)
Packit 7e316a
Packit 7e316a
        # Remove all GPOS lookups 
Packit 7e316a
        # These lines are disable since gpos tables are font specific and simply importing from lohit will not help it.
Packit 7e316a
        for lookup in font.gpos_lookups:
Packit 7e316a
            font.removeLookup(lookup)        
Packit 7e316a
Packit 7e316a
        # Merge the new featurefile 
Packit 7e316a
        font.mergeFeature(sys.argv[2])
Packit 7e316a
        font.save()
Packit 7e316a
        font.close()
Packit 7e316a
        print("[SUCCESS]", sys.argv[2], "feature file applied")
Packit 7e316a