• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Select Character and replace font?

LEGEND ,
Jan 09, 2019 Jan 09, 2019

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.

TOPICS
Scripting

Views

1.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 12, 2019 Jan 12, 2019

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

...

Votes

Translate

Translate
Adobe
Community Expert ,
Jan 09, 2019 Jan 09, 2019

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)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 10, 2019 Jan 10, 2019

Copy link to clipboard

Copied

pixxxel schubser

Thanks for your interest.

Yes. Heart Unicode is U+2665.

Before/After

Sample File: Dropbox - Sample1.ai

File fonts

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 12, 2019 Jan 12, 2019

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 12, 2019 Jan 12, 2019

Copy link to clipboard

Copied

pixxxel schubser​

That is perfect! Thanks so much. I'll try to learn from this.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 15, 2024 Apr 15, 2024

Copy link to clipboard

Copied

LATEST

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!

wesleyh57554615_0-1713194689158.png

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines