6 Replies Latest reply on Apr 2, 2013 1:21 PM by Aubreyff

    Layer > Type > Replace All Missing Fonts with jsx.

    Aubreyff Level 1

      Hi All,

       

      I am trying to use the Layer > Type > Replace All Missing Fonts command from a jsx script. Is it possible?

       

      Thank you,

      Aubrey

        • 1. Re: Layer > Type > Replace All Missing Fonts with jsx.
          c.pfaffenbichler Level 9

          Does ScriptingListener.plugin record any code for this?

          • 2. Re: Layer > Type > Replace All Missing Fonts with jsx.
            Paul Riggott Level 6

            If there is no scriptlistner output you could try recording an action and use Insert Menu Item from the action palette fly-out menu, this hopefully should generate some code.

            1 person found this helpful
            • 3. Re: Layer > Type > Replace All Missing Fonts with jsx.
              Aubreyff Level 1

              Thank you both, very much. This forum is very helpful.

              • 4. Re: Layer > Type > Replace All Missing Fonts with jsx.
                xbytor2 Level 4

                If you really do need to call a menu item in JS that doesn't generate listener code, here's how

                I do it.

                 

                1) Create an action with a single step, the Insert Menu Item bit.

                 

                 

                2) Run ActionToXML.jsx from xtools. You'll end up with a file that looks like this:

                 

                <ActionFile key="MenuItem.atn" file="/private/var/folders/gj/t92cwx212c9gdvhl_8xh5qc80000gn/T/TemporaryItems/MenuItem.atn">
                  <ActionSet version="16" name="MenuItem" expanded="false" count="1">
                    <Action key="1" name="MenuItem" expanded="false" count="1">
                      <ActionItem key="TEXT" expanded="false" enabled="true" withDialog="false" dialogOptions="3" identifier="TEXT" event="select" name="Select" hasDescriptor="true">
                        <ActionDescriptor key="select" count="1">
                          <DescValueType.REFERENCETYPE key="1853189228" id="1853189228" symname="Null" sym="null">
                            <ActionReference key="1853189228" Id="1853189228" symname="Null" sym="null" count="1">
                              <ReferenceFormType.ENUMERATED key="1299062816" id="1299062816" symname="MenuItem" sym="Mn  " desiredClassString="MenuItem" desiredClass="Mn  " enumeratedTypeString="MenuItem" enumeratedType="MnIt" enumeratedValueString="ToggleInfoPalette" enumeratedValue="TglI"/>
                            </Actionreference>
                          </DescValueType.REFERENCETYPE>
                        </ActionDescriptor>
                      </ActionItem>
                    </Action>
                  </ActionSet>
                </ActionFile>
                

                 

                 

                3) The part that you need is the ID for the menu item. It is the enumeratedValue attribute of ReferenceFormType.ENUMERATED. In this case it's 'TglI' for Windows->Info which toggles the Info palette.

                 

                 

                4) Here's code for calling a menu item.

                 

                function doMenuItem(itemID, interactive) {
                  function cTID(s) { return app.charIDToTypeID(s); };
                  function sTID(s) { return app.stringIDToTypeID(s); };
                
                  var desc = new ActionDescriptor();
                  var ref = new ActionReference();
                
                  ref.putEnumerated(cTID("Mn  "), cTID("MnIt"), itemID);
                  desc.putReference(cTID("null"), ref);
                
                  var lvl = $.level;
                  $.level = 0;
                  try {
                    var mode = (interactive != true ? DialogModes.NO : DialogModes.ALL);
                    executeAction(sTID("select"), desc, mode);
                
                  } catch (e) {
                    $.level = lvl;
                    if (e.number != 8007) { // if not "User cancelled"
                      throw e;
                    } else {
                      return false;
                    }
                  }
                  $.level = lvl;
                
                  return true;
                };
                

                 

                 

                5) The code to invoke the menu item in question would look like this:

                 

                doMenuItem('TglI');
                
                • 5. Re: Layer > Type > Replace All Missing Fonts with jsx.
                  Michael L Hale Level 5

                  Newer versions of Photoshop have an app method for running menu items.

                   

                  app.runMenuItem();

                  • 6. Re: Layer > Type > Replace All Missing Fonts with jsx.
                    Aubreyff Level 1

                    I was able to use ScriptingListener.plugin.

                    I opened a file with missing fonts and ran Layer > Type > Replace All Missing Fonts.

                    In the ScriptingListener.log was this code.

                     

                     

                    var idreplaceSubstitutes = stringIDToTypeID( "replaceSubstitutes" );

                    executeAction( idreplaceSubstitutes, undefined, DialogModes.NO );

                     

                    It seems to have worked.