Link in Zwischenablage kopieren
Kopiert
I create a TextFrame="abc" has paragraph style set Font size =20pt
I can't set a other font size to textframe:
Ex: doc.TextFrames(1).Characters(2).CharacterAttributes.size = 12
Result font size of character =20pt;
Why can't overidde setting fontsize of pragraph style?
Link in Zwischenablage kopieren
Kopiert
Seems like a bug as indeed size is not changed like paragraph style overrides any change.
Fill a bug report.
Double checked, now it's fully functional. Don't know why it didn't earlier.
Link in Zwischenablage kopieren
Kopiert
It not only font size, Black color can't set, if paragraph style setting a other value.
Version CC. 2017. font size can set, color still can't set.
Link in Zwischenablage kopieren
Kopiert
characterAttributes is a property of "textRange", not of "characters". Try this:
doc.textFrames[1].textRange.characterAttributes.size = 12
Link in Zwischenablage kopieren
Kopiert
the problem is not textRange,
If i set font size =13 , it is ok.
ex: doc.TextFrames(1).Characters(2).CharacterAttributes.size = 13 =>OK
Set font size =12 , it not ok, Because [normal character style] setting font size =12.
it will auto use font size of paragraph style.
Link in Zwischenablage kopieren
Kopiert
I using illustrator CS6
Link in Zwischenablage kopieren
Kopiert
Salut !
Utilisez plutôt JavaScript
----------------------...
Rem visual Basic Document
Rem Hello World
Set appRef = CreateObject("Illustrator.Application")
Rem Create a new document and assign it to a variable
Set documentRef = appRef.Documents.Add
Rem Create a new text frame item and assign it to a variable
Set sampleText = documentRef.TextFrames.Add
Rem Set the contents and position of the TextFrame
sampleText.Position = Array(200, 200)
sampleText.Contents = "Hello World!"
sampleText.TextRange.CharacterAttributes.Size = 20
' sampleText.TextRange.Characters(2).CharacterAttributes.Size = 32
documentRef.TextFrames(1).TextRange.Characters(2).CharacterAttributes.Size = 32
---------------------
de LR
Link in Zwischenablage kopieren
Kopiert
Hi, renél80416020
If i set font size =13 , it is ok.
ex: doc.TextFrames(1).Characters(2).CharacterAttributes.size = 13 =>OK
Set font size =12 , it not ok, Because [normal character style] setting font size =12.
it will auto use font size of paragraph style.
Link in Zwischenablage kopieren
Kopiert
It's a bit of a stretch, but...
ApllyTo of CharacterStyle methods has clearingOverrides option.
"action1" on line 15 is to execute "Create New Style" on the Character Styles palette. You can register the actions in advance or use dynamic action methods. I do not use "Add" of CharacterStyles method because you can't inherit properties of the TextFrame.
(with Ai CC2017)
Sub sample()
Set appRef = CreateObject("Illustrator.Application")
Set documentRef = appRef.Documents.Add
Set sampleText = documentRef.TextFrames.Add
sampleText.Position = Array(200, 200)
sampleText.Contents = "Hello World!"
sampleText.TextRange.CharacterAttributes.Size = 20
Set cyanColor = CreateObject("Illustrator.CMYKColor")
cyanColor.Cyan = 100
cyanColor.Magenta = 0
cyanColor.yellow = 0
cyanColor.Black = 0
sampleText.TextRange.CharacterAttributes.FillColor = cyanColor
sampleText.Selected = True
Call appRef.DoScript("action1", "actionSet1", False)
Set charStyle = documentRef.CharacterStyles.Item(documentRef.CharacterStyles.Count)
charStyle.CharacterAttributes.Size = 12
Call charStyle.ApplyTo(documentRef.TextFrames(1).TextRange.Characters(2), True)
charStyle.Delete()
End Sub
sample()
Link in Zwischenablage kopieren
Kopiert
In CC 2017, If i use action to add character style:
If Text not setting any attributes, it will display a dialog of Character style when call action ( in CS6 :it can create character style and not display dialog).
How can turn off dialog?
Link in Zwischenablage kopieren
Kopiert
Salut !
Effectivement, j'ai essayé sur CS6 et j'ai rencontré le même problème 11.99 ou 12.01 > OK
mais pas 12 ??
Idem en JavaScript :
// JavaScript Document
var documentRef = app.documents.add();
//Create a new text frame item and assign it to a variable
var sampleText = documentRef.textFrames.add();
//Set the contents and position of the TextFrame
sampleText.position = new Array(200, 200);
sampleText.contents = "Hello World!";
sampleText.textRange.characterAttributes.size = 20;
sampleText.textRange.characters[1].characterAttributes.size = 11.99; // ou 12.01 OK
//documentRef.textFrames[0].textRange.characters[1].characterAttributes.size = 12;
de LR
Link in Zwischenablage kopieren
Kopiert
Résultats identiques sur CS2 et CS5 mais pas sur CS (OK).
Ce qui pose problème est la police "MyriadPro-Regular", il faut spécifier une autre police de caractères.
var orange = macmykColor(0,50,100,0);
var noir = macmykColor(0,0,0,100);
var nomPolice = "MyriadPro-BoldIt"; //"MyriadPro-Regular";
//Create a new text frame item and assign it to a variable
var sampleText = documentRef.textFrames.add();
//Set the contents and position of the TextFrame
sampleText.position = new Array(200, 200);
sampleText.contents = "Hello World!";
sampleText.textRange.fillColor = orange;
sampleText.textRange.textFont = textFonts.getByName(nomPolice);//app.textFonts[315];
sampleText.textRange.characterAttributes.size = 20;
sampleText.textRange.characters[1].characterAttributes.size = 12;
sampleText.textRange.characters[1].fillColor = noir;
//documentRef.textFrames[0].textRange.characters[1].characterAttributes.Size = 12;
wordColor(sampleText,1,12,noir,1);
function wordColor(objetText,rang,size,couleur,nbMot)
{ //Change la couleur de 1 ou plusieurs mot(s))
var firstWord;
for (var i = rang; i < rang+nbMot; i++){
firstWord = objetText.words;
firstWord.fillColor = couleur;
firstWord.size = size;
}
}
function macmykColor(c,m,j,n)
{ //cree une nouvelle couleur CMJN
var cmykColor = new CMYKColor();
cmykColor.cyan = c;
cmykColor.magenta = m;
cmykColor.yellow = j;
cmykColor.black = n;
return cmykColor;
}
Link in Zwischenablage kopieren
Kopiert
While properties of text frames contain non-default values, their properties may be changeable to default values. Those properties are italic, horizontal, etc.
Example using fillColor:
(function () {
var CONTENTS = '0123456789',
doc = app.documents.add(),
newSpot = doc.spots.add(),
newSpotColor = new SpotColor(),
unchangeableTxt = doc.textFrames.add(),
changeableTxt = doc.textFrames.add();
unchangeableTxt.contents = CONTENTS + ': unchangeable';
unchangeableTxt.position = [0, 20];
unchangeableTxt.textRange.characterAttributes.size = 20;
unchangeableTxt.textRange.characters[2].characterAttributes.size = 12;// No effect
changeableTxt.contents = CONTENTS + ': changeable';
changeableTxt.position = [0, 100];
newSpot.colorType = ColorModel.SPOT;
newSpot.color = changeableTxt.textRange.characters[2].characterAttributes.fillColor;
newSpotColor.spot = newSpot;
changeableTxt.textRange.characters[2].characterAttributes.fillColor = newSpotColor;// set non-default values
changeableTxt.textRange.characterAttributes.size = 20;
changeableTxt.textRange.characters[2].characterAttributes.size = 12;// OK
newSpot.remove();
}());
Link in Zwischenablage kopieren
Kopiert
can you set it to something like 12.00001 or something?
what about setting it to 11 and then incrementing it?
fontSize = 11;
fontSize += 1;
something like that?
Weitere Inspirationen, Events und Ressourcen finden Sie in der neuen Adobe Community
Jetzt ansehen