8 Replies Latest reply: Jul 4, 2012 6:42 AM by Transcon Guy RSS

    How to get the original font version?

    Transcon Guy Community Member

      Hi everydody,

       

      How can I get the original font version used in InDesign? Actually I can use the InDesign XMP data to have the last font version used but not the original one.

       

      InDesign seems to keep that somewhere because if I use a different font version when I open a document and I go to type --> Find Fonts... and click "More Info", I can see "Version: 001.001 (Created with - 001.002)".

       

      I'm looking to do a script that will compare font version between fonts  availlable to InDesign and Fonts  needed by the document. Actually InDesign don't warn about this on open.

       

      Javacript or applescript.

       

      Thanks!

        • 1. Re: How to get the original font version?
          Harbs. CommunityMVP

          var font = app.fonts[0];

          alert("Name: " + font.name + "\rVersion: " + font.version);

          • 2. Re: How to get the original font version?
            Harbs. CommunityMVP

            Try comparing app.fonts to doc.fonts...

            • 3. Re: How to get the original font version?
              Transcon Guy Community Member

              Thanks Harbs but I should be more precise. I want to compare the font version used actually in document against the original font version.

               

              The info shown in find font about version is:

              Version: 001.001 (Created with - 001.002)

               

              Where InDesign store the original information about fonts? I know InDesign write the last font information used into XMP when saving. Is InDesign keep previous XMP somewhere so it can find the first time a font have been used and retreive the version?

              • 4. Re: How to get the original font version?
                Harbs. CommunityMVP

                Do you get the same thing using Document.fonts.item() as Application.fonts.item()?

                • 5. Re: How to get the original font version?
                  Transcon Guy Community Member

                  It depend how I load my font. If my font is in folder "~/Applications/Adobe InDesign CS5.5/Fonts" or "~/Library/Fonts", Document.Fonts is equal to Application.fonts. If I put my font in "Document Fonts" folder beside my ID document, it is possible to have 2 fonts with the same name and different version between Document.fonts and Application.Fonts but after a test, what is in Application is just a list of availlable fonts to InDesign and Document.fonts is the actual loaded fonts.

                   

                  When fonts are missing using Document.fonts, I can get the name but the version output strangely like:

                   

                  Document Fonts:

                  Helvetica Rounded          Bold  Version 2.062;PS 2.000;hotconv 1.0.57;makeotf.lib2.0.21895

                  Brush Script          Medium  Version 2.062;PS 2.000;hotconv 1.0.57;makeotf.lib2.0.21895

                   

                  Normaly when my fonts are active the result is:

                   

                  Document Fonts:

                  Helvetica Rounded          Bold  001.001

                  Brush Script          Medium  001.001

                   

                  I'm looking now to use Document.stories.item() to gather original font version...

                  • 6. Re: How to get the original font version?
                    Transcon Guy Community Member

                    After many tries with Document.stories.item() it seems I can get only the first font used in each stories. It looks also if fonts are missing I can get only the font name et not the version. Maybe I don't use the right object... I have trouble to understand the Data Browser of ExtendedScript toolkit. Now my result is with missing fonts:

                     

                    Stories Fonts:

                    Brush Script          Medium  Can't find Version

                    Helvetica Rounded          Bold  Can't find Version

                     

                    and with font loaded at application level:

                    Stories Fonts:

                    Brush Script          Medium  001.001

                    Helvetica Rounded          Bold  001.001

                     

                    Here the script I use:

                     

                    var myApplicationFonts = app.fonts;

                    var myDocument = app.documents.item(0);

                    var myDocumentFonts = myDocument.fonts;

                    var myFontNames = myApplicationFonts.everyItem().name;

                    var myDocumentFontNames = myDocument.fonts.everyItem().name;

                    var myDocumentFontVersion = myDocument.fonts.everyItem().version;

                    var mytFontVersion = myApplicationFonts.everyItem().version;

                     

                    var myString = "\rApplication Fonts:\r";

                    for(var myCounter = 0;myCounter<myFontNames.length; myCounter++){

                    myString += myFontNames[myCounter] + "  " + mytFontVersion[myCounter] + "\r";

                    }

                    myString += "\rDocument Fonts:\r";

                    for(var myCounter = 0;myCounter<myDocumentFontNames.length; myCounter++){

                    myString += (myDocumentFontNames[myCounter]);

                        try{

                        myString += ("  " + myDocumentFontVersion[myCounter] + "\r");

                        }

                        catch(err)

                        {

                        myString += "  Can't find Version \r";

                        }

                    }

                    myString += "\rStories Fonts:\r";

                    for(var myCounter = 0;myCounter<myDocument.stories.length; myCounter++){

                    myString += (myDocument.stories.item(myCounter).appliedFont.name);

                        try{

                        myString += ("  " + myDocument.stories.item(myCounter).appliedFont.version + "\r");

                        }

                        catch(err)

                        {

                        myString += "  Can't find Version \r";

                        }

                    }

                    myString;

                     

                    Any idea? It should have a way to get the original font version if InDesign can remember it...

                    • 7. Re: How to get the original font version?
                      [Jongware] CommunityMVP

                      The Font object in Javascript has some peculiar properties. If the font is installed on your system, you can use it to inquire full name, path, version, etc. But if it's not installed (showing the "font missing" dialog), you cannot access it in any way through Javascript. You can sort of 'see' it with Document Fonts but you can't ask what version it ought to be.

                       

                      Anyway, if you do have that same font but you might have another version, you cannot check the "original" version number either. "The" version number of a font is always the one in your system.

                       

                      Any idea? It should have a way to get the original font version if InDesign can remember it...

                       

                      InDesign can, because the original version number is stored in the .indd file, but this information is not exposed to the scripting engine.

                       

                      (Bah! I just exported a test file to .idml, unpacked it, checked the file Resources/Fonts.XML and ... it contains the version numbers from the InDesign file, not the 'originals'. There goes another idea.)

                      • 8. Re: How to get the original font version?
                        Transcon Guy Community Member

                        Thanks Jongware, it looks really like it. Finally I will use the XMP of InDesign to have the last used font version instead of the original one.

                         

                        var myDoc = app.activeDocument;

                        var myDocXMP = app.activeDocument.metadataPreferences;

                        var theEvalCount =  myDocXMP.countContainer ("http://ns.adobe.com/xap/1.0/t/pg/", "xmpTPg:Fonts")

                        var myCount = eval( theEvalCount );

                        var myInfo = new Array

                        myInfo.push(myDoc.name);

                         

                           try {

                                var j = 0

                                    for ( j = 0; j < myCount; j++) {

                                    var fontVersionEvalString= "myDocXMP.getProperty(\"http://ns.adobe.com/xap/1.0/t/pg/\", \"xmpTPg:Fonts[" + [j+1] + "]/stFnt:versionString\")";

                                    var fontVersion = eval(fontVersionEvalString)

                                    myInfo.push( fontVersion);

                                    }

                                }catch (e){

                            }

                         

                        myInfo;