Copy link to clipboard
Copied
Hi.
I come form InDesign scripting and I'm sorry to say that illustrator one is really raw...
Anyway, my problems are:
- Looks like it's not possible to get something like "textStyleRanges" within a paragraph so the only way to get different text style ranges in a paragraph is to loop through characters and check differences (am I wrong?)
- Looks like it's not possible to expand a symbolItem... is there a way to get this?
Thanks!
You are correct.
In order to expand a symbol, you need to copy it to a temporary layer, Here's some code I use:
function unlinkSymbol(mySymb){
var symbLayer=findOrCreateLayer("SymbolsTemp-----")
var dupSymbol=mySymb.duplicate() // Duplicate the symbol
symbLayer.visible = true // Layer must be visible and unlocked
symbLayer.locked = false
symbLayer.symbolItems.add(dupSymbol) // Place duplicate symbol on symbLayer
dupSymbol.remove()
Copy link to clipboard
Copied
You are correct.
In order to expand a symbol, you need to copy it to a temporary layer, Here's some code I use:
function unlinkSymbol(mySymb){
var symbLayer=findOrCreateLayer("SymbolsTemp-----")
var dupSymbol=mySymb.duplicate() // Duplicate the symbol
symbLayer.visible = true // Layer must be visible and unlocked
symbLayer.locked = false
symbLayer.symbolItems.add(dupSymbol) // Place duplicate symbol on symbLayer
dupSymbol.remove() // Break the link
var myGroup = symbLayer.groupItems[symbLayer.groupItems.length-1]
myGroup.name = mySymb.name // Name the group same as the original
symbLayer.visible = false // Hide the layer, delete it later
return myGroup
}
Copy link to clipboard
Copied
Thanks big RA!
What about document fonts?
Is there any way to get fonts used within an Illustrator document?
Something similar to InDesign's "app.activeDocument.fonts"...
I just came across "app.textFonts" which is good but I only need the document's fonts.
Thanks!
Copy link to clipboard
Copied
function getUsedFonts (doc ){ var xmlString = new XML(doc.XMPString); fontsInfo = xmlString.descendants("stFnt:fontName"); var ln = fontsInfo.length(), arr = []; for (var i = 0; i<ln; i++){arr.push(fontsInfo)}; return arr; }
alert(getUsedFonts(activeDocument));
-- function I used in my fonts package script. You should save the document first.
Copy link to clipboard
Copied
Thanks, that's a great tip!
Copy link to clipboard
Copied
Hey, man! Can you help me? I'm trying to add this bit of scripting to a file. I copied and pasted just as you've got it above. When I execute the script, it does everything corectly except for the fonts. A window pops up (I've attached an image) that lists all of the correct fonts used, but it doesn't save the fonts to the folder.
Any thoughts as to what I've done wrong? Maybe I put the code in the wrong place within the file? Any help is much appreciated
Copy link to clipboard
Copied
The snippet in post 3 only displays a dialog of the font names nothing more…
Copy link to clipboard
Copied
As Mark said, that snippet only tells you what fonts been used in the document. To collect fonts to a folder is more complex, since you can not get the fonts location property from within Illustrator scripting DOM.
If you also have Indesign installed, you can have a look with [this script](http://pastebin.com/raw.php?i=EEPNWxCS), which can use to package fonts for .ai/.indd files.
If you don't have Indesign, I have another solution which is more complex.
BTW: You can package fonts with Illustrator CC directly now.
Copy link to clipboard
Copied
Thanks, Molu. I looked at your script in pastebin and tried to implement it, but I received an error with Line 23. If you are interested, would you PM me?I'd like to try and figure this out. I have both indesign and illustrator.
I'm currently copying the fonts from illustrator into indesign and packaging that way. This method works fine, except that it is time consuming (relative to a script doing it). I know that collecting fonts in illustrator can be done because of programs like Scoop and Flightcheck, so I'm hoping to make it a reality for me without dishing out some dough.
Any thoughts?
Copy link to clipboard
Copied
What do you need to do?
Copy link to clipboard
Copied
I'd like to collect fonts in illustrator. I'm currently copying the fonts from illustrator into indesign and packaging that way. This method works fine, except that it is time consuming (relative to a script doing it). I know that collecting fonts in illustrator can be done because of plugins/scripts like Scoop and Flightcheck and ArtFiles, so I'm hoping to make it a reality for me without dishing out some dough.