Copy link to clipboard
Copied
pun not intended,
whilst docs do mention
FontOpenTypePositionOption.OPENTYPESUPERSCRIPT,
I could not get it working
ok, found it by comparing 2 objects.
in case someone's struggling too, it's:
characterAttributes.baselinePosition = FontBaselineOption.SUPERSCRIPT
Copy link to clipboard
Copied
ok, found it by comparing 2 objects.
in case someone's struggling too, it's:
characterAttributes.baselinePosition = FontBaselineOption.SUPERSCRIPT
Copy link to clipboard
Copied
Bonjour,
Pour s'amuser un peu...
Document ouvert, lancer le script.
// JavaScript document for Illustrator
// Landry René
// elleere Wed, 25 April 2018 17:39:04 GMT
// INIT---------
var c1 = "^";
var c2 = "_";
var text = "2^2.5 + b^2 = 5 C_12^2 sin(20^3)"; // cas 1
//var text = "2^2.5 + b^2 = 5 C^2_12 sin(20^3)"; // cas 2
var corps = 16;
//-------------
var docRef = activeDocument;
var pointText = docRef.textFrames.add();
pointText.contents = text;
pointText.position = [20,-20];
pointText.textRange.size = corps;
//expo_indice(pointText,c1,1); // si cas 2
expo_indice(pointText,c2,0);
expo_indice(pointText,c1,1); // si cas 1
//--------------
function expo_indice(textRf,rx,drap) {
var index, pos, i, r, curentChar, suit, baseline;
baseline = drap ? FontBaselineOption.SUPERSCRIPT : FontBaselineOption.SUBSCRIPT;
pos = index = textRf.contents.indexOf(rx);
suit = textRf.contents;
while (pos != -1) {
suit = suit.substring(pos+1);
r = parseFloat(suit)+"";
//r = drap ? parseFloat(suit)+"" : "1"; // si toujours 1 chiffre
for (i = 1; i <= r.length; i++) {
curentChar = textRf.textRanges[index+i];
curentChar.baselinePosition = baseline;
}
textRf.textRanges[index].remove();
pos = suit.indexOf(rx);
index += pos;
}
}
//--------------
Copy link to clipboard
Copied
hello, the baselinePosition property seems not working on my character, while using $.writeln() showed the change of it.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now