5 Replies Latest reply on May 20, 2015 10:12 PM by BEGINNER_X

    Alert Missing Fonts

    BEGINNER_X Level 3

      Hi All,

      FYI., new to Illustrator & Illustrator scripting.

       

      Request:

      Need alert, if the illustrator document having missing fonts.

       

      In Indesign, we should use the below code:

       

      Missing_Font();
      function Missing_Font()
      {
          var myUsedFonts = app.activeDocument.fonts;
          for (var i = 0; i < myUsedFonts.length; i++) {
          if (myUsedFonts[i].status != "1718831470")
          {
              alert("Please Fix Missing Font")
              exit(0);
              }
          }
      }
      
      

       

       

      Thanks in advance

      Siraj

        • 1. Re: Alert Missing Fonts
          Ten A Adobe Community Professional

          Here is a verify document<->system fonts sample code.

           

          function getSysFonts(){

            var f = app.textFonts;

            var fontLst = [];

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

            fontLst.push(app.textFonts[i].name);

            }

            return fontLst.join(";");

            }

           

          function getFntsLst (doc){

               var xmlString = new XML(doc.XMPString);

               var fntFace = xmlString.descendants("stFnt:fontName");

               var lst = [];

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

            lst.push(fntFace[i]);

               return lst;

            }

           

          var st="";

          var ft = getFntsLst (app.activeDocument);

          var sysFt = getSysFonts();

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

            if (sysFt.indexOf(ft[i])>-1) st += ft[i] + " : found in system.\n";

            else  st += ft[i] + " : not found in system.\n";

            }

           

          alert (st);

           

          スクリーンショット 2015-05-20 16.35.00.png

           

          Documents font information in XMP string and System fonts list in textFonts property under the application.

           

          Ten

          • 2. Re: Alert Missing Fonts
            BEGINNER_X Level 3

            Hi Ten,

             

            Thanks for your quick response...

             

            My request is,

            if the document having any missing fonts, then the script should alert("Document having missing fonts. Please check")

             

            I tried your script, it will list out all the used fonts only. Not shows missing font.

             

            Script Output Screenshot:

             

            Screen Shot 2015-05-20 at 3.27.38 PM.png

             

             

            Please look at Document Find Font Screenshot:

             

            Screen Shot 2015-05-20 at 3.27.09 PM.png

            • 3. Re: Alert Missing Fonts
              Ten A Adobe Community Professional

              mmmm....

              Sorry, I think textFonts property not contain missings, But I its wrong.

              There seems to not in useful properties in AI.

              I'll search another way to detect it...

               

              Ten

              • 4. Re: Alert Missing Fonts
                Ten A Adobe Community Professional

                Here is a reference thread:

                https://forums.adobe.com/thread/1075283

                 

                However, We can predefine and save  textFonts. When you need to check fonts, Read it and compare Documents font list.

                 

                Ten

                • 5. Re: Alert Missing Fonts
                  BEGINNER_X Level 3

                  Hi Ten,

                   

                  Thanks a lot!!!!

                  No words to say, you did a excellent job for me.

                   

                  Tested in single file, Works like a charm.

                   

                  Even though, I need to check with all live jobs.

                   

                  Again Thanks

                  Siraj