Copy link to clipboard
Copied
I’m working with PDF files in illustrator and whenever the file uses Helvetica I have to change the font to Arial. This gets old when working with hundreds of illustrations. Can anyone tell me how I would go about changing all text that uses Helvetica bold to Arial bold and Helvetica Roman to Arial?
Would I loop through all the text frames and get the value of the font and use that value to change them or is there a more global way to go about this?
Any help would be appreciated,
Duane
1 Correct answer
DuanesSearchForKnowledge wrote:
… If there was a way to find the font used in the file and select thetext using that font it seems it would be possible to change it to one of these fonts. I dont know enough about it to know if it is possible or not.
Thanks for the info,
Duane
Look at this example:
...if (app.documents.length > 0 ) {
var doc = app.activeDocument;
var aFont = (doc.textFrames[0].textRange.textFont)
// You always need the correct internal text font name
// change to regular, if
Explore related tutorials & articles
Copy link to clipboard
Copied
You can create an Action to do this and in CS6 run the action by using the doScript construct.
Copy link to clipboard
Copied
Intriguing!!!
I am stuck with CS 5 for now. I assume this doScript construct is only available in CS6?
Thanks for the info,
Duane
Copy link to clipboard
Copied
For ExtendScript, yes. For AppleScript and VBS, no.
Copy link to clipboard
Copied
A more global way would be to use the app's 'Find Font' feature…? Im not a user of actions so you could test if it's recordable and you could use with actions and batch…
Copy link to clipboard
Copied
I tried and it is indeed recordable. You could do it as a two part action and assign it an F-key or use it in a script.
Copy link to clipboard
Copied
Thanks for checking.
I did try it and it worked for me but can I use the action in a script with CS 5?
Thanks,
Duane
Copy link to clipboard
Copied
Without knowing more of your work flow its hard to say… CS5 can't call action using ESTK the feature is NEW to CS6. An action can call a script ( although its forgetful ). So it can depend on what you are trying to do and where…?
Copy link to clipboard
Copied
it doesnt sound like it would be dependable.
what my workflow is;
Script: open a file
Script: unhide all layers
Script: deletes layer named raster
Script: deletes layer named searchable text
Action: change all text to arial and arial bold (This is where I would need the action to work)
script: copys all text to a layer and changes it's color, then hides it .
script: copys everything to a new layer and rasterizes it.
script : hides all layers and then turns on raster layer and searchable text layer.
script: saves and closes file
then repeated over about 600 files.
can't wait to get CS 6!
Thanks for the help,
Duane
Copy link to clipboard
Copied
then, back to your question, yes you'll have to loop through all text frames...
or, what if you uninstall Helvetica temporarily? then on opening the file you swap the font, just an idea, not sure if it will help much.
Copy link to clipboard
Copied
The Find Font is what i use now. I wanted to find a way to do it with ExtendScript quicker. I have found that my arial font I use is textFont[12] and the arial bold I use is textfont[14] on my system. If there was a way to find the font used in the file and select thetext using that font it seems it would be possible to change it to one of these fonts. I dont know enough about it to know if it is possible or not.
Thanks for the info,
Duane
Copy link to clipboard
Copied
Selecting the text script or GUI is the slowest method… Find Font will do this globally without trawling every character of every text frame… And it will be plug-in which is far faster than script…
Copy link to clipboard
Copied
Do you know if it can be automated in CS 5? part of my script unhides layers that need the text change.
Thanks for the info,
Duane
Copy link to clipboard
Copied
DuanesSearchForKnowledge wrote:
… If there was a way to find the font used in the file and select thetext using that font it seems it would be possible to change it to one of these fonts. I dont know enough about it to know if it is possible or not.
Thanks for the info,
Duane
Look at this example:
if (app.documents.length > 0 ) {
var doc = app.activeDocument;
var aFont = (doc.textFrames[0].textRange.textFont)
// You always need the correct internal text font name
// change to regular, if bold
if (aFont.name == textFonts.getByName("MyriadPro-Bold").name) { // I haven't Helvetica here, so I take this font instead
doc.textFrames[0].textRange.textFont = textFonts.getByName("MyriadPro-Regular");
}
// try and have fun
}
Copy link to clipboard
Copied
Thank you Pixxxel schubser, I was able to selected all my helvetica text and change it to arial in my document.
var doc3 = app.activeDocument;
var myTextFrame = app.activeDocument.textFrames;
for (i = 0; i < myTextFrame.length; i++) {
var textArtRange = doc3.textFrames;
var aFont = (doc3.textFrames.textRange.textFont)
if (aFont.name == textFonts.getByName("Helvetica").name) {
try {
//doc3.textFrames.selected = true;
doc3.textFrames.textRange.textFont = textFonts.getByName("Arial-BoldMT");
} catch (e) {}
}
}
Copy link to clipboard
Copied

