Skip navigation
Currently Being Moderated

[AS][CS5] Find and replace a missing font

Jan 28, 2012 5:08 PM

I have an overly complex script that compares the document's fonts missing fonts to the system fonts and makes a best guess. It was written to handle conversion of Multi-ad Creator documents to InDesign. It has worked 100% of the time so far. It needs a LOT of cleaning up and tweaking to make effecient, but that is not the point of my question. Everyday I am sent an InDesign file I have to work with and everyday it will has a missing font. Arial (OTF).

I ran my script thinking it would replace it with Arial (TT). No problem...

 

Ran it... nothing.

 

When I use the find dialog in Indesign to search based on the applied font it works, the returned properties in AS contain:

 

return properties of find text preferences

font:"Arial (OTF)"

 

Ok, fine so I try...

 

set properties of find change text options to {case sensitive:false, whole word:false, include footnotes:false, include hidden layers:false, include locked layers for find:true, include locked stories for find:true, include master pages:true}

    set applied font of find text preferences to "Arial (OTF)"

    set applied character style of change text preferences to "Page&Header"

    tell document 1

        set myFoundItems to change text

    end tell

 

Nothing.

 

This has pretty much worked on every other font I've tried, so what am I doing wrong here?

 
Replies
  • Currently Being Moderated
    Jan 29, 2012 2:59 AM   in reply to lithodora

    lithodora wrote:

     

        set applied font of find text preferences to "Arial (OTF)"

     

    What happens if you use:

     

        set applied font of find text preferences to font "Arial (OTF)"

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 29, 2012 9:22 PM   in reply to Shane Stanley

    Use the Type Menu -> Find Font to easy replace the missing fonts manually.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 30, 2012 4:20 AM   in reply to lithodora

    lithodora wrote:

     

    On a side note: It seems almost everytime I google for something to do with scripting this stuff your name pops up in the thread. Directly (here) and indirectly (old mail lists) you have been a great help to me in most of my endeavours at automating. I just wanted to say thanks.

     

    <blush> Glad to know it helps.

     
    |
    Mark as:
  • John Hawkinson
    5,572 posts
    Jun 25, 2009
    Currently Being Moderated
    Feb 1, 2012 12:40 AM   in reply to lithodora

    So what happened? I woudl speculate that you might have to omit the (OTF) from the font name. I realize this might be seriously problematic.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 1, 2012 2:20 AM   in reply to John Hawkinson

    John, I too would have tried that… App dictionary says:

     

    applied font (any) : The font applied to the find text preference, specified as either a font object or the name of font family. Can return: font, string or nothing.

     

    Other apps like to use the postscript name but Im not sure if thats the case here…?

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 1, 2012 1:18 PM   in reply to Muppet Mark

    I suppose we should wait to hear back from the OP, but I thought I would chime in to say that CS5 acts weeeeeird when you have different faces of the same font from different font types (which I think is the only time you see the "(T1)", "(TT)" or "(OTF)"), in a way that CS4 didn't. I don't have mixed faces of Arial, but I do of Helvetica Neue. If I do a findText() with this findTextPreference:

     

    app.findTextPreferences.appliedFont = "Helvetica Neue (T1)     47 Light Condensed";
    

     

    I get nothing, even though I should. When I then look at the Find/Change dialog in the UI, I see:

     

    Screen shot 2012-02-01 at 2.57.17 PM.PNG

     

    (Note the "TT".) Assigning a string rather than font to findTextPreferences.appliedFont, or using "Helvetica Neue" or "Helvetica Neue (T1)", gets me the same thing: nothing found, and "Helvetica Neue (TT)" displayed in the Find/Change UI.

     

    I can specify any of those in the UI and it works as expected—as it did in CS4. I ran into a different but related issue, involving idml interpretation, with CS5, and filed a bug report, but have not had a chance to see if it was fixed in 5.5.

     

    Jeff

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 4, 2012 7:49 PM   in reply to lithodora

    Thus far you confirmed everything I found while experimenting in Javascript ...

     

    It seems a missing font is not a Font -- the internal type for InDesign, with a name, an id, a version number etc. etc. Since it's not a Font, none of the regular ways of using it work: not by object id, not by name, and not by direct object reference. The "(OTF)" and "(TT)" suffixes are not part of the font name, as you can see when doing this

     

    alert (app.selection[0].appliedFont.name);

     

    with the text cursor inside a missing font. Note that ID still thinks it's a Font object:

     

    alert (app.selection[0].appliedFont);

     

    will say it's [Object Font], but about the only thing you can access is its name. Stuff like "app.selection[0].appliedFont.fullName" will return an error.

     

    I gave up trying to script this.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points