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

The requested font family is not available.

Explorer ,
Sep 10, 2023 Sep 10, 2023

Copy link to clipboard

Copied

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

Views

346

Translate

Translate

Report

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. 

Votes

Translate

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

Copy link to clipboard

Copied

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

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

P.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

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