Dec 11, 2008

Retaining Outlined Font Metadata in Adobe Illustrator via Scripting

Keeping text live and editable in Adobe Illustrator is a worthy goal, however there are valid reasons why a person may wish to outline an editable font to vector paths. One problem with this practice is that the font information is lost, making it hard to know which exact font was used. This is not much of an issue for files created in-house, where a duped file or layer may be used to keep a back-up copy of the live text. However for supplied files, this can be a major problem - even more so when a client wishes you to match an uncommon font and all they have is an outlined version of the file.

Ideally, when one selects the Type/Create Outlines command, the font information would be tagged to the outlined text. It is possible to use the Notes section of the Attributes Window (palette) to manually enter the font family name after converting the live text to outlines, however these manual steps are far from ideal even for disciplined users with time to spare.

The good news is that with Scripting, this tedius manual process can be automated. Instead of selecting the text object and using the Create Outlines command, one simply runs the script on the selected text. By referencing the installed script in an Illustrator Action file, one can bind the script to an F-Key or mouse click in order to further facilitate the task, making this process just as - if not more convenient than using the default command.




AppleScript Code:
__________

tell application "Adobe Illustrator"
tell document 1
set storyText to text of story of selection
set fontName to name of text font of text of story of selection
tell selection
tell storyText
set propList to {fontName, return, size, return, leading, return, tracking, return}
end tell
set convertedText to convert to paths
set note of convertedText to propList as text
end tell
end tell
end tell

__________

My sincere thanks and appreciation to Rick Gordon for writing this AppleScript at my request. Simply copy and paste the above code into the AppleScript Script Editor.app application; compile and save in script format. Next place the resulting AppleScript script file in the Illustrator Scripts folder and relaunch Illustrator to access the script (File/Scripts).

Note: This solution is far from ideal and can fail with text styled with multiple fonts. The second screen capture image above only uses the propList fontName attribute, rather than multiple attributes such as point size, leading and tracking as shown in the complete script code.


_