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

Shortcut for changing (not all) but selected text in layer to specific font family

New Here ,
Mar 08, 2024 Mar 08, 2024

Copy link to clipboard

Copied

Hi,

I'm looking for a custom keyboard shortcut that will change my selected text within a layer to a specific font within the same font family. I do not want to change the font of the whole layer.

 

Currently, I have to go back and forth with mouse & keyboard and am looking for a quick way to avoid this and do all with keyboard.

 

See screenshots below.

 

Thanks.

Screenshot 2024-03-08 at 11.43.41 AM.png

Screenshot 2024-03-08 at 11.43.55 AM.png

Screenshot 2024-03-08 at 11.44.13 AM.png

   

TOPICS
Actions and scripting , macOS

Views

72

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
Adobe
Community Expert ,
Mar 10, 2024 Mar 10, 2024

Copy link to clipboard

Copied

To be blunt: 

While this may be possible via Scripting (with some workaround to determine the selected range) I would recommend doing type-heavy work in more appropriate software (Indesign, Illustrator, … for example). 

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
People's Champ ,
Mar 10, 2024 Mar 10, 2024

Copy link to clipboard

Copied

As far as I know, these are the only keyboard shortcuts available:
rbin_0-1710094641546.png

 

 

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 11, 2024 Mar 11, 2024

Copy link to clipboard

Copied

LATEST

This is a demo that splits your text layer at the return character and formats just one piece. I use this basic process in numerous text processing scripts. Sorry for the lack of comments, again this is just a framework.

#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;
        var tColor = new SolidColor;
        tColor.rgb.hexValue = "FF0000";
        //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;
                            TextRef.color = tColor;
                            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