Skip to main content
Participant
Sep 18, 2023 7:12 PM UTC
Question

Photoshop API: How to replace a missing font?

Hello. I'm editing a PSD file's text layers with the Photoshop JavaScript API. The original file features the Adobe Clean Medium font, so I want to keep it. Since by default the API replaces it with Arial, I'm explicitly setting the desired font in the call's options object. For the href property, I uploaded the font file (an OTF) to an AEM instance and successfully created an Adobe I/O signed URL out of it. This is the relevant section of my code:

const axios = require('axios');

//...

let requestBody = {
  "inputs": [
    {
      "href": inputUrl,
      "storage": "external"
    }
  ],
  "options": {
    "manageMissingFonts": "useDefault",
    "globalFont": "Adobe Clean Medium",
    "fonts": [
      {
        "storage": "external",
        "href": fontUrl //"<SIGNED_GET_URL_TO_AdobeClean-Medium.otf>"
      }
    ],
    "layers": [
      {
        "name": "layer2",
        "text": {
          "contents": "content 1",
        }
      },
      {
        "name": "layer3",
        "text": {
          "contents": "content 2",
        }
      }
    ]
  },
  "outputs": [
    {
      "href": outputUrl,
      "storage": "external",
      "type": "vnd.adobe.photoshop"
    }
  ]
};

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://image.adobe.io/pie/psdService/text',
  headers: {
    'Authorization': 'Bearer ' + aioToken,
    'x-api-key': aioApiKey,
    ...data.getHeaders()
  },
  data: JSON.stringify(requestBody)
};

try {
  let resp = await axios.request(config);

  //...
} catch(e){
  console.error(e)
}

My code looks almost the same as in the docs  However, although the text is modified, I'm not getting the font replaced. What am I doing wrong?

This topic is closed to new replies. Start a new post to keep the conversation going.

4 replies

Adobe Employee
Sep 26, 2023 4:06 PM UTC

Hello,

Looks like you are doing everything the docs says.  I'll let the dev knows.  However, can you try the following workaround by specifying the postScriptName explicitly, for example

 

{
  "options": {
    "layers": [
      {
        "text": {
          "characterStyles": [
            {
              "fontPostScriptName": "MyriadPro-Bold",
            }
          ]
        },
        "name": "someLayerName"
      }
    ]
  }
}
Translate
Participant
Sep 2, 2024 2:10 PM UTC

did it worked ?

i have the same problem and it is not working for me

Translate
Participant
Sep 2, 2024 6:25 PM UTC

I'm no longer working on this project, but this workaround didn't work for me either when I tried it.

Translate