Documentation for Text to PNGs

Documentation

This page is the documentation for this program.

Contents of the settings text area

The settings area contains a list of settings, one setting per line, then a blank line, then a line of text for each text image you want the program to make up.

Each setting line has the name of the setting, then a colon, then a space, then the value for the setting. Settings can be specified in any order. Missing settings deliberately default to an unhelpful value.

The size text is drawn on the display

The only way to be sure what size the text will appear on the computer you're going to use to administer the experiment is to test some sample text on the computer you're going to use to administer the experiment.

Here's why. Originally one ‘point’ was one 72nd of an inch. So if you specified 12 point Palatino you knew your characters would take up one 6th of an inch. A text specification would look like ‘12pt Palatino on 14’ which would mean that the lines of text would be 12 points high and there'd be an extra 2 points of white space between successive lines of text.

Unfortunately displays do not tell computers how big their pixels are, so although you can specify font size in points, you can't be sure how big the font will actually be drawn. These days font sizes are normally specified in pixels: ‘px’ instead of ‘pt’. ‘12px Palatino on 14’ will exactly the match the point measurement on a display with 72 pixels per inch, but most displays have better resolution than that these days, so the text will normally be smaller.

What fonts do you have available ?

This program can write text in any font your computer makes available to your web browser. Sorry, but there's no way to have a web page list the fonts available to it. You should use the facilities provided with your operating system to show your fonts and sample text in each of your fonts. On a Macintosh, use the application Font Book. On a Windows computer, use the Fonts control panel.


Settings

widthThe width of the image measured in pixels.
width: 140
heightThe height of the image measured in pixels.
height: 100
fontThe font that will be used to draw the text. The order of the various components matters: styles first, then size, then fontname. However, doesn't seen to matter whether you spell the font name with capital letters.
font: 40px Palatino
font: 12px Arial
font: italic bold 60px Bookman
linespacingThe vertical distance, in pixels, the program should use between two successive lines of text, including the space taken up by the text itself. This is used only if you type so much text into one line of the settings area that the program has to wrap the text onto more than one line within the image.
linespacing: 44
linespacing: 14
linespacing: 64
colourThe colour in which the text will be drawn. There are two common formats. The first is ‘rgb(r,g,b)’ where r, g and b are integers from 0 to 255. The bigger the number the brighter the red, green or blue element of the colour. The second adds an extra parameter: ‘rgba(r,g,b,a)’ where the new parameter is a number from 0 to 1 which indicates how visible the text should be. 0 would give completely transparent (which would be pointless since you wouldn't see anything, and 1 would completely hide anything behind the text, which would be the same as the three-parameter format.
colour: rgb(0,0,0)
  -- black
colour: rgb(20,100,10)
  -- dark green
colour: rgb(255,200,0)
  -- bright orange
colour: rgba(255,0,0,.5)
  -- transparent bright red
colour: rgb(180,255,180)
  -- pastel green
colour: rgba(20,20,120,.8)
  -- slightly transparent dark blue
filenameThe images will be provided with filenames according to this setting. The filename should end in ‘.png’ so programs know what file format the images files use. You will want either a hash sign or a dollar sign somewhere in this parameter: a hash sign will be replaced with the image file number (starting with 1). A dollar sign will be replaced with the text written on that line.
filename: image#.png
  -- image1.png, image2.png ...
filename: $ pic.png
  -- sampletext pic.png, nextline pic.png ...
filenamefirstnumberThis is used only if you have a hash character in your ‘filename’ setting. It's used to make sure that low-number filenames are ‘01’ or ‘001’ instead of ‘1’. If you're preparing your image files in batches instead of all at once, you might want the program to skip some numbers when it puts the image numbers in the filenames. If this setting is missing, the program defaults to ‘1’.
filenamefirstnumber: 21
filenameminlengthThis is used only if you have a hash character in your ‘filename’setting. It's used to make sure that low-number filenames start with ‘01’ or ‘001’ instead of ‘1’. You can use this to ensure that your filenames sort correctly in alphanumeric lists. If this setting is missing, the program defaults to the number of digits which would be needed for all the filenames generated to be the same length.
filenameminlength: 3