Skip to main content
Known Participant
September 11, 2023
Answered

The requested font family is not available.

  • September 11, 2023
  • 2 replies
  • 835 views

Hello guys, I'm having an error when try to replace a font using InDesign script like this:

 

function editTextFonts (openDoc, tfEditData, textFrame) {
    var lines = textFrame.lines
    var firstLine = lines.firstItem()
    var oldFont = firstLine.appliedFont

    if (!tfEditData.hasOwnProperty('font')) {
        return oldFont
    }

    var font = tfEditData.font
    var changeFont = oldFont.postscriptName.indexOf(font) === -1

    if (!font || !changeFont) {
        return oldFont
    }

    var newFont = findFontByPostscriptName(font, app.fonts)

    if (newFont === null || newFont.status !== FontStatus.INSTALLED) {
        return oldFont
    }

    for (var i = 0; i < lines.length; i++) {
        var line = lines[i]
        line.appliedFont = newFont.postscriptName
    }

 

 

When tries to assign newFont.postscriptName in appliedFont I got the error: The requested font family is not available. I have checked and the font is properly installed, even the variable newFont has the status INSTALLED. Any help with this will be really appreciated

This topic has been closed for replies.
Correct answer Peter Kahrel

Are you sure that the PostScript name is always the same as the font name? Sometimes they are spelled differently. 

2 replies

Peter Kahrel
Community Expert
Peter KahrelCommunity ExpertCorrect answer
Community Expert
September 14, 2023

Are you sure that the PostScript name is always the same as the font name? Sometimes they are spelled differently. 

Known Participant
September 18, 2023

Hey Peter, actually changing newFont.postscriptName for newFont.name fixed the problem. Really appreciate the help

Peter Kahrel
Community Expert
Community Expert
September 11, 2023

What data type is newFont.postscriptName? If it's a string, maybe use

line.appliedFont = app.fonts.item(newFont.postscriptName);

P.

Known Participant
September 14, 2023

That didn't solve the problem, the problem is happening with some fonts, not all of them, and when you check the font with problems, they are already installed