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

Detecting Fonts within Clipping Masks

New Here ,
Feb 01, 2019 Feb 01, 2019

Goal: search the document and output a .info/text of all fonts used in the illustrator document, including within transparency masks.

When a font is used via the transparency panel, it is not output with either the document info -> save function or the find font > save list features provided from illustrator.

But it is output via packaging, and shows up in the package>fonts folder. So somehow illustrator was able to find it in the transparency mask.

Is there a way to latch onto this font hidden in a transparency mask for list output?  

Below is a script borrowed/modified from a few sources to search within a directory folder for an AI file and to output an info file, but it cannot detect fonts in a transparency mask either. Any suggestions on how to include fonts clipped in those transparency masks in the output?

//Font Finder modified

//ignore target error below on line 3

#target illustrator 

 

var inputFolder = Folder.selectDialog("Select a folder contains adobe Illustrator files ");  // Establish directory scope

 

if (inputFolder) { 

    var fileList = inputFolder.getFiles('*.ai'),  // Target only adobe illustrator files

        fontsInfo = []; 

    loadXMPLibrary(); 

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

        if (fileList instanceof File && fileList.hidden == false) { 

            fontsInfo.push(getFontsInfo(fileList)); 

        } 

    } 

    unloadXMPLibrary(); 

 

var Loginfo = new File(inputFolder + '/Font.info.txt'); 

Loginfo.open('w', 'TEXT', '????'); 

var info = fontsInfo.join('\n\n'); 

Loginfo.write(info); 

Loginfo.close(); 

 

if (/(Open Type|TrueType)/.test(info)) { 

    alert('Fonts Output to Designated Folder as .info') 

 

function getFontsInfo(file) { 

    var arr = ['File: ' + decodeURI (file.name)], 

        xmpFile, oXmp, fontNumber, i, path, fontname, fonttype, ns = 'http://ns.adobe.com/xap/1.0/t/pg/'; 

    xmpFile = new XMPFile(file.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_READ); 

    oXmp = xmpFile.getXMP(); //Returns an XMPMeta object 

    fontNumber = oXmp.countArrayItems(ns, 'xmpTPg:Fonts'); 

    xmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY); 

    if (fontNumber) { // if there's at least 1 font, proceed 

        for (i = 1; i <= fontNumber; i++) { 

            path = XMPUtils.composeArrayItemPath(ns, 'xmpTPg:Fonts', i); 

            fontname = oXmp.getStructField(ns, path, XMPConst.TYPE_FONT, 'fontName'); 

            fonttype = oXmp.getStructField(ns, path, XMPConst.TYPE_FONT, 'fontType'); 

            arr.push([i, '. ', fontname, '-', fonttype].join('')); 

        } 

    } 

    return arr.join('\n'); 

 

function loadXMPLibrary() { 

    if (!ExternalObject.AdobeXMPScript) { 

        try { 

            ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript'); 

        } catch (e) { 

            alert('Unable to load the AdobeXMPScript library!'); 

            return false; 

        } 

    } 

    return true; 

 

function unloadXMPLibrary() { 

    if (ExternalObject.AdobeXMPScript) { 

        try { 

            ExternalObject.AdobeXMPScript.unload(); 

            ExternalObject.AdobeXMPScript = undefined; 

        } catch (e) { 

            alert('Unable to unload the AdobeXMPScript library!'); 

        } 

    } 

TOPICS
Scripting
440
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
no replies

Have something to add?

Join the conversation
Adobe