• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Change text size without transform tool [SOLVED]

Engaged ,
Mar 18, 2022 Mar 18, 2022

Copy link to clipboard

Copied

UPDATE: The user @jazz-y provided a great script that allows us to achieve this. Please go to the following answer and copy the script after the sentence "I rewrote the script with this in mind, try":
https://community.adobe.com/t5/photoshop-ecosystem-discussions/change-text-size-without-transform-to...

 

Meanwhile, you can also upvote this idea to become a native feature, here:
https://community.adobe.com/t5/photoshop-ecosystem-ideas/resize-different-text-proportionally-inside...

 

------

I have a text box with different text sizes and I want to resize all of them proportionally, but I don't want to use the Transform Tool, because that will change the size of the text box itself, which is not what I want.

 

Is there a way to achieve this? When I select all text, the text size field is empty (obviously, because it has a lot of sizes to process) and I can't use that technique of dragging the T icon horizontally to increase/decrease the size.

 

Any tips?

 

 

TOPICS
Actions and scripting , macOS , Windows

Views

1.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Mar 22, 2022 Mar 22, 2022

@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

...

Votes

Translate

Translate
Adobe
Mentor ,
Mar 20, 2022 Mar 20, 2022

Copy link to clipboard

Copied

Hmm, strange. That should work but you're right, it doesn't.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 21, 2022 Mar 21, 2022

Copy link to clipboard

Copied

My guess is that PS is not really transforming the font itself, but just the container, even though the font size information change, maybe just for visual aid, and once you move it to another container, it pastes it with the real size.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 20, 2022 Mar 20, 2022

Copy link to clipboard

Copied

Maybe a script?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 21, 2022 Mar 21, 2022

Copy link to clipboard

Copied

That could maybe be an option for someone with that skill level, which is not my case, unfortunately... 😕

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 22, 2022 Mar 22, 2022

Copy link to clipboard

Copied

Unfortunately, not mine either, but you could try asking around on this Forum. There are a lot of posters here who do know it, and are quite willing to help.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 22, 2022 Mar 22, 2022

Copy link to clipboard

Copied


@Semaphoric wrote:

you could try asking around on this Forum.


 

@TiagoRocha 

I've just now added the Scripting tag to your original post. The scripters who filter posts may catch this now.

 

Jane

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Mar 22, 2022 Mar 22, 2022

Copy link to clipboard

Copied

Working with text by scripts has a number of limitations, in particular, you cannot work with a selected text fragment (only with the entire layer at once). If I understand you correctly, you need something like this:

 

#target photoshop

var w = new Window('dialog{orientation:"row"}'),
    bnInc = w.add('button{text:"+"}'),
    bnDec = w.add('button{text:"-"}'),
    et = w.add('edittext{text: 100}'),
    st = w.add('statictext{text:"pt"}');
et.text = $.getenv('size') ? $.getenv('size') : 50
et.onChange = function () { $.setenv('size', this.text) }
bnDec.onClick = bnInc.onClick = function () {
    changeFontSie(this.text, Number(et.text));
    try { app.refresh() } catch (e) { w.close() }
}

w.show();

function changeFontSie(mode, offset) {
    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')),
                newSise = mode == '+' ? curSize + offset : curSize - offset,
                curLeading = textStyle.hasKey(s2t('impliedLeading')) ? textStyle.getUnitDoubleValue(s2t('impliedLeading')) : null;
            textStyle.putUnitDouble(s2t('impliedFontSize'), s2t('pointsUnit'), newSise);
            if (curLeading) textStyle.putUnitDouble(s2t('impliedLeading'), s2t('pointsUnit'), curLeading * newSise / curSize);
            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);
    }
}

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 22, 2022 Mar 22, 2022

Copy link to clipboard

Copied

Actually, you can work with text fragments but you need to break them up for styling and use AM code. Its a royal PITA.

For this demo, create a document with a text layer, 48 point text, first line "test", second line whatever. Run the script. Using this demo in an actual working script is left as an exercise for the reader 😉

#target photoshop

layerUpdate();

function setFormatting(start, end, fontName, fontStyle, fontSize){
    var idsetd = app.charIDToTypeID('setd');
    var action = new ActionDescriptor();
    var idnull = app.charIDToTypeID('null');
    var reference = new ActionReference();
    var idTxLr = app.charIDToTypeID('TxLr');
    var idOrdn = app.charIDToTypeID('Ordn');
    var idTrgt = app.charIDToTypeID('Trgt');
    reference.putEnumerated(idTxLr, idOrdn, idTrgt);
    action.putReference(idnull, reference);
    var idT = app.charIDToTypeID('T   ');
    var textAction = new ActionDescriptor();
    var idTxtt = app.charIDToTypeID('Txtt');
    var actionList = new ActionList();
    var textRange = new ActionDescriptor();
    var idFrom = app.charIDToTypeID('From');
    textRange.putInteger(idFrom, start);
    textRange.putInteger(idT, end);
    var idTxtS = app.charIDToTypeID('TxtS');
    var formatting = new ActionDescriptor();
    var idFntN = app.charIDToTypeID('FntN');
    formatting.putString(idFntN, fontName);
    var idFntS = app.charIDToTypeID('FntS');
    formatting.putString(idFntS, fontStyle);
    var idSz = app.charIDToTypeID('Sz  ');
    var idPnt = app.charIDToTypeID('#Pnt');
    formatting.putUnitDouble(idSz, idPnt, fontSize);
    textRange.putObject(idTxtS, idTxtS, formatting);
    actionList.putObject(idTxtt, textRange);
    textAction.putList(idTxtt, actionList);
    action.putObject(idT, idTxLr, textAction);
    app.executeAction(idsetd, action, DialogModes.NO);
	}

function layerUpdate(){
    if(documents.length > 0){
        //declare demo variables
        var text1 = "test";
        var text2 = "test replacement";
        var oldtSize = 48;
        var tSize = 24;
        var tFont = "Calibri";
        var tStyle = "bold";
        var tLead = 24;
        var boxH = 200;
        var boxW = 400;
        //end demo variables
        var originalDialogMode = app.displayDialogs;
        app.displayDialogs = DialogModes.ERROR;
        var originalRulerUnits = preferences.rulerUnits;
        var j = 0;
        try{
            var docRef = activeDocument;
            preferences.rulerUnits = Units.POINTS;
            var m = 0;
            for(var i = 0; i < docRef.artLayers.length; i++){
                var LayerRef = docRef.artLayers[i];
                if(LayerRef.kind == LayerKind.TEXT){
                    var TextRef = LayerRef.textItem;
                    TextRef.textComposer = TextComposer.ADOBESINGLELINE;
                    var layerText = TextRef.contents;
                    var newText = layerText.replace(text1, text2);
                    if(newText != layerText){
                        j = i;
                        TextRef.contents = newText;
                        if(TextRef.size == oldtSize){
                            TextRef.size = tSize;
                            TextRef.font = tFont;
                            TextRef.useAutoLeading = false;
                            TextRef.leading = tLead;
                            var l = TextRef.contents.split(/\r/);
                            docRef.activeLayer = LayerRef;
                            setFormatting(0, l[0].length, tFont, tStyle, oldtSize);
                            preferences.rulerUnits = Units.PIXELS;
                            if(TextRef.kind == TextType.PARAGRAPHTEXT){
                                TextRef.height = boxH;
                                TextRef.width = boxW;
                                }
                            preferences.rulerUnits = Units.POINTS;
                            break;
                            }
                        }
                    }
                }
            }
        catch(e){
            alert(e + '  ' + e.line);
            preferences.rulerUnits = originalRulerUnits;
            app.displayDialogs = originalDialogMode;
            return;
            }
        preferences.rulerUnits = originalRulerUnits;
        app.displayDialogs = originalDialogMode;
        }
    else{
        alert('You must have a document open to run this script.');
        return;
        }
    }

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 22, 2022 Mar 22, 2022

Copy link to clipboard

Copied

Sorry, I tried creating a script with your code, but when I run it, nothing happens...

As I mentioned, my level of scripting is zero, so I don't know if there's something else that needs to be done or not, but nothing happened when I ran it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 22, 2022 Mar 22, 2022

Copy link to clipboard

Copied

Sorry, but my knowledge when it comes to scripts is pretty much zero...

Where do I paste this code? I tried the Script Editor on Mac, but I get an error when I hit the "hammer" icon to compile it.

"Expected end of line, etc. but found unknown token."

And it points to this second line:

var w

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 22, 2022 Mar 22, 2022

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 22, 2022 Mar 22, 2022

Copy link to clipboard

Copied

Thank you. I save it as a .js file and was able to run it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 22, 2022 Mar 22, 2022

Copy link to clipboard

Copied

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-to...).

 

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).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 22, 2022 Mar 22, 2022

Copy link to clipboard

Copied

This is a demo to show you how to deal with different text attributes in one text layer. Basically an advanced scripting topic and demo. You could use this as a basis for a script that had a dialog box with sliders or number entry fields to choose how much to change the sizes. You wouldn't use fixed values hard coded, you would get the variable values from the user.

Photoshop doesn't have a way to do what you want. Period. So you either live with it or learn to script, or find a script that does what you need. I don't know of one and don't have time to code something up for you which is why I'm posting a script I already have.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Mar 22, 2022 Mar 22, 2022

Copy link to clipboard

Copied

@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_A_Marsh wrote a good instruction on working with scripts Downloading and Installing Adobe Scripts 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 23, 2022 Mar 23, 2022

Copy link to clipboard

Copied

Wow! That's amazing. It's working now 🙂

Really appreciate your time and help on this script.

 

I'm not very familiar with the whole "multiplier" thing you mention.

Basically my idea was that it would just increase / decrease the size of all text by a certain percentage and in that case you would't deal with fixed multiplier associated with a certain line of text. I wasn't really thinking about the complications of what you just mentioned, and it makes perfect sense to me now. Thanks for clarifying.

 

When I tested your script now, I wasn't really sure I understood why you added the BASE menu, but now I get it and it's really clever. You can pick a certain font size as your "anchor" and everything else will adjust to it. You have created something really helpful and I truly hope other people can use this. Maybe you can share it somewhere online as a downloadable file with some instructions on what it does, etc?

 

Again, thank you so much for you time and help!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Mar 23, 2022 Mar 23, 2022

Copy link to clipboard

Copied

I try to collect code snippets that I write in answers in this community. Often they become the basis for more complex scripts or for solving similar problems. Perhaps you can find something useful for yourself - https://github.com/boogalooper/Snippets

Unfortunately, I am lazy and do not like to write documentation, but in each code fragment I try to indicate a link to the topic in which there was a discussion.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 23, 2022 Mar 23, 2022

Copy link to clipboard

Copied

Thanks for sharing your GitHub. Saved it for later research 😉

When I said "instructions on what it does" it was just a brief description, for example in this case it could be something like

"Increate / decrease all text inside a text box, proportionally, when multiple font sizes are present".

 

But yeah, adding the link to the thread is helpful. You are doing a great job and I appreciate you sharing this with us!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 23, 2022 Mar 23, 2022

Copy link to clipboard

Copied

I'll have to take a look at your code samples when I have time. I'm doing something similar on my Dropbox with utility scripts I have written. Most have come about because I use them in production.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 24, 2022 Mar 24, 2022

Copy link to clipboard

Copied

Your solution made someone to emphasize it also in the title 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 24, 2022 Mar 24, 2022

Copy link to clipboard

Copied

I'm sorry, I don't get what you mean by that... Can you clarify?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 24, 2022 Mar 24, 2022

Copy link to clipboard

Copied

You said you can't edit your posts yet so I assume someone liked it enough to additionally add [SOLVED] in the title of your thread. That's not needed as we can mark solutions as correct.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 24, 2022 Mar 24, 2022

Copy link to clipboard

Copied

LATEST

Oh that...

Apparently, someone pumped me up a few "levels", because now I am able to edit my replies and my posts 😉

 

I'm part of a music forum as well and it's always good practice to add the [SOLVED] along with marking the correct answer, just because it's easier for people to see it when they go through a list of posts. It's just a habit of mine.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 22, 2022 Mar 22, 2022

Copy link to clipboard

Copied

A script returns only one value for text size, even if a text box has multiple sizes. It could possibly be done but not easily.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines