Blame apply_featurefile.py

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