Script to generate string kerning lists for MetricsMachine

Ramiro EspinozaRamiro Espinoza Posts: 477
edited December 2015 in Technique and Theory
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.
# 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) 

Comments

  • Ramiro EspinozaRamiro Espinoza Posts: 477
    edited December 2015
    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')
Sign In or Register to comment.