Skip to main content
October 12, 2010
Question

How to make a handwriting font look like real handwriting in InDesign CS5

  • October 12, 2010
  • 2 replies
  • 16840 views

This is a script I've written (AppleScript) that addresses the  problem most handwriting fonts have — they look like fonts, mostly  because they're settled so regularly along the baseline and their glyphs  are so uniform.

It began as a way for me to address a  need for a project I was working on, something designed to look like a  scrapbook. I was using the "Journal" typeface designed by Fontourist  (http://www.dafont.com/journal.font), which gave me a good balance of  readability and organic feel, but of course it had the same issues as  all other fonts of its ilk.

To address that I wrote a  script to trawl the taxt frames in a specified CS5 INDD document,  looking fist to see if they had that font as their active one, after  which the script shifts each glyph up or down the baseline by a random  amount, gives each glyph a random stroke weight change, and finally  tints each glyph a random amount off of its basic tint.

Each  of these changes is very subtle, with the result being something that  looks considerably more organic and hand-made than the font did out of  the can. The script should be easily modified by anyone who wants to run  it using a different font instead of "Journal". Here it is. Enjoy!

--

-- This script changes the  baseline offset, stroke width, and color tint
-- of any type set in the "Journal" typeface to randomized values,  giving
-- the text a much more organic look and feel.

-- Written by Warren Ockrassa,  http://indigestible.nightwares.com/
-- Free to use, modify and distribute, but I'd prefer attribution.

-- Note that this script can take quite a while to execute with  larger
-- or more complex files.

set theItem to 0

set theItem to choose file with prompt "Select a CS5 InDesign  document to modify..."

if theItem is not equal to 0 then
    
     tell application "Adobe InDesign CS5"
        
         open theItem
        
         tell active document
            
             -- Determine how many text frames we need to change
            
             set myFrames to the number of text frames
            
             if myFrames is not equal to 0 then
                
                 set theFrame to 1
                
                 repeat until theFrame > myFrames
                    
                     set myText to text frame theFrame
                     set myFont to applied font of character 1 of myText  as string
                    
                     -- Check to make sure we're only modifying text  frames
                     -- that have been set in the "Journal" typeface
                    
                     if word 1 of myFont is "Journal" then
                        
                         repeat with thisCharacter in (characters of  myText)
                            
                             -- Randomize the values of baseline shift,  stroke, and tint
                            
                             set baselineShift to ((random number from -5  to 5) / 10)
                             set strokeWeight to (((random number 10)) /  100)
                             set myTint to (100 - (random number 10))
                             set fillColor to fill color of thisCharacter
                             set baseline shift of thisCharacter to  baselineShift
                             set stroke color of thisCharacter to  fillColor
                             set stroke weight of thisCharacter to  strokeWeight
                             set fill tint of thisCharacter to myTint
                             set stroke tint of thisCharacter to myTint
                            
                         end repeat
                        
                     end if
                    
                     set theFrame to (theFrame + 1)
                    
                 end repeat
                
             end if
            
         end tell
        
     end tell
    
     beep
     display dialog "Modifications finished!" buttons {"Groovy!"} default  button 1
    
else
    
     display dialog "Operation cancelled" buttons {"OK"} default button 1
    
end if

This topic has been closed for replies.

2 replies

Participant
February 20, 2012

I need to do something similar to this - but need to vary the size and font.  I need to have a script assign random fonts to words (I'd have a set of three or four fonts I'd want the script to choose from).

How to I revise this type script to make that happen?

Thanks!

February 21, 2012

For the fonts, the really cheap and dirty method would probably be to load the names of the fonts you want to use into an array variable in the AppleScript, then get a random index count to grab one of the font names out of that array.

The script as it exists now goes character by character - you'd want to revise it so it went word by word instead, or else you'd end up setting each word's character to one of your random font choices. Instead of

repeat with thisCharacter in (characters of  myText)

you'd do something like

repeat with thisWord in (words of  myText)

As for loading an array variable in AppleScript - I've not done that before, but it's probably something like:

set myFontArray to {"Papyrus", "Arial", "Comic Sans"}

The curly braces are necessary, as it appears that AppleScript supports lists rather than arrays (a minor but not entirely unimportant detail). Anyway, from there, you'd grab one font at a time, randomly, probably like this:

set myWordFontNumber to random ( length of myFontArray ) - 1

  set myWordFont to item myWordFontNumber of myFontArray

You do the first line to get a random number based on the number of items in your list of fonts. You subtract 1 from it because the count on the actual list begins at 0 rather than 1, which means that sometimes you'll get a random number that's actually 1 larger than the number of items in the list, and you'll never see the first item (which is at position 0). This is a very old-school gotcha when working with arrays and lists - a ten-item list will count from 0 to 9, not 1 to 10.

From there, you'd set the given word in your text frame's font to the name of the font you pulled out of the myFontArray variable. You'll want to make sure that the font names you load into your list are the actual names of the fonts you're working with - the examples I used here probably won't work.

Please note that this is just a high-level gloss of what you'd need to do in order to modify the script. You'll have to hit the AppleScript documentation (and InDesign's scripting documentation) to get the precise syntax.

Participant
March 9, 2012

Thanks for the help here.  I was able to put together a solution for exactly what I needed with the help of some others here too, using Javascript, shown here in this discussion: http://forums.adobe.com/message/4220016#4220016

Participant
December 17, 2010

Hi, can you tell me how to make that script compatible with windows vbscript

December 17, 2010

Me? No, I can't. I've never worked with VBScript. Sorry!