Copy link to clipboard
Copied
Bonjour à tous,
J'ai un script qui ouvre une boite de dialogue pour que je puiise entrer le texte que je souhaite afficher à un endroit spécifique de mon plan de travail. Tout fonctionne sauf que je n'arive pas à changer le style de police de mon texte.. J'aimerais que le texte soit en police "Myriad pro" et en style de police "Bold" et que la taille de la police soit de 14 pt.
Voici le script que j'utilise
characterAttributes.font is not part of the API, you should use
characterAttributes.textFont
characterAttributes.fontWeight is not part of the API
= "Myriad Pro Bold"; you can't assign the font by providing the String name, you need to get the Font Object and use the internal name illustrator understands
textFonts.getByName(Internal_fontname);
var text = prompt("Entrez le texte à écrire:", "");
if (text) {
var fontname = "MyriadPro-Bold";
var doc = app.activeDocument;
var laye
...
Copy link to clipboard
Copied
characterAttributes.font is not part of the API, you should use
characterAttributes.textFont
characterAttributes.fontWeight is not part of the API
= "Myriad Pro Bold"; you can't assign the font by providing the String name, you need to get the Font Object and use the internal name illustrator understands
textFonts.getByName(Internal_fontname);
var text = prompt("Entrez le texte à écrire:", "");
if (text) {
var fontname = "MyriadPro-Bold";
var doc = app.activeDocument;
var layer = doc.layers.getByName("FOND DE PLAN");
layer.locked = false;
var textFrame = layer.textFrames.add();
textFrame.contents = text;
textFrame.textRange.characterAttributes.textFont = textFonts.getByName(fontname);
var nonPrintableLayer = doc.layers.getByName("NON IMPRIMABLE");
var pointOfGathering = nonPrintableLayer.pathItems.getByName("POINT DE RASSEMBLEMENT");
var textBounds = textFrame.geometricBounds;
var pointBounds = pointOfGathering.geometricBounds;
var x = pointBounds[0] + (pointBounds[2] - pointBounds[0] - textBounds[2] + textBounds[0]) / 2;
var y = pointBounds[1] + (pointBounds[3] - pointBounds[1] - textBounds[3] + textBounds[1]) / 2;
textFrame.left = x;
textFrame.top = y;
layer.locked = true;
}
Copy link to clipboard
Copied
Thank you so much @CarlosCanto !!!