Skip to main content
Participant
September 18, 2023
Question

Photoshop API: How to replace a missing font?

  • September 18, 2023
  • 1 reply
  • 507 views

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 has been closed for replies.

1 reply

Adobe Employee
September 26, 2023

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"
      }
    ]
  }
}
Participant
September 2, 2024

did it worked ?

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

Participant
September 2, 2024

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