Making Alpha Characters From Fonts


Copyright © June, 2006 SuzShook

sample alphas

dot   Script Summary:

The purpose of this script is to create a sheet of formatted alphanumeric characters, or individual alphanumeric characters, from any font. This script is particularly intended for "scrappers" but can be used by anyone wishing to create a collection of formatted font characters for other graphic work. The script starts with a 500 x 500 pixel canvas and enlarges the canvas as needed if a single sheet is requested. If multiple images are to be created, the script will create an image for each character individually, format the character, and save it before proceeding to the next character. Multiple images can also be created using a pre-allocated template image.

Images created by this script will be named for the font used to create them. For example, if the Arial font is used:

Setting the AlphaType variable to 3 allows the user to use a pre-allocated template for the separate alpha characters. When this option is selected, the template will be used for each character in the CharacterSet, and the text layer will be added above the layer that is active in the Layers palette when the script runs. In addition, the alpha character will be centered before it is formatted. This option allows you to 'dress up' your final alpha images; however, you will need to experiment with the placement of any tubes or other items in your template before executing the MakingAlphas script. Here's a sample image with a flower tube used to decorate the alpha character:

using alphatype 3

The template used to create this image had 2 layers - the bottom layer was filled with white, and the next layer had the flower tube placed on it. Before running the MakingAlphas script, the bottom or white layer was made the active layer. Therefore, the text layer was inserted just above the white layer, which was below the flower tube - in this way, the alpha characters were always inserted behind the flower.

Note: The pre-allocated template, when used, will not be permanently modified by this script. When this option is chosen, the alpha character layer is deleted once the image is saved, and the template is re-used for the next character. At the end of the script, the template is closed without being saved.

The script does a considerable amount of validity checking at the beginning. For example, it checks to see whether the script is running from a Trusted folder, and whether the Format script and CharacterSet file can be found. Any failures or anomalies detected during this process are clearly reported to the user, and the script is aborted. If no problems are detected, the image or images are created and saved in the format and location specified in the user options.

IMPORTANT NOTE: Please keep the Script Output palette (SOP) open during the execution of this script - important instructions will be printed to the SOP during the execution of the script. To open the SOP, choose View...Palettes...Script Output, or press the shortcut key, F3 (SHIFT+F3 in PSP9 and above). Make the SOP large enough so that you can read the generated messages. I find that 6 inches by 4 inches works well.

dot   Installation Instructions:

  1. Place the ss-MakingAlphas script in your Scripts-Trusted folder. The script must run from the Scripts-Trusted folder because it saves and closes files.

  2. Quick Guide and related files:
    • Make a folder in your Quick Guides folder (if you don't already have one) called Scripts.
    • Within the Scripts folder, make a folder called ss-MakingAlphas.
    • Place everything from the ZIP file (except the ss-MakingAlphas script) in the Scripts\ss-MakingAlphas folder.
    • If you are working in PSP 8 or 9, you can open the MakingAlphas ReadMe file in the Learning Center. If you are working in PSP X, you can view the ReadMe file by browsing to the ss-MakingAlphas folder you created above and double-clicking on the index.htm file.

  3. I have included five sample "CharacterSet" files with this package:
    • One for lowercase letters - called ss-MakingAlphasCharacters-LowerCaseOnly.txt
    • One for uppercase letters - called ss-MakingAlphasCharacters-UpperCaseOnly.txt
    • One for numbers only - called ss-MakingAlphasCharacters-NumbersOnly.txt
    • One for non-number, non-letter "other" characters - called ss-MakingAlphasCharacters-OtherCharacters.txt
    • One for all characters found on the standard keyboard - called ss-MakingAlphasCharacters-All.txt.

    You will probably find a use for one or more of these character sets when you are creating your "alpha sheets". You can also build your own character sets - just insert one character per line, leave no blank lines, and save the resulting file as a .txt file. I would advise keeping all your character sets files in the ss-MakingAlphas Quick guide folder so that everything is together.

    You can even use ASCII characters in the CharacterSet file when you are created single alpha sheets, as long as those characters are available in the font being used.

    NOTE: Caution - do not use ASCII characters in a CharacterSet when you have requested individual images for each character (AlphaType = 2). There is a problem with this version of the script which does not allow building of the file name with ASCII characters. I am working to resolve this problem, and will publish a new version of the script as soon as I figure out why the script fails in this instance. Be aware that if you attempt to use ASCII characters when option 2 is selected for the AlphaType variable, the script will fail with a UnicodeDecodeError.

    See Notes and Tips below for tips on getting ASCII characters into your CharacterSet files for AlphaType = 2 runs. Here's a small sample I made using assorted ASCII characters:

    small ascii alpha sheet

dot   Plugin Settings:

N/A


dot   Running the Script:

Here are the actions you must take before running the MakingAlphas script:

  1. You must create a script to format the alpha characters. The ss-MakingAlphas script will create the characters for you - you need only create a script that formats them. For example, your script might add a bevel to the character, or a drop shadow, or apply an effect. You can do anything you want to format the characters in your script - just be sure the steps are all set to run in Silent mode so that your MakingAlphas script can run unattended (sample included in ZIP called ss-MakingAlphas-SampleFormatScript.PspScript).

    See Note and Tips below for tips on format scripts.

  2. You must update the MakingAlphas script, inserting the proper information into the User-Defined Variables section of the script. That section, found at the beginning of the script (lines 34 - 44), looks like this:

    Here's that same section, with the variables filled in on my system:

    Your path names might be considerably longer than mine, especially if you are using the My Documents location for your PSP files. Just be sure you have the complete path name for each of the first three variables. See Notes and Tips section below for tips on extracting complete path names.

    Each of the seven variables listed above is fully documented in the script - you will want to read the included documentation when you update those fields. Briefly, here's what each of these fields represents:

    • SaveLocation - complete path to folder to store saved alpha image(s)
    • FormatScript - complete path to your format script file
    • CharacterSet - complete path to the text file containing characters to process
    • Identifier - unique identifier to be appended to each alpha image name (optional)
    • AlphaType - type of image(s) you wish to save (choose 1 to save all characters on a single sheet; choose 2 to save each character as a separate image; choose 3 to save separate images, using a pre-allocated template image)
    • SaveType - format in which you want to save images (you can choose 1 to save images in PSP 8-compatible format (pspimage extension), 2 to save images in PSP 7-compatible format (psp extension), or 3 to save images as PNG files)
    • Multiplier - variable used to control size of image for single alpha sheets

  3. You must set all the options for the text font in the Text tool Tool Options palette before running the script. An open document is required to access the Text Tool Options palette - just create any image, set your options, and delete the image. You can control more all Text tool options for this script, as noted below:
    • Select the font 'Name'.
    • Select the 'Size' of the font.
      NOTE: Maximum size allowed in this script is 500 pixels. Using a larger font size slows down the process considerably, and may cause PSP to crash. Therefore, if you choose a font size greater than 500 pixels, it will be changed by the script to 500.
    • Select the 'Stroke width' for the font. Set this parameter to 0 if you do not want a stroke on your text.
    • Set the 'Kerning' value for your text.
    • Set the 'Leading' value for your text.
    • Select the 'Font style'option(s) for your text. You can select from bold, italic, underline, and strikethru.
    • Select the 'Anti-alias' option for your text.
    • Set the 'Stroke width' value for your text.
    • Set the 'Line style' value for your text.
    • Set the 'Warp text' option, if desired.
    • In PSP X, set the 'Units' parameter to Pixels. As there is no way for the script to determine the setting for this parameter, unpredictable results will occur if it is not set to Pixels.
    • Make sure the 'Remember text' box is UNchecked in the Text Entry dialog - if this box is checked, the last used font will be used, and not the font chosen in the Text Tool Options palette.

  4. You must choose the materials you want for the text in the Materials palette:
    • Select the stroke (outline) material in the Foreground Material box.
    • Select the fill material in the Background Material box.

  5. If you choose 3 for the AlphaType variable, you must have a pre-allocated image open in your workspace, and the active layer in this image must be the layer that you want below the alpha character. This image will be used for all separate alpha characters.

  6. Finally, in order to ensure that the text renders correctly, if you are running the MakingAlphas script in PSP X, you must change the Host Version line (line 9 in the script) from:
    'Host Version': u''

    to:

    'Host Version': u'10'
    Note: It is extremely important that the Host Version says 10 (or 10.01 or 10.02 or 10.03 - it's the 10 that's important). Text will not render correctly (or predictably) in PSP X if the system does not know you are running that version. You "tell" PSP you are running PSP X using the Host Version parameter. Thus, for text to render correctly in PSP X, it is essential that you set this parameter to 10, and set the Text Units parameter to Pixels.

    Leaving the Host Version set to '10' won't prevent the script from running in other versions of PSP. You may get this warning message in lower versions of PSP:

    version warning message

    but you can safely click the OK button and continue processing the script.

When you have completed the above tasks, you are ready to run the MakingAlphas script. Find the ss-MakingAlphas script in the Select Script droplist on the Script toolbar, make sure the Toggle Execution Mode button is set to run the script in Silent mode, and click on the Run Selected Script button to run.

The first part of the script generates a Welcome message which reminds the user about the preliminary steps that must be taken. Read these instructions carefully to be sure all is in place for this script to run successfully. Move the Message Box out of the way so you can read what has been printed in the Script Output palette (SOP). If you don't have the SOP open, click on the Cancel button in the Welcome message, activate the SOP, and then start the script again.

When you click the OK button in the script summary Message Box, the script continues and lists the options you have chosen in the SOP. If these are correct, click to OK button to proceed. If there are errors, click the Cancel button to stop the script, correct the errors, and restart the script.

When all has been verified, the script builds the alpha characters image(s), adding your formatting and saving the image(s) in your chosen location.

Note: Be aware that this process can be very slow when building a single sheet with a large font character size and a complex Format script. The script may slow to a crawl at times. Note that the script is not complete until the "Mission accomplished!" message appears in the SOP.



dot   Change History:




Notes and Tips:
checkmark To get the path name "right" for a folder, try the following:
  1. Browse to the folder whose name you need.
  2. In the Address box at the top of the screen, highlight the address of the folder (Hint: press the Tab key - it moves you to the Address box and highlights the address).
  3. Copy the address/path name (CTRL+C).
  4. Return to the MakingAlphas script and paste the path name (CTRL+V) between the quotes in the User-Defined Variables section of the script.
checkmark To get the text file or script file name correct, try the following:
  1. Browse to the folder that contains the script or text file whose name you need.
  2. Left-click on the script/file name.
  3. Press F2 as if to Rename the file - this will highlight the entire file name in the Rename box.
  4. Copy the name (CTRL+C).
  5. Click anywhere outside the Rename box (or press the ESC key) to cancel the Rename.
  6. Return to the MakingAlphas script and paste (CTRL+V) the name of the script/file in place at the end of the path name in the User Defined Variables section of the script.
    Note: If there is no backslash (\) at the end of the path name, you will have to add one before inserting the script/file name.
checkmark An even easier way to get the file path names correct is to download and install one of the free utilities that does the work for you. With these utilities, all you have to do is right-click on the name of the file, choose Copy Path (or Copy File Path - depending on which utility you use), and the complete path is copied to the clipboard. Then all you have to do is return to the MakingAlphas script, place your cursor where you want the path, and paste (Edit...Paste, or CTRL + V). Here are the links to two such utilities - the first one has several "copy path" options, while the second is a simpler copy, without the additional foldout menus:
Ninotech Path Copy 4.0
Letterman Stationery Copy File Path
checkmark

Some fonts have unassigned keystrokes and these may show up as small rectangular boxes that look like this:

unassigned keystrokes box shape

In most cases, the script recognizes these boxes, and eliminates them, but in some cases, they may still be printed.

checkmark

In rare cases, the code I use to distinguish unassigned keystroke boxes from valid characters may eliminate valid characters. If this happens, and you really want that missing character, create a new image for the missing character after the script completes and run your formatting script on the image. If you saved individual characters as separate images, save this character image the same way, using the same naming convention for the image. If you saved the characters for the font as a single image, copy the image as a new layer into the character sheet for this font, move it into a clear location so it won't overlay other characters, and merge the layers.

Note: When a character is skipped because the script determines that character is an unassigned keystroke or a "box" character, a message is generated to the SOP clearly indicating this has occurred. For an unassigned keystrokes - for example, an uppercase M - the message will say:

NOTE: Unmapped keystroke (M) - not printed!

For a character the script determines is a "box" character - for example, the * character - the message will say:

NOTE: Box shaped character (*) - not printed!

This way, it will be easy to scan the SOP for any missing characters.

checkmark Be very careful when creating format scripts for use with the Making Alpha Characters script. Remember that your script should be flexible enough to work with any font, no matter what size is chosen for the font. Actions using the Magic Wand and Fill steps are not recommended in format scripts because these commands depend upon a specific pixel where you click, either to select with the Magic Wand, or to fill an area, and the specific location you use when you create the format script might not be applicable with another font, character, or font or image size. When you've developed a format script that works consistently on widely different image sizes, different fonts, different characters within fonts, and different font sizes, you've probably got a winner!

checkmark If a character is saved that is not wanted, that image can simply be deleted from the folder where the images were saved. In the case where a single sheet of all characters was made, the unwanted character can be selected with the selection tool and deleted.

checkmark This script takes into account the size of each character it prints when making a single sheet of alpha characters. Great care has been taken to program the script so that no character is "off the page" - characters positioned too high on the page will be moved down; characters placed too close to other characters will be adjusted to the right, or down; characters too close to the right edge of the sheet, or partially off the sheet on the right side, will be removed and placed on the next line. The moves required to make this happen are especially needed with flowery, flowing fonts that have lots of loops and decorations, or long, flowing tails, etc. If you experience any problems with characters generated by this script, please let me know.

checkmark In order to accommodate at least the 94 keyboard characters, a large image is used when a single alpha sheet is chosen by the user. If you find the image is not large enough to accommodate all characters in the font you have chosen, increase the value of the Multiplier variable in the user-defined variables section of the script. The default setting for this variable is 15, which will produce an image 15 times wider and higher than the font size chosen. Thus, if a font size of 500 is chosen, the single sheet size will be 15 times this size, or 7500 x 7500 pixels.

checkmark The final single sheet image might not be completely filled. You might want to crop the image to save disk space. Just open the saved image, crop, and then re-save.
checkmark For individual character images, a small initial image size is chosen (500 x 500 pixels). The characters are written to this image and then copied to new images before formatting. Don't worry if the characters do not "fit into" this image - it just serves as a starting point, and all images generated are large enough for the characters they hold.

checkmark When using a template for individual character images, the character will be placed on a new layer above the active layer in the image. Therefore, be sure to activate the layer you want to appear below your alpha character before running the script.

checkmark One way to create alpha sheets that are smaller in size is to place uppercase letters only on one sheet, lowercase letters on a second sheet, and numbers and other (non-number, non-letter) characters on a third sheet.

checkmark Interesting outlined letters can be achieved by setting the Background Material to Transparent (Null), and using a different line style for the letters:

using line styles

checkmark If you rerun this script using the same font and using the same unique identifier and placing the finished image(s) in the same location, previously created images will be overlaid without warning.

checkmark A "testing mode" is included with this script. When this mode is enabled, much information is written to the SOP, which can help in debugging if the script fails or produces unexpected results. To enable the testing mode, change this line (line 23) in the script:
TestMode = 'No'

to this:

TestMode = 'Yes'
checkmark To check which characters are available in a font, open Windows Character Map by choosing Start...All Programs...Accessories...System Tools...Character Map. Select the font you wish to check in the Font droplist at the top of the Character Map window (#1 below). All installed or open fonts will be listed. Here's what the Character Map dialog looks like:

windows character map

checkmark To add "special characters" to a CharacterSet:
  • Open Windows Character Map (see above).
  • Select the font you are going to use in the Font droplist at the top of the Character Map window (#1 in the screen capture image above).
  • Scroll to find the character you want to use - in the image above, the copyright character has been selected (#5 above).
  • Double-click on the character you want to add to your CharacterSet data set, or single-click on the character, then click on the Select button (#2 above). The character you select will show up in the "Characters to copy" box to the left of the Select button (#4 above).
  • Click the Copy button (#3 above) or use the copy shortcut, CTRL + C.
  • Open your CharacterSet document and position the insertion point where you want the special character to appear.
  • On the Edit menu, click Paste (CTRL + V).
    Note: Depending on the program you are using to edit your CharacterSet document, you may even be able to copy characters by dragging them from Character Map directly into an open document.

You can also select many characters - they will fill up the "Characters to copy" box (#4 above). Just remember that each character has to be on a separate line in your CharacterSet document, or the group of characters will print as a single character. To separate characters when many of them are on one line, position your cursor after the first character and hit ENTER. Continue until each character is on its own line.