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

CS2 How to automate font find & replace option in Illustrator?

New Here ,
Feb 16, 2009 Feb 16, 2009
Hi,

I want to automate(in Batch) the Font Find & Replace Option in Illustrator's "Type->Find Font" menu Item.

Can this be automated using the CS2 SDK or AI 10 SDK?

If possible which Header file & methods should i use?

Is there any code snippets to automate this?

myriaz
TOPICS
SDK
3.2K
Translate
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
Adobe
Guide ,
Feb 19, 2009 Feb 19, 2009
It should doable, but it would be significantly different between 10 & CS2 since they use different text engines.

AIFont.h would be the place to start, at least for enumerating the available fonts. You'll probably want to us that to get a list of 'search' fonts & 'replace' fonts.

Doing the replacing is a little more complicated, and will require some investigation of the ATE (Adobe Text Engine) if you're working with CS2. It's been too long, I'm afraid, for me to be much help with 10.

Here's some code that assigns an ATE::IFont object to a block of text:

-------------------------------
ASSERT(!font.IsNull());
ATE::TextRangeRef textRangeRef = 0;

AIErr error = sAITextFrame->GetATETextRange(GetHandle(), &textRangeRef);
THROW_EXCEP_IF(error);

ATE::ITextRange textRange(textRangeRef);
ATE::ICharFeatures charFeatures = textRange.GetUniqueLocalCharFeatures();

charFeatures.SetFont(font);
textRange.SetLocalCharFeatures(charFeatures);
-------------------------------

Note that GetHandle() is a method that (as one would expect) gets the handle to the text object I want to assign the font to. And THROW_EXCEP_IF is a macro of mine that throws an exception error is not kNoErr.

You'll still need to prepare the IFont object you want and you can do that fairly easy by using code that looks like this:

-------------------------------
AIErr error = sAIFont->FontFromFontKey(fontKey, &fontRef);
THROW_EXCEP_IF(error);

ASSERT(fontRef);
ATE::IFont font(fontRef);
-------------------------------

I'm assuming having an AIFontKey (fontKey above) won't be too hard since that's what you get when you enumerate the fonts using AIFont.h.

I think that should be enough to get you going, but let me know if you have any other questions!
Translate
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 ,
May 09, 2009 May 09, 2009

Hi, I do have the same problems (thousands of files with invalid fonts in to be replaced), I've tried to make an action script with no success (WinXp, CS2/4)

Could you elaborate the various steps needed to make your solution work, I'm not fluent with the tools you're mentionning.

Thanks,

JR

Translate
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
Guide ,
May 11, 2009 May 11, 2009
LATEST

The solution I outlined involves using the AI C++ SDK to write your own plugin. If you want to attempt that route my suggestion is to download the AI SDK and modify one of their sample plugins. You'd simply need to replace whatever menuitem 'go' code they have with the code of your own to do the search  replace.

Bear in mind that this would require Xcode (Mac) or Visual Studio (PC) and the experience to get this up & running, or the willingness to learn it.

Translate
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 Beginner ,
Feb 26, 2009 Feb 26, 2009
I am also need to automate the "Font Find & Replace Option" in Illustrator's CS. Kindly advice me.

Thanks,
Prabudass
Translate
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
Guide ,
Feb 26, 2009 Feb 26, 2009
CS uses the same engine. Anything earlier is completely different, since they added the new engine in Illustrator CS.
Translate
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 ,
Mar 05, 2009 Mar 05, 2009
Hi,

Can u tell how to find the the fonts used in the document directly without iterating through the text art used in the document.BCOZ if i iterate through each text frame or character my plugin works very slowly.I want to speed up the process of finding & replacing the fonts like wat we do manually in the "Type-> Find Font" menu thru my code.

Please post ur comments on this .If there is no direct option to find &replace the fonts used in the document ,pls let me know the simplest logic of finding & replacing all occurances of a font in a doc so that my process of doing this should be faster.

Thanks in advance.

myRiaz
Translate
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