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

Issue with missing font code

Advisor ,
Jun 12, 2017 Jun 12, 2017

Copy link to clipboard

Copied

Can someone please help with the code below??

I am using this code to detect missing fonts as part of a script that exports pdfs.

The issue is but not on every document it will error thinking there is a missing font, but when I go under the Type/Find Font/Fonts in document all is good.

I can even do a direct pdf export out of InDesign without any issues and the fonts are fine in the pdf.

I am not a scripter so can someone please look and see if there's a bug in this code?? also what would it take to check within the document bounds and not look at any text frames on the pasteboard?

Maybe there is a better option for checking for missing fonts than what I am using.

Thanks in advance!

var usedFonts = app.activeDocument.fonts;

var missingItem = '\n'

for(var i = 0; i < usedFonts.length; i++){

    if(usedFonts.status != FontStatus.INSTALLED){

        missingItem += '\n' + usedFonts.fontFamily;

   alert('Document Contains Missing Fonts Job Aborted!')

                 exit();

            }

        }

TOPICS
Scripting

Views

1.1K

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
Enthusiast ,
Jun 12, 2017 Jun 12, 2017

Copy link to clipboard

Copied

Are you really using installed font or document font?

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
Advisor ,
Jun 12, 2017 Jun 12, 2017

Copy link to clipboard

Copied

The fonts are uploaded to an Extensis Universal Type server and there is also the Document Font folder with the document.

Thanks

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
Enthusiast ,
Jun 12, 2017 Jun 12, 2017

Copy link to clipboard

Copied

In this case, document fonts (in the folder) isn't installed. Right?

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
Advisor ,
Jun 12, 2017 Jun 12, 2017

Copy link to clipboard

Copied

The fonts would be out on the Universal Type server that InDesign is linked to thru a Extensis plugin.......but not in Font Book.

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
Enthusiast ,
Jun 12, 2017 Jun 12, 2017

Copy link to clipboard

Copied

As far as I know, the code "FontStatus.INSTALLED" will check if the font is

installed in the current machine.

​If you comment this section of your code, is the PDF exported correctly?​

PS: to comment an entire section you can put "//" in front of each line or

/* in the beggining and */ in the end of the section you want to comment.

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
Advisor ,
Jun 12, 2017 Jun 12, 2017

Copy link to clipboard

Copied

So when I comment that section and export the pdf, the pdf it exports fine with no font issues just like exporting it directly from InDesign.

Should this section have the Font Status set to NOT_AVAILABLE?

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
Enthusiast ,
Jun 12, 2017 Jun 12, 2017

Copy link to clipboard

Copied

That's it.

You got it.

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
Advisor ,
Jun 12, 2017 Jun 12, 2017

Copy link to clipboard

Copied

what else needs to change? because when I change it to the bombs either way.

var usedFonts = app.activeDocument.fonts;

var missingItem = '\n'

for(var i = 0; i < usedFonts.length; i++){

    if(usedFonts.status != FontStatus.NOT_AVAILABLE){

        missingItem += '\n' + usedFonts.fontFamily;

   alert('Document Contains Missing Fonts Job Aborted!')

                 exit();

            }

        }

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
Advisor ,
Jun 12, 2017 Jun 12, 2017

Copy link to clipboard

Copied

do I really need ".fontFamily" could this be a issue?

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
Enthusiast ,
Jun 12, 2017 Jun 12, 2017

Copy link to clipboard

Copied

If you're not showing an alert with what fonts are missing, you don't need it.

You don't need the var missingItem = '\n' too.

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
Advisor ,
Jun 12, 2017 Jun 12, 2017

Copy link to clipboard

Copied

I can't seem to get it to work correctly.............the alert was just to let the operator know the export was aborted

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
Enthusiast ,
Jun 12, 2017 Jun 12, 2017

Copy link to clipboard

Copied

var usedFonts = app.activeDocument.fonts;

var missingItem = '\n'

for(var i = 0; i < usedFonts.length; i++){

    if(usedFonts.status != FontStatus.INSTALLED){

        missingItem += '\n' + usedFonts.fontFamily;

   alert('Document Contains Missing Fonts Job Aborted!')

                 exit();

            }

        }

Try to substitute the code below by this:

var usedFonts = app.activeDocument.fonts;

var myArray = [];

for(var i = 0; i < usedFonts.length; i++){

    if(usedFonts.status == FontStatus.NOT_AVAILABLE){

        myArray.push(usedFonts.name);

            }

        }

if (myArray.length != 0) {

     alert('Document contains missing fonts. Job aborted!\r' + 'Unavailable fonts:\r' + myArray.join('\r'));

     exit();

     }

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 ,
Jun 13, 2017 Jun 13, 2017

Copy link to clipboard

Copied

This is some of my hacked up code lol. The variable missingItem builds a list to error to the user of what is missing, kind of like the above myArray. I am glad this question came up because I occasionally get the missing font error when it is not missing a font. Now I know why and can correct my script!

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
Advisor ,
Jun 13, 2017 Jun 13, 2017

Copy link to clipboard

Copied

Thanks for help!!!..........but for some reason I am having the same issue with the new code, it errors thinking there is a missing font now listing the font(s), but when I go under the Type/Find Font/Fonts in document all is good.

I can do a direct pdf export out of InDesign without any issues and the fonts are fine in the pdf.

Any thoughts??

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
Advisor ,
Jun 13, 2017 Jun 13, 2017

Copy link to clipboard

Copied

FYI

Thanks for help!!!..........but for some reason I am having the same issue with the new code, it errors thinking there is a missing font now listing the font(s), but when I go under the Type/Find Font/Fonts in document all is good.

I can do a direct pdf export out of InDesign without any issues and the fonts are fine in the pdf.

Any thoughts??

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 ,
Jun 13, 2017 Jun 13, 2017

Copy link to clipboard

Copied

LATEST

One thing I have found, is sometimes I have a character style or paragraph style that has a missing font, even if it isn't being used, that doesn't show up in the find fonts menu.

I am having trouble getting NOT_AVAILABLE to even report missing fonts, so you are ahead of me. Good fun indeed

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
Enthusiast ,
Jun 12, 2017 Jun 12, 2017

Copy link to clipboard

Copied

if(usedFonts.status != FontStatus.NOT_AVAILABLE)

You're checking if the usedFonts are NOT (!=) NOT_AVAILABLE

I think you need to check if it's available. Right? So, just check if the usedFont are NOT_AVAILABLE.

if(usedFonts.status == FontStatus.NOT_AVAILABLE)

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