| 1 |
#!/usr/bin/python |
| 2 |
# Copyright (C) 2012, Aravinda VK <[email protected]> |
| 3 |
# http://aravindavk.in |
| 4 |
|
| 5 |
# This program is free software: you can redistribute it and/or modify |
| 6 |
# it under the terms of the GNU General Public License as published by |
| 7 |
# the Free Software Foundation, either version 3 of the License, or |
| 8 |
# (at your option) any later version. |
| 9 |
|
| 10 |
# This program is distributed in the hope that it will be useful, |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU General Public License for more details. |
| 14 |
|
| 15 |
# You should have received a copy of the GNU General Public License |
| 16 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
import sys |
| 19 |
import fontforge |
| 20 |
|
| 21 |
|
| 22 |
if __name__ == "__main__": |
| 23 |
if len(sys.argv) < 3: |
| 24 |
print("USAGE: python apply_featurefile.py <sfd file> <featurefile>") |
| 25 |
else: |
| 26 |
font = fontforge.open(sys.argv[1]) |
| 27 |
|
| 28 |
# Remove all GSUB lookups |
| 29 |
for lookup in font.gsub_lookups: |
| 30 |
font.removeLookup(lookup) |
| 31 |
|
| 32 |
# Remove all GPOS lookups |
| 33 |
# These lines are disable since gpos tables are font specific and simply importing from lohit will not help it. |
| 34 |
for lookup in font.gpos_lookups: |
| 35 |
font.removeLookup(lookup) |
| 36 |
|
| 37 |
# Merge the new featurefile |
| 38 |
font.mergeFeature(sys.argv[2]) |
| 39 |
font.save() |
| 40 |
font.close() |
| 41 |
print("[SUCCESS]", sys.argv[2], "feature file applied") |
| 42 |
|