import datetime
import os


##################################################
# Running the Script will output the control strings in a PDF
# it will look for a folder called REVIEWS in the same directory
# as your .UFO file. You'll need to make this folder first

##################################################
# CHANGE THESE 
PDF = True 
bigSizes = [54,40,36,24]
smallSizes = [18,14,12,11,10,9,8,7,6]

###################################################


date = datetime.datetime.now()
today = date.strftime("%Y-%m-%d at %H.%M.%S")

f = CurrentFont()
basepath = os.path.dirname(f.path)
fontName = '%s-%s' % (f.info.familyName, f.info.styleName)
fontName = fontName.replace(' ', '')
print(basepath)

proof = 'Control Strings'
strings = ['HHDHOHODOO','nnpnonopoo','HHnnHH','OOooOO']

margin = 36

controlStrings = FormattedString()


# check if font is installed
f.testInstall()

def drawLabel():
    label = FormattedString()
    label.fontSize(6.5)
    label.font('Helvetica')
    label.append(fontName + ' ')
    label.append(today)
    label.append('\t'+proof)
    textBox(label,(margin,0,W,24))
    
def drawStrings(x):
    controlStrings.font(fontName)
    for size in x:
        print(size)
        controlStrings.fontSize(size)
        # controlStrings.lineHeight(size*1.4)
        for string in strings:
            controlStrings.append(string + ' ',font=fontName)
        
        controlStrings.append('\n' + str(size),font="Helvetica",fontSize=6.5,align="right")
        tabs((600,"right"))
        controlStrings.append('\n',align="left")

        stroke(None)
    textBox(controlStrings,(margin,margin,W-margin*2,H-margin*3))

newPage('LetterLandscape')
W = width()
H = height()


drawStrings(bigSizes)
drawLabel()

newPage('LetterLandscape')
W = width()
H = height()
controlStrings = FormattedString()

drawStrings(smallSizes)
drawLabel()

if PDF:
    saveImage(basepath+'/REVIEWS/'+fontName+' '+proof+' '+today+'.pdf')


print(fontName, today)