Blame apply_featurefile.py

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