Skip navigation
Currently Being Moderated

Random font script?

Mar 31, 2009 8:09 AM

Does anyone know of a script to assign random fonts to a bunch of text?

Basically, I've got a slew of words which are going to go into a collage. Instead of manually changing the font, size, weight of each, I'd like each word to be changed automatically.

I thought I'd seen one of these once, but I can't find head-nor-tail of it.

Any help?
 
Replies
  • Currently Being Moderated
    Mar 31, 2009 9:20 AM   in reply to cts_graphics
    Don't know of a script, but you might have more fun with a ransom note font. There are several free ones hanging round the Web, but I like this one that is professionally done:

    http://www.fontscape.com/explore?7AH
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 31, 2009 1:44 PM   in reply to cts_graphics
    I wrote this ages ago: <a href="http://www.adobeforums.com/webx?7@@.59b68bb0/8">randomizing type features such as leading</a>.<br /><br />Shouldn't be too hard to add random fonts to the mix.<br /><br />Notice it randomizes <br />i characters.<br />You can make it work on <br />i words<br />by ... simply changing 'characters' into 'words'. Really.<br />Oh, and change<br /><br />>for (i=0; i<app.selection[0].length; i++)<br /><br />to<br /><br />>for (i=0; i<app.selection[0].paragraphs[0].words.length; i++)
     
    |
    Mark as:
  • Currently Being Moderated
    Apr 27, 2009 6:34 AM   in reply to cts_graphics

    Hi

     

    I have got the same problem.

     

    Did you find a solution to it ?

     

    Thank you.

     

    Julien

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 27, 2009 6:55 AM   in reply to Julien-caetla

    Here's a link to the new location of the original thread that jongware mentions: http://forums.adobe.com/message/1281781#1281781

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 27, 2009 6:59 AM   in reply to Peter Spier

    THANKS A LOT !

     

    You're a life saver.

     

    Ju

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 27, 2009 7:09 AM   in reply to Julien-caetla

    This probably should get into the forum faqs, not that anyone would read it, but the way to find these old threads is to copy some bit of recognizable text from a post and paste it into the search field at the top of the page.

     

    In this case I used the title of the old thread, "randomizing type features such as leading" and it popped right up.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 27, 2009 7:57 AM   in reply to Peter Spier

    I keep this idea in my mind, i didn't think about it before.

     

    Anyway, the script works, but it's not exactly what i had in mind.

     

    I want to change the font of a text randomly, to get a "looking like" handwriting.

     

    Is there a script function which will choose randomly between two or three fonts ?

     

    Thans for all.

     

    Julien

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 27, 2009 8:08 AM   in reply to Julien-caetla

    If you want the look of handwriting, why not use a font that looks like handwriting instead of playing mix-or-match.

    http://new.myfonts.com/tags/handwriting/

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 27, 2009 8:23 AM   in reply to Peter Spier

    Because i'm working on some comics made by an artist.

     

    In order to keep the creative work he made on his comics, i want to keep the feeling for the french translation of the book.

     

    I am searching around for some javascript help for indesign, but it ain't easy.

     

    If you got an idea, i'll be glad to ear it.

     

    Ju

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 27, 2009 9:01 AM   in reply to Julien-caetla

    I'd still look for a handwriting-style font -- there were hundreds of them on that link -- that mimics the look of the original text.

     

    But if you insist on randomizing fonts, you'll need to build a loop that works though character by character and generates a random number from 1 to whatever the number of fonts you want to choose from happens to be, then uses a switch to assign a font based on that number. I'm not a scripter, but jongware's script is a good starting point, and I'd guess that the font would be assigned with a line that looks something like app.selection[0].characters[i].font =

     

    Peter

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 19, 2012 6:02 PM   in reply to cts_graphics

    did anyone come up with a finished solution?  I've got about exactly the same situation as the OP, and have been working with what I've found here, but really am a novice when it comes to scripting, so not sure I'm going to be able to pull off what I need.  Got about 800 names to put into a collage, and want to randomly assign fonts (from a set of just three or four), or at least font sizes and color (again, from a set of certain sizes and colors).  The names are two words each - first and last name - and these pairs need to match of course.

     

    Any help would be greatly appreciated.

     

    Colin

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 20, 2012 2:38 AM   in reply to CH design

    Colin, you are a bit sketchy about what you have now ... Down here below is a Javascript that assumes you have a selection of text frames (one or more), each of which may contain one or more paragraphs. The script assigns a random font and swatch from a list to each separate paragraph. It doesn't attempt to select "pairs to match", it just uses each separate paragraph.

     

    Before running the script, you must fill in the list of fonts and swatches to use. There is one peculiarity in scripting required: the font name and style MUST be separated from each other with a tab, NOT a space -- that is the special code '\t' in Javascript. (You can also type a tab but this way it's more clear what's happening). See the script for examples ("Impact" happens to have no particular style, so there I don't need a tab). No worries, the script will tell you if something is wrong.

     

    Did I mention you can add as much fonts and swatches to choose from as you want? You can -- just continue the numbering (Be Friendly to your computer and don't skip numbers either).

     

    Here is how it looks: I selected two text frames and ran my script. Then I ran it again on the same selection. Then I ran it again, just for good measures! Total randomness ensured.

    randomize.PNG

     

    And here is the Javascript (make sure to save as "randomcolor.jsx" or it won't work):

     

    // Check selection
    if (app.documents.length == 0 ||
     app.selection.length == 0)
    {
     alert ('Please make sure to have some text frames selected first!')
     exit();
    }
    var font = [];
    var swatch = [];
    font[0] = "Times New Roman\tRegular";
    font[1] = "Myriad Pro\tSemibold";
    font[2] = "Impact";
    // font[3] = "etc. etc."
     
    swatch[0] = "Red";
    swatch[1] = "C=100 M=0 Y=100 K=0";
    swatch[2] = "C=36 M=100 Y=26 K=0";
    // swatch[3] = "etc. etc."
    // Check fonts
    for (i=0; i<font.length; i++)
    {
     try {
      x = app.fonts.item(font[i]).fullName;
     } catch (_)
     {
      alert ('The font name "'+font[i]+'" cannot be found -- please check spelling etc.');
     }
    }
    // Check swatches
    for (i=0; i<swatch.length; i++)
    {
     try {
      x = app.activeDocument.swatches.item(swatch[i]).name;
     } catch (_)
     {
      alert ('The swatch name "'+swatch[i]+'" cannot be found -- please check spelling etc.');
     }
    }
    // Apply random colors and fonts!
    for (sel=0; sel<app.selection.length; sel++)
    {
     // Is this a text frame? (It better be!)
     if (app.selection[sel] instanceof TextFrame)
     {
      // Ah right. Go over each of its text lines ..
      for (par=0; par<app.selection[sel].paragraphs.length; par++)
      {
       // .. and apply random font and swatch
       app.selection[sel].paragraphs[par].appliedFont = font[Math.floor(Math.random()*font.length)];
       app.selection[sel].paragraphs[par].fillColor = swatch[Math.floor(Math.random()*swatch.length)];
      }
     }
    }
    
     
    |
    Mark as:
  • Currently Being Moderated
    Feb 21, 2012 6:18 AM   in reply to [Jongware]

    Your script here worked perfectly!  Thanks so much.  I entered the fonts and swatch colors I was using in my design, and then I added a little bit to the script so that it would randomize font sizes as well (the script chooses from among a certain set of point sizes I wanted); you can see what I added in these sections of the script here:

     

    var font = [];

    var swatch = [];

    var pointSize = [];

    font[0] = "Helvetica\tExtra Compressed";

    font[1] = "Minion Pro\tBold Cond";

    font[2] = "Trajan Pro\tBold";

    font[3] = "Minion Pro\tBold Cond Italic";

    // font[3] = "etc. etc."

     

    swatch[0] = "light brown";

    swatch[1] = "60p light brown";

    swatch[2] = "30p light brown";

    swatch[3] = "50p orange";

    swatch[4] = "25p orange";

    // swatch[3] = "etc. etc."

     

    pointSize[0] = "22.5";

    pointSize[1] = "15";

    pointSize[2] = "10";

     

    And then one more line at the very end:

     

    app.selection[sel].paragraphs[par].pointSize = pointSize[Math.floor(Math.random()*pointSize.length)];

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 21, 2012 7:00 AM   in reply to CH design

    Nice addition!

     

    Yeah that's how I learned to script as well: start with a working script, modify, then modify some more ... until you break something

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)