• 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 find/replace on certain missing fonts

Community Expert ,
Mar 11, 2021 Mar 11, 2021

Copy link to clipboard

Copied

Hi all, 

 

This one's been driving me a bit crazy. End goal is to do a find/replace missing font by CSV, but having inconsistent results with how certain document.fonts are being identified and found. Also seeing inconsistencies across OSes (I am on Mac 10.15.6, running InDesign 16.0.1). I am unable to find some of the T1 fonts, and their names display just as Helvetica, not Helvetica Neue (T1). 
I had someone test on High Sierra, InDesign 15 and had no problem finding and replacing all the fonts. Also been having issues on Windows 10, ID 16.1, my client's machine. They were able to find a couple of the T1 fonts, but not all. Their log file is attached. 
I'm curious if others wouldn't mind testing on the attached idml and sharing their log file with me to see if I can get to the root of the issue. Potentially a move away from TrueType font support already? Pardon some of the inefficiences in the code; just trying to solve this bug and cobbled together snippets from the main codebase I'm working on. 

 

Much appreciated. 

 

 

var logger = function(msg) {
    try {
        //var d = new Date();
        var f = File("~/Desktop/fontReplacer-log.txt");
        f.encoding = "UTF-8";
        f.open("a");
        f.writeln(msg);
        f.close();
    }
    catch(e) {
    }
};

var main = function() {
    var usedFonts = app.activeDocument.fonts;
    var numFonts = usedFonts.length;
    logger("Used fonts: " + numFonts); 
    var missingFonts = [];
    for ( var i = numFonts - 1; i >= 0; i-- ) {
        logger("-------------");
        logger(usedFonts[i].name);
        if ( usedFonts[i].status != FontStatus.INSTALLED ) {
            logger("Font is missing");
            //missingFonts.push(usedFonts[i]);
            
        }
        var myFontFamily = usedFonts[i].fontFamily;
        //---------------------------------------------------------------------------------------------------------
        var myFontStyle = usedFonts[i].name.replace(/.+\t/,"").replace(/(.+)(\1)/,"$1");
        //---------------------------------------------------------------------------------------------------------

        logger( "Found:\tmyFontFamily = " + myFontFamily + "\tmyFontStyle = " + myFontStyle )

        app.findChangeTextOptions.includeMasterPages = true;

        app.findTextPreferences = app.changeTextPreferences = null;
        app.findTextPreferences.appliedFont = usedFonts[i];
        app.findTextPreferences.fontStyle = myFontStyle;

        myFound = app.activeDocument.findText();
        var F = myFound.length;

        app.changeTextPreferences.appliedFont = "Minion Pro";
        app.changeTextPreferences.fontStyle = "Regular";
        app.activeDocument.changeText();

        logger( "Done! [" + F + "]" )
    }
    alert("Done!");
} 

main();

 

 

TOPICS
Scripting

Views

665

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 ,
Mar 11, 2021 Mar 11, 2021

Copy link to clipboard

Copied

Here are results from the log from my machine just now. Having trouble uploading the idml; getting this error message: 

  • The attachment's testdoc1.idml content type (application/octet-stream) does not match its file extension and has been removed.

Here's a DB link to the IDML. 

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
Contributor ,
Mar 13, 2021 Mar 13, 2021

Copy link to clipboard

Copied

Here's my result. Tested on Windows 10 with InDesign 2021 (16.1)

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 ,
Mar 13, 2021 Mar 13, 2021

Copy link to clipboard

Copied

Interesting result. You had successful finds for everything but: 

  • It skipped over T1 55 Roman
  • It skipped over T1 77 Bold Condensed
  • It found two instances of T1 57 Condensed; maybe the 77 from above?
  • It skipped Helv Neue Regular (not T1)
  • It skipped Regular Helvetica Bold and Light

 

Thanks for testing. 

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 ,
Mar 13, 2021 Mar 13, 2021

Copy link to clipboard

Copied

Disregard, figured out why some were skipped; it was a problem with the iterator. Only question left is why the two instances of 57 Condensed. I fixed the code above to fix the iterator issue, for anyone else who might be able to test. 

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 ,
Mar 18, 2021 Mar 18, 2021

Copy link to clipboard

Copied

Here is mine.

Sorry. Windows 10 64.

InDesign 2020 15.1.1

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 ,
Mar 18, 2021 Mar 18, 2021

Copy link to clipboard

Copied

Thanks, Luis. OS and ID Version?

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 ,
Mar 18, 2021 Mar 18, 2021

Copy link to clipboard

Copied

LATEST

I found that using doc.fonts is unreliable if you check for missing fonts.
I used it on an export script which regulary found "missing" fonts which in fact weren't (e.g. some Helvetica).

I switched to using a preflight profile which checks for missing fonts and catch the result from there (for some output info).

Nevertheless, attached my log (macOS 10.13.6, InDesign 15.1.3)

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