Skip to main content
Inspiring
April 5, 2026
Question

Font Assignment in Script not Working

  • April 5, 2026
  • 3 replies
  • 103 views

We have a script that checks all styles for a font selected by the user, and changes that style to another font selected by the user. BUT, changing the font from “Gotham (T1)\tMedium” to “Gotham\tMedium” does nothing.

 

So I figured I’d first change the font to something else entirely. BUT, when I apply the new “Gotham\tMedium” IT AUTOMATCIALLY REVERTS TO THE (T1) FONT AGAIN!!!!

 

Does anyone know how to “force” the “AppliedFont” attribute to actually work in this situation and get rid of the dang Type1 font?

 

Thanks!
Ken

    3 replies

    Kasyan Servetsky
    Legend
    April 6, 2026

    I wrote a few scripts for replacing fonts. But with some fonts it works, with others it doesn't. I think the reason is that, at some point, the 'find-replace by script' feature was broken and became totally buggy.
    Sometimes, but not always, exporting files to IDML and back to INDD fixes the problem.

    TNTGuysAuthor
    Inspiring
    April 6, 2026

    Thanks for somewhat confirming my “doesn’t feel right” / “is this broken?” thoughts.

     

    Gladly, after making all the styles based on no other style the built-in replace fonts worked properly.

     

    Thanks again for posting.

    Brad @ Roaring Mouse
    Community Expert
    Community Expert
    April 6, 2026

    A couple of questions.

    Is this an old document that did use the Type 1 version?

    What version are you using now? From Adobe Fonts or other? Where did the original Type 1 come from?

    Does your Script also find the fonts in all Styles, used or not, and updates them?

    Part of the issue is the way InDesign stores information internally for fonts, etc, etc. It will include the font type along with all its other relevant data.

    You can see this if you save out an IDML file and open that in an XML editor (like BBEdit): the Resources > Fonts section will list all the fonts used in the document and also the type.

    The problem lies in that this internal database doesn’t necessarily remove all the old references, so even if you do a Find/Replace and switch to Opentype version (which is what I assume you are doing), you have to get EVERY reference to it, which means updating all Styles that have Gotham applied, used or not. Regardless, InDesign is properly using the correct font outline as it recognizes fonts by the internal PostScript name, but since there’s a mismatch with the font type, it flags those by adding the “(T1)”.

    THEN you have to save the file so the database gets properly rewritten. Sometime you have to save out as an IDML file and reopen it to clear out all the old cruft.

     

     

     

    TNTGuysAuthor
    Inspiring
    April 6, 2026

    Yes, old InD file that once used Type1. I know about the internal font type as it’s part of the object model, but I couldn’t find anything regarding it that would help me get around the problem.

    Gladly, after making all the styles based on no other style the built-in replace fonts worked properly.

    Thanks for posting.

    Community Expert
    April 5, 2026

    Hi Ken,

    I don’t think you’re doing anything wrong here, per se, without seeing your code → this appears to be an InDesign font-mapping conflict.

    What I would imagine is happening here is that when both Gotham (T1) and Gotham (OpenType) are present, InDesign’s internal font engine is seeing them as the same family. When your script assigns the new font, InDesign 'resolves' that name to the first version it finds in cache, or something along those lines, which is why it feels like it’s automatically reverting.

     

    I think I’ve found that the only 100% reliable way is to deactivate/uninstall the Type 1 version of Gotham. Since Adobe ended Type 1 support recently, InDesign is particularly 'glitchy' when legacy and modern versions of the same family coexist.

    The Script 'Force' Fix: Instead of assigning the font object (e.g., ps.appliedFont = targetFont), try assigning the string name and the style separately. This forces InDesign to re-evaluate the mapping:

    JavaScript
    ps.appliedFont = "Gotham"; 
    ps.fontStyle = "Medium";


    Type > Find/Replace Font. If you see the (T1) version there, use the 'Change All' button to swap it to the OpenType version manually. Once the document 'forgets' the T1 version, your script should stop fighting the ghost of the old font.

     

    If you’re on a tight deadline, deactivate the T1 font in your font manager and embrace sanity!

    TNTGuysAuthor
    Inspiring
    April 5, 2026

    That’s the frustrating thing, the Type1 font is NOT installed at all.

     

    I started down the script route because trying to use InD’s built-in missing / replace font feature was mystically changing the Medium weight to Book, even though I was telling it to turn the T1 Medium to the OTF Medium.

     

    I ended up using ANOTHER script to make all the styles based on none, then InD’s replace font feature seems to have worked correctly and kept the Medium as Medium. Though I’ve not scrutinized things yet to see what else might have gone awry.

     

    Thanks for posting.

    Community Expert
    April 5, 2026

    Can you share your script? And maybe a sample file. See if can get something working. Not sure how I’d mirror your setup with fonts, but willing to try.