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

The requested font family is not available.

Explorer ,
Sep 10, 2023 Sep 10, 2023

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

TOPICS
Scripting
648
Translate
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

correct answers 1 Correct answer

Community Expert , Sep 14, 2023 Sep 14, 2023

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

Translate
Community Expert ,
Sep 11, 2023 Sep 11, 2023

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

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

P.

Translate
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
Explorer ,
Sep 13, 2023 Sep 13, 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

Translate
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
Community Expert ,
Sep 14, 2023 Sep 14, 2023

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

Translate
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
Explorer ,
Sep 18, 2023 Sep 18, 2023
LATEST

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

Translate
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