Simple script: test in batch if all tabular and fixed width values are correct

Ramiro EspinozaRamiro Espinoza Posts: 751
edited December 2016 in Font Technology
Hi there,

Here is another simple script I wrote for Fontlab (it should also work in Robofont I think) to test if all fixed width glyphs have the right value in all open font. You can easily adapt it to your foundry production standards editing the glyph lists and variables at the top.

#FLM: ReType Tabular Checker V1.0
#Test if tabular and non spacing glyphs have the right width

from robofab.world import CurrentFont,AllFonts

numbers = ["zero.tosf","one.tosf","two.tosf","three.tosf","four.tosf","five.tosf","six.tosf","seven.tosf","eight.tosf","nine.tosf","zero.tf","one.tf","two.tf","three.tf","four.tf","five.tf","six.tf","seven.tf","eight.tf","nine.tf"]
operators = ["plus","minus","equal","multiply","divide","plusminus","approxequal","logicalnot","notequal","lessequal","greaterequal","less","greater","asciicircum"]
currencies = ["Euro.tf","dollar.tf","cent.tf","sterling.tf","yen.tf","florin.tf"]
diacritics = ["gravecomb","acutecomb","uni0302","tildecomb","uni0304","uni0306","uni0307","uni0308","uni030A","uni030B","uni030C","uni0312","uni0313","uni0326","uni0327","uni0328","gravecomb.case","acutecomb.case","uni0302.case","tildecomb.case","uni0304.case","uni0306.case","uni0307.case","uni0308.case","uni030A.case","uni030B.case","uni030C.case","uni0326.case","uni0327.case","uni0328.case","gravecomb.sc","acutecomb.sc","uni0302.sc","tildecomb.sc","uni0304.sc","uni0306.sc","uni0307.sc","uni0308.sc","uni030A.sc","uni030B.sc","uni030C.sc","uni0326.sc","uni0327.sc","uni0328.sc"]

tabWidth = 698
operatorsWidth = 500
diacriticsWidth = 1

def checkTabNumbers(font):
	for n in font:
		for i in numbers:
			if n.name == i:
				if n.width != tabWidth:
					print "Tab value of " + n.name + " is NOT correct <---"
					n.mark = 250
					
def checkOperators(font):
	for n in font:
		for i in operators:
			if n.name == i:
				if n.width != operatorsWidth:
					print "Tab value of " + n.name + " is NOT correct <---"
					n.mark = 250
					
def checkCurrencies(font):
	for n in font:
		for i in currencies:
			if n.name == i:
				if n.width != tabWidth:
					print "Tab value of " + n.name + " is NOT correct <---"
					n.mark = 250

def checkDiacritics(font):
	for n in font:
		for i in diacritics:
			if n.name == i:
				if n.width != diacriticsWidth:
					print "Tab value of " + n.name + " is NOT correct <---"	
					n.mark = 250


for x in AllFonts():
	print
	print x.info.postscriptFullName
	print
	checkTabNumbers(x)
	checkOperators(x)
	checkDiacritics(x)
	checkCurrencies(x)
	print "_______________________________________"
	x.update()
	
	
print
print "Ready the chicken!!"


Comments

  • Thanks Ramiro! Have you considered publishing this on Github? 

    I also suggest declaring what kind of libre license you intend for this - I guess MIT, similar to RoboFab/etc?

  • Vassil KatelievVassil Kateliev Posts: 54
    edited January 2017
    A bit more versatile, but definately more Pythonian and de-robofabed version.

    #FLM: Check Tabular Widths 1.2 (based on ReType.com Tabular Checker 1.0)

Sign In or Register to comment.