Copiar vínculo al Portapapeles
Copiado
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?
Copiar vínculo al Portapapeles
Copiado
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.
Copiar vínculo al Portapapeles
Copiado
Thank you.
But only some colors have checkbox global.
Ex: If Textcolor is None, will have not checkbox global.
Copiar vínculo al Portapapeles
Copiado
Error occur when TextColor and Color of Character style is the same.
Copiar vínculo al Portapapeles
Copiado
all attributes will auto apply from paragraph style, if setting of text the same with setting of standard character style
Copiar vínculo al Portapapeles
Copiado
How can setting standard character style more priority than paragraph style?
Copiar vínculo al Portapapeles
Copiado
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.
Copiar vínculo al Portapapeles
Copiado
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
Copiar vínculo al Portapapeles
Copiado
If add new character style, can it keep other attributes, if i only set size?
Copiar vínculo al Portapapeles
Copiado
Yes.
Other attributes comes from the paragraph style.
In your case - I would work with styles strictly.
Copiar vínculo al Portapapeles
Copiado
I don't want it get from pagraph style, i want it can keep value of text attributes.
Copiar vínculo al Portapapeles
Copiado
as my data attach. i want color still is yellow, not change to red, (other attributes the same).
Copiar vínculo al Portapapeles
Copiado
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.
Copiar vínculo al Portapapeles
Copiado
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.
Copiar vínculo al Portapapeles
Copiado
This error only occur when set by code, if i set on screen , it is ok.
Encuentra más inspiración, eventos y recursos en la nueva comunidad de Adobe
Explorar ahora