Copy link to clipboard
Copied
This is my file illustrator
Dropbox - test6.ai - Simplify your life
Color of Character style = Yellow
Color of Paragraph style= Red
Text color is Yellow.
Dim app = CreateObject("Illustrator.Application.CS6")
Dim doc = app.ActiveDocument
doc.TextFrames(1).Characters(2).CharacterAttributes.size = 12
Result: character auto apply color from paragraph style
I only want change font size, not want change color.
Why characters auto apply color from paragraph style?
How can keep original color when set font size?
Copy link to clipboard
Copied
I ran just a few basic test with this script that I wrote....
var doc = app.activeDocument;
var allText = doc.textFrames;
for (i = 0; i < allText.length; i++){
var theText = allText;
var allTextAttributes = theText.textRange.characterAttributes;
allTextAttributes.size = (10);
}
I got the same results as you did. The yellow changed to red. I applied a different swatch to the text color and ran the script again. The font size changed and the color did not. If you double click your yellow swatch that is applied to the text and check the box next to global it should resolve your issue.
Copy link to clipboard
Copied
Thank you.
But only some colors have checkbox global.
Ex: If Textcolor is None, will have not checkbox global.
Copy link to clipboard
Copied
Error occur when TextColor and Color of Character style is the same.
Copy link to clipboard
Copied
all attributes will auto apply from paragraph style, if setting of text the same with setting of standard character style
Copy link to clipboard
Copied
How can setting standard character style more priority than paragraph style?
Copy link to clipboard
Copied
In every case. A character style beats the paragraph style.
But you didn't have applied a character style nor a paragraph style in your document. Only local formatting with deviations from the basic formats.
Copy link to clipboard
Copied
Create in your example document a new character style with a different character size.
Name it --> newCharStyle
Run this script snippet:
// create before a character style with your preferred size and name it--> newCharStyle
var aDoc = app.activeDocument;
var aChar = aDoc.textFrames[0].characters[1];
var charStyle = aDoc.characterStyles.getByName("newCharStyle");
charStyle.applyTo(aChar);
If that works for your needs
have fun
Copy link to clipboard
Copied
If add new character style, can it keep other attributes, if i only set size?
Copy link to clipboard
Copied
Yes.
Other attributes comes from the paragraph style.
In your case - I would work with styles strictly.
Copy link to clipboard
Copied
I don't want it get from pagraph style, i want it can keep value of text attributes.
Copy link to clipboard
Copied
as my data attach. i want color still is yellow, not change to red, (other attributes the same).
Copy link to clipboard
Copied
The only and the safe way is to work with styles. As in InDesign.
If you don't do this, it is much more complicated. You will have to declare every attribute in your script.
Copy link to clipboard
Copied
can i add a new character style and auto get all attributes of text set to new style? the same with select text and add new style on Illustrator app.
Copy link to clipboard
Copied
This error only occur when set by code, if i set on screen , it is ok.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now