Script to generate kerning strings for MetricsMachine

Ramiro Espinoza
Posts: 839
Hi there,
I love using MetricsMachine, but I've never liked the fact I can't use my Fontlab kerning text files. Metrics machine uses 2 different kind of kerning text files: one for single pairs and another one that let you set and compare strings.
Setting strings is key (e.g. when setting the kerning in capitals, when comparing kern symmetry and when kerning quotes), but the problem is making string kerning lists for MM by hand is a pain and tools like Impallari's kerning list maker (http://www.impallari.com/testing/) only let you make the simplest kind of kerning text files.
So I've made a simple Python script to automatically generate string kerning text files. Feel free to use/improve it.
I love using MetricsMachine, but I've never liked the fact I can't use my Fontlab kerning text files. Metrics machine uses 2 different kind of kerning text files: one for single pairs and another one that let you set and compare strings.
Setting strings is key (e.g. when setting the kerning in capitals, when comparing kern symmetry and when kerning quotes), but the problem is making string kerning lists for MM by hand is a pain and tools like Impallari's kerning list maker (http://www.impallari.com/testing/) only let you make the simplest kind of kerning text files.
So I've made a simple Python script to automatically generate string kerning text files. Feel free to use/improve it.
# ReType's Make string kerning lists for MetricsMachine # Tweak / Comment from line 4 to 7 if you are using a PC. import sys sys.dont_write_bytecode = True f = open(title + '.txt', 'w') sys.stdout = f # Set the title title = 'UC_symmetry' # Set your own strings string_1 = 'AVAWATAYAVSVSWSW' string_2 = 'AOAQAPAFASAYSY' string_3 = 'OVOWOTOYO' print '#KPL:W: '+ title for x in range((len(string_1))-1): stringlist = list(string_1) stringlist.insert(x+1,' ') print ''.join(stringlist) for x in range((len(string_2))-1): stringlist = list(string_2) stringlist.insert(x+1,' ') print ''.join(stringlist) for x in range((len(string_3))-1): stringlist = list(string_3) stringlist.insert(x+1,' ') print ''.join(stringlist)
Tagged:
4
Comments
-
I've made a more efficient version with a function:
# ReType's Make string kerning lists for MetricsMachine # Set the title title = 'UC_symmetry' # Tweak / Comment from line 7 to 10 if you are using a PC. import sys sys.dont_write_bytecode = True f = open(title + '.txt', 'w') sys.stdout = f print '#KPL:W: '+ title def Make_kerning_list(string): for x in range((len(string))-1): stringlist = list(string) stringlist.insert(x+1,' ') print ''.join(stringlist) # Set your own strings Make_kerning_list('AVAWATAYAVSVSWSW') Make_kerning_list('AOAQAPAFASAYSY') Make_kerning_list('OVOWOTOYO')
1 -
Hi there,
I just updated my script so it now can take strings set with slashes (for example: "/one.lf/period/two.lf/period ...etc"
Now it is way simpler to adapt your Fontlab strings to MetricsMachine# ReType's Make string kerning lists for MetricsMachine 3.0 # Set the title title = 'MetricMachine_kerning_block' # Tweak / Comment from line 7 to 10 if you are using a PC. import sys sys.dont_write_bytecode = True f = open(title + '.txt', 'w') sys.stdout = f print '#KPL:W: '+ title def makeString(string): list = string.split() for x in range(len(list) - 1): list.insert(x + 1, ' ') print ''.join(list) list.pop(x + 1) #Example: format your string in this way (space separated) makeString( '/one.lf /comma /two.lf /comma /three.lf /comma /four.lf /comma /five.lf /comma /six.lf /comma /seven.lf /comma /eight.lf /comma /nine.lf' )
0 -
thank you for sharing this! pretty helpful I think! Somehow in my case with RF the saved txt file was empty when I tried your example with /glyphnames. I modified it a bit and now it is working here - also added a fontpath as a variable:
# ReType's Make string kerning lists for MetricsMachine 3.1 import sys # Set the title and path for export .txt title = 'MetricMachine_kerning_block' fontPath = "/Users/yourUserName/Desktop/" finallist = [] finallist.append('#KPL:W: '+ title) def makeString(string): list = string.split() for x in range(len(list) - 1): list.insert(x + 1, ' ') finallist.append(str(''.join(list))) list.pop(x + 1) def exportFile(): f = open(fontPath+title + '.txt', 'w') f.write('\n'.join(finallist)) f.close #Example: format your string in this way (space separated) makeString( '/one.lf /comma /two.lf /comma /three.lf /comma /four.lf /comma /five.lf /comma /six.lf /comma /seven.lf /comma /eight.lf /comma /nine.lf' ) # write the file exportFile()<br>
0 -
Hi Lukas,
Thanks for the contribution. I should have said I wasn't running the script from Robofont or Fontlab. It was intended to be run with Terminal (actually, I do it from TextWrangler).0
Categories
- All Categories
- 46 Introductions
- 3.8K Typeface Design
- 475 Type Design Critiques
- 555 Type Design Software
- 1.1K Type Design Technique & Theory
- 640 Type Business
- 830 Font Technology
- 29 Punchcutting
- 507 Typography
- 120 Type Education
- 313 Type History
- 74 Type Resources
- 109 Lettering and Calligraphy
- 30 Lettering Critiques
- 79 Lettering Technique & Theory
- 529 Announcements
- 84 Events
- 110 Job Postings
- 165 Type Releases
- 169 Miscellaneous News
- 274 About TypeDrawers
- 54 TypeDrawers Announcements
- 118 Suggestions and Bug Reports