Unfortunately, this does exactly the same as increasing the text by X amount of points using (on a Mac) the Shift + CMD + < or > shortcut (or Shift + Ctrl + CMD + < or >).
Your script gives the option to set the number of points manually, but the script itself is not resizing proportionally (as I mentioned here: https://community.adobe.com/t5/photoshop-ecosystem-discussions/change-text-size-without-transform-tool/m-p/12823614#M630772).
Basically it's just adding X amount of points to all text, so a text at 50 and a text of 25, by adding 50 points will become 100 and 75, which is not a proportion of 50 and 25 (which should be 100 and 50 in the end).
@TiagoRocha, i had a feeling that I understood something wrong 🙂
In your description, I see one problem - there is no definition of what exactly should act as the basis for determining the multiplier. Let's say, we have two lines 50 pt and 25 pt. If we take the first one as the base and add 50 pt, then we get the multiplier (50+50)/50 = 2. If we have the second one as the base, then the multiplier is different (25+50)/25= 3. We can, of course, use a fixed multiplier, but it will be difficult for you to get the desired symbol size.
I rewrote the script with this in mind, try:
#target photoshop
var w = new Window('dialog{orientation:"column"}'),
g1 = w.add("group"),
st = g1.add('statictext{text:"base:"}');
dl = g1.add("dropdownlist{preferredSize: [120,-1]}"),
g2 = w.add("group"),
bnInc = g2.add('button{text:"+"}'),
bnDec = g2.add('button{text:"-"}'),
et = g2.add('edittext{preferredSize: [40,-1]}');
g1.add('statictext{text:"pt"}');
g2.add('statictext{text:"pt"}');
et.text = $.getenv('size') ? $.getenv('size') : 50
et.onChange = function () { $.setenv('size', this.text) }
bnDec.onClick = bnInc.onClick = function () {
var base = Number(dl.selection.text),
scale = this.text == '+' ? (base + Number(et.text)) / base : (base - Number(et.text)) / base;
if (scale >= 0) {
changeFontSize(scale)
w.onShow();
try { app.refresh() } catch (e) { w.close() }
}
}
dl.onChange = function () { $.setenv('base', this.selection.index) }
w.onShow = function () {
var o = getFontSize();
dl.removeAll()
for (a in o) { dl.add('item', a) }
dl.selection = $.getenv('base') && Number($.getenv('base')) < dl.items.length ? Number($.getenv('base')) : 0
}
w.show();
function changeFontSize(scale) {
var s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('textKey'));
r.putEnumerated(s2t('layer'), s2t('ordinal'), s2t('targetEnum'));
if (executeActionGet(r).hasKey(p)) {
var textKey = executeActionGet(r).getObjectValue(p),
styles = textKey.getList(s2t('textStyleRange'));
var l = new ActionList();
for (var i = 0; i < styles.count; i++) {
var cur = styles.getObjectValue(i),
textStyle = cur.getObjectValue(s2t('textStyle'));
var curSize = textStyle.getUnitDoubleValue(s2t('impliedFontSize')),
curLeading = textStyle.hasKey(s2t('impliedLeading')) ? textStyle.getUnitDoubleValue(s2t('impliedLeading')) : null;
textStyle.putUnitDouble(s2t('impliedFontSize'), s2t('pointsUnit'), curSize * scale);
if (curLeading) textStyle.putUnitDouble(s2t('impliedLeading'), s2t('pointsUnit'), curLeading * scale);
cur.putObject(s2t('textStyle'), s2t('textStyle'), textStyle);
l.putObject(s2t('textStyleRange'), cur)
}
textKey.putList(s2t('textStyleRange'), l);
(r = new ActionReference()).putEnumerated(s2t('layer'), s2t('ordinal'), s2t('targetEnum'));
(d = new ActionDescriptor()).putReference(s2t('null'), r);
d.putObject(s2t('to'), s2t('textLayer'), textKey);
executeAction(s2t('set'), d, DialogModes.NO);
}
}
function getFontSize() {
var s2t = stringIDToTypeID,
fontSizeList = {};
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('textKey'));
r.putEnumerated(s2t('layer'), s2t('ordinal'), s2t('targetEnum'));
if (executeActionGet(r).hasKey(p)) {
var sList = executeActionGet(r).getObjectValue(p).getList(s2t('textStyleRange'));
for (var x = 0; x < sList.count; x++) {
var k = sList.getObjectValue(x).getObjectValue(s2t('textStyle'))
if (k.hasKey(s2t('impliedFontSize'))) {
var size = Math.round(k.getUnitDoubleValue(s2t('impliedFontSize')) * 100) / 100
if (fontSizeList[size]) fontSizeList[size].push(i) else fontSizeList[size] = [i]
}
}
}
return (fontSizeList)
}
* better to use .jsx file extension, not .js. @Stephen Marsh wrote a good instruction on working with scripts Downloading and Installing Adobe Scripts