Here's a link to the new location of the original thread that jongware mentions: http://forums.adobe.com/message/1281781#1281781
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.
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
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
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
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
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.
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)];
}
}
}
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)];
North America
Europe, Middle East and Africa
Asia Pacific