Superscript text font change using script
Hi Everyone
Is there script to find and change the font of thesuperscript text.
Hi Everyone
Is there script to find and change the font of thesuperscript text.
The script will indeed be similar to the one referred to by c.pfaffenbichler
We get a descriptor for the text layer, get an ActionList with a list of styles, loop through all the styles looking for the one in which the 'baseline' key is set to 'superScript'. Then, in this style, change the values of the keys fontName, fontPostScriptName, fontScript, fontStyleName to the required ones (I have never changed the font using a script, so we need to experiment to find out what the minimum set of keys is needed for the font to change correctly - we may have to refer to the list of fonts application to get all the required attributes). After that, collect the descriptor in reverse order and assign it to the text layer.
»fontPostScriptName« and »color« seem to be enough.
// base on code by jazz-y;
// change font of superscript letters;
// 2020, use it at your own risk;
s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('numberOfLayers'));
r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
var len = executeActionGet(r).getInteger(p);
for (var i = 0; i <= len; i++) {
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('textKey'));
r.putIndex(s2t('layer'), i);
var theCheck = false;
if (executeActionGet(r).hasKey(p)) {
var textKey = executeActionGet(r).getObjectValue(p),
styleList = textKey.getList(s2t('textStyleRange')),
l = new ActionList(),
d = new ActionDescriptor(),
z = false;
for (var x = 0; x < styleList.count; x++) {
k = styleList.getObjectValue(x);
s = k.getObjectValue(s2t('textStyle'));
theX = s.getEnumerationValue(stringIDToTypeID("baseline"));
var theNewOne = new ActionDescriptor;
////////////////////////////////////
if (theX == "2477") {
var theCheck = true;
var theStyle = k.getObjectValue(s2t('textStyle'));
theStyle.putString(s2t('fontPostScriptName'), "Helvetica-Bold");
var d = new ActionDescriptor();
d.putDouble(s2t('red'), s.getObjectValue(s2t('color')).getInteger(s2t('red')));
d.putDouble(s2t('grain'), s.getObjectValue(s2t('color')).getInteger(s2t('grain')));
d.putDouble(s2t('blue'), s.getObjectValue(s2t('color')).getInteger(s2t('blue')));
theStyle.putObject(s2t('color'), s2t('RGBColor'), d);
k.putObject(s2t('textStyle'), s2t('textStyle'), theStyle)
} else {
};
////////////////////////////////////
l.putObject(s2t('textStyleRange'), k)
}
if (theCheck == true) {
textKey.putList(s2t('textStyleRange'), l)
var d = new ActionDescriptor();
(r = new ActionReference()).putIndex(s2t('layer'), i);
d.putReference(s2t('null'), r);
d.putObject(s2t('to'), s2t('textLayer'), textKey);
executeAction(s2t('set'), d, DialogModes.NO);
}
}
};Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.