Copy link to clipboard
Copied
Another simple script I don't know how to write:
I want to search for a specific character (♥) and change the font to "ZapfDingbatsITC". I've tried to find and change similar scripts but nothing is working for me.
Thanks for any help.
Thank you for the example file.
I don't have ZapfDingbatsITC on my computer. That's why I use another font in the script snippets.
At first create a textFrame with one character with your ZapfDingbats - and run this line of code:
alert (app.activeDocument.textFrames[0].textRange.characters[0].textFont);
You will need the exact name later for the next script snippet.
Use the font name for ZapfDingbats in line #10 instead and save this script.
...// regards pixxxel schubser
var aDoc = app.activeDocument;
var
Copy link to clipboard
Copied
for the beginning: Need to remove some characters in the text in active document
Question: which font (and unicode) does your heart (♥) has in your document?
Maybe do you have an example document for us (+ screenshots before/after for comparison)
Copy link to clipboard
Copied
Thanks for your interest.
Yes. Heart Unicode is U+2665.
Before/After
Sample File: Dropbox - Sample1.ai
File fonts
Copy link to clipboard
Copied
Thank you for the example file.
I don't have ZapfDingbatsITC on my computer. That's why I use another font in the script snippets.
At first create a textFrame with one character with your ZapfDingbats - and run this line of code:
alert (app.activeDocument.textFrames[0].textRange.characters[0].textFont);
You will need the exact name later for the next script snippet.
Use the font name for ZapfDingbats in line #10 instead and save this script.
// regards pixxxel schubser
var aDoc = app.activeDocument;
var aTF = aDoc.textFrames[0];
var reg = /\u2665/g;
var res, idx;
while (res = reg.exec(aTF.contents))
{
idx = res.index;
aTF.textRange.characters[idx].textFont = app.textFonts.getByName("MS-UIGothic"); // or whatever textFont you want
};
This works for the first text frame in the document (as your example file).
Have fun
Copy link to clipboard
Copied
That is perfect! Thanks so much. I'll try to learn from this.
Copy link to clipboard
Copied
Is there a way to search all text boxes (or selected text boxes) in the document and swap the character if it is in multiple text boxes?
I have zero knowledge to scripting in Illustrator and have to swap a ton of standard "0" that is within a word with a different font that has a slash through the zero.
I was able to get it to work on the first text box only but it does not apply to all text boxes in the document.
Please help!
Thanks!