Skip to content

Commit bc4b25e

Browse files
committed
Modified the generateSingleKernFile script to do a similar operation in creating mark feature files from a single UFO master.
1 parent b0327be commit bc4b25e

1 file changed

Lines changed: 89 additions & 0 deletions

File tree

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/usr/bin/python
2+
3+
###################################################
4+
### THE VALUES BELOW CAN BE EDITED AS NEEDED ######
5+
###################################################
6+
7+
writeClassesFile = True # TRUE: Writes mark classes to external file. FALSE: Writes mark classes as part of mark.fea file.
8+
genMkmkFeature = True # TRUE: Writes mkmk.fea file. FALSE: Ignores mark-to-mark placement.
9+
indianScriptsFormat = True # TRUE: Writes abvm.fea and blwm.fea files. FALSE: Writes simple mark.fea file.
10+
trimCasingTags = True # TRUE: Trims casing tags so that all marks can be applied to UC/LC. FALSE: Leaves casing tags as is.
11+
12+
13+
libraryNotFound = False
14+
15+
import os, sys, re, copy, math, time
16+
try:
17+
from defcon import Font
18+
except:
19+
print "ERROR: This script requires defcon. It can be downloaded from https://github.com/typesupply/defcon"
20+
libraryNotFound = True
21+
try:
22+
import WriteFeaturesMarkFDK
23+
except:
24+
print "ERROR: This script requires WriteFeaturesMarkFDK.py. It can be downloaded from https://github.com/adobe-type-tools/python-modules"
25+
libraryNotFound = True
26+
27+
if libraryNotFound:
28+
sys.exit()
29+
30+
31+
def generateMarkFiles(font):
32+
33+
folderPath, fontFileName = os.path.split(font)
34+
# path to the folder where the font is contained and the font's file name
35+
os.chdir(folderPath)
36+
37+
ufoFont = Font(fontFileName)
38+
ufoBaseName = os.path.splitext(fontFileName)[0]
39+
# markFileName = 'mark_%s.fea' % ufoBaseName
40+
styleName = ufoFont.info.styleName
41+
42+
print '*******************************'
43+
print 'Exporting mark files for %s...' % (styleName)
44+
45+
WriteFeaturesMarkFDK.MarkDataClass(ufoFont, folderPath, trimCasingTags, genMkmkFeature, writeClassesFile, indianScriptsFormat)
46+
47+
48+
def run():
49+
# if a path is provided
50+
if len(sys.argv[1:]):
51+
baseFolderPath = sys.argv[1]
52+
53+
if baseFolderPath[-1] == '/': # remove last slash if present
54+
baseFolderPath = baseFolderPath[:-1]
55+
56+
# make sure the path is valid
57+
if not os.path.isdir(baseFolderPath):
58+
print 'Invalid directory.'
59+
return
60+
61+
# if a path is not provided, use the current directory
62+
else:
63+
baseFolderPath = os.getcwd()
64+
65+
t1 = time.time()
66+
67+
fontPath = os.path.abspath(sys.argv[-1])
68+
69+
print fontPath
70+
fontsList = []
71+
72+
if os.path.exists(fontPath) and fontPath.lower().endswith('.ufo'):
73+
generateMarkFiles(fontPath)
74+
75+
else:
76+
print "No fonts found"
77+
return
78+
79+
t2 = time.time()
80+
elapsedSeconds = t2-t1
81+
82+
if (elapsedSeconds/60) < 1:
83+
print 'Completed in %.1f seconds.' % elapsedSeconds
84+
else:
85+
print 'Completed in %.1f minutes.' % (elapsedSeconds/60)
86+
87+
88+
if __name__=='__main__':
89+
run()

0 commit comments

Comments
 (0)