GREP

226 views
Skip to first unread message

Richard Holstein

unread,
Dec 10, 2012, 12:32:13 PM12/10/12
to indesign-talk
After applying a style to a paragraph, can GREP then find all the missing glyphs?

Thanks,
Richard

Roy McCoy

unread,
Dec 10, 2012, 12:38:03 PM12/10/12
to indesi...@googlegroups.com
How does applying a paragraph style change anything about what was said earlier on this?

Roy

steve harley

unread,
Dec 10, 2012, 12:47:50 PM12/10/12
to indesi...@googlegroups.com
On Mon, Dec 10, 2012 at 10:32 AM, Richard Holstein
<drahc...@gmail.com> wrote:
> After applying a style to a paragraph, can GREP then find all the missing
> glyphs?

it doesn't matter whether you apply a style first or not

InDesign's Find/Change GREP tool can't find missing glyphs from the
user interface, but the script i posted on your other thread can find
them; did you find that useful? the script applies a character style,
is that what you want to with the missing glyphs?

Richard Holstein

unread,
Dec 10, 2012, 1:26:48 PM12/10/12
to indesi...@googlegroups.com
Roy- I was away and could no longer find the earlier conversation for some reason...but I have now.

Steve- I will now try the script you posted, my knowledge of apple script is very limited. I realize that the_fonts, a_font,  the_missing, c, "chinese text" need to replaced with something but I don't know with what. Could you be a bit more specific/wordy for a non-programmer, as to what i need to place in there.

Rebecca- your solution makes perfect sense but entails up front work which I am trying to eliminate if at all possible.



--
You received this message because you are subscribed to the Google Groups "InDesign talk" group.
To post to this group, send email to indesi...@googlegroups.com.
To unsubscribe from this group, send email to indesign-tal...@googlegroups.com.
Visit this group at http://groups.google.com/group/indesign-talk?hl=en.



steve harley

unread,
Dec 10, 2012, 3:12:13 PM12/10/12
to indesi...@googlegroups.com
On Mon, Dec 10, 2012 at 11:26 AM, Richard Holstein
<drahc...@gmail.com> wrote:
> Steve- I will now try the script you posted, my knowledge of apple script is
> very limited. I realize that the_fonts, a_font, the_missing, c, "chinese
> text" need to replaced with something but I don't know with what. Could you
> be a bit more specific/wordy for a non-programmer, as to what i need to
> place in there.

i don't know your experience level or the details of your situation …
from what you've written, it sounds like you are on a Mac, and you
know how to run an AppleScript but aren't sure about what you might
need to be ready to run the script, is that right?

the script is very simple, and simply assumes you want to apply a
specific character style to every missing glyph in the front InDesign
document — is that what you want to do?

if so, the only thing that has to be replaced is "chinese text" —
replace that with the name of the character style you want to apply
(keep the double quotes); test it after saving a copy of your document
just in case

if you have further questions or experience errors, please ask

Roy McCoy

unread,
Dec 10, 2012, 4:36:59 PM12/10/12
to indesi...@googlegroups.com
steve harley wrote:

> replace that with the name of the character style you want to apply

And which he's created and defined to apply the desired font -
which is obvious of course, but just for the sake of completeness.


Roy

Richard Holstein

unread,
Dec 10, 2012, 4:56:46 PM12/10/12
to indesi...@googlegroups.com
This is working beautifully! Now one step further, this script will change the whole document (there could be some Korean paragraphs or other languages that I would want to change to their own fonts). What should added/changed to only apply to a selection (I would place the script in InDesign's scrip folder).

BTW you are right on all counts, mac, description...

Thank you.

steve harley

unread,
Dec 10, 2012, 5:06:38 PM12/10/12
to indesi...@googlegroups.com
Richard seemed to spell that out in the initial message

Roy McCoy

unread,
Dec 10, 2012, 5:34:11 PM12/10/12
to indesi...@googlegroups.com
Richard wrote:

This is working beautifully! Now one step further, this script will change the whole document (there could be some Korean paragraphs or other languages that I would want to change to their own fonts). What should added/changed to only apply to a selection

This thread seems to be involving an AppleScript script pretty exclusively, so you might want to move it to the applescriptingindesign group, to which I just now added you.

That said, your question raises some interesting issues and I'll probably learn something from this. The script Steve posted on December 4, and which I don't think he modified later, was:

tell application "Adobe InDesign CS6"
  set the_fonts to get fonts of front document
  repeat with a_font in the_fonts
    set find glyph preferences to nothing
    set glyph ID of find glyph preferences to 0
    set applied font of find glyph preferences to a_font
    set the_missing to find glyph
    repeat with c in the_missing
      set applied character style of c to "chinese text"
    end repeat
  end repeat
end tell

I would have expected "set the_missing to find glyph" to be either "set the_missing to find glyph document 1" or in a tell statement to document 1. But there's no explicit stipulation of a find range, and what I don't know is whether find glyph defaults to document 1, or whether this script might apply - or try to apply - the style to every ID document open at the time the script was activated.

To return to your question, the normal way to stipulate a selection rather than a story or doc would be, I imagine, "set the_missing to find glyph selection".


Steve wrote, quoting me:

And which he's created and defined to apply the desired font -
which is obvious of course, but just for the sake of completeness.

Richard seemed to spell that out in the initial message

Well, he seemed to have forgotten some other things.
My note was for him, and not for you (of course).


Roy

steve harley

unread,
Dec 10, 2012, 5:39:07 PM12/10/12
to indesi...@googlegroups.com
On Mon, Dec 10, 2012 at 2:56 PM, Richard Holstein <drahc...@gmail.com> wrote:
> This is working beautifully! Now one step further, this script will change
> the whole document (there could be some Korean paragraphs or other languages
> that I would want to change to their own fonts). What should added/changed
> to only apply to a selection (I would place the script in InDesign's scrip
> folder).

glad it's working; it's very bare bones, so i'm slightly surprised; to
work with the currently selected text in the front document, you can
change this one script line to add a clause at the end:

set the_missing to find glyph selection of front document

if the script seems slow, it could probably be sped up by applying the
character style with the find glyph settings, rather than changing one
character at a time; if it's fast enough, then leave well enough alone

steve harley

unread,
Dec 10, 2012, 6:02:21 PM12/10/12
to indesi...@googlegroups.com
On Mon, Dec 10, 2012 at 3:34 PM, Roy McCoy <roymc...@gmail.com> wrote:
> This thread seems to be involving an AppleScript script pretty exclusively,
> so you might want to move it to the applescriptingindesign group, to which I
> just now added you.

well, you'll leave me out if you take it there; i haven't wanted to
join yet another group


> That said, your question raises some interesting issues and I'll probably
> learn something from this. […]
>
> I would have expected "set the_missing to find glyph" to be either "set
> the_missing to find glyph document 1" or in a tell statement to document 1.
> But there's no explicit stipulation of a find range, and what I don't know
> is whether find glyph defaults to document 1, or whether this script might
> apply - or try to apply - the style to every ID document open at the time
> the script was activated.

i was aware i had left that unaddressed in my proof of concept script;
it is almost easier to test than to ask the question, but it does
illustrate a principle: a missing object reference typically means the
command addresses the innermost surrounding tell block, in this case
the application; so there _is_ an explicit stipulation, and it does
indeed change all the docs you have open; caveat emptor!


> To return to your question, the normal way to stipulate a selection rather
> than a story or doc would be, I imagine, "set the_missing to find glyph
> selection".

interestingly, "find glyph selection" applies to the selection only in
the front doc, not everything selected in any doc; this is true for
"selection" in general, despite the fact it is a valid property of the
application object; so i would call this an error in the semantics of
the dictionary

Richard Holstein

unread,
Dec 11, 2012, 9:15:32 AM12/11/12
to indesi...@googlegroups.com
Working perfectly (selection)...Thanks you!


Brad Walrod

unread,
Dec 11, 2012, 3:56:18 PM12/11/12
to indesi...@googlegroups.com
Steve,

I’ve been trying to get this to work on a test doc, hoping to use it in the future as I could sure have used it in the past, and I can’t seem to get it to work. I suspect my test is faulty.

After changing the ID version number (5.5) in the script and the character style name to one I created (“missingglyphs”) I tried running it on text that had been formatted as Garamond Premier Pro to pick up its support of Cyrillic glyphs.

I changed one word to Univers 45 Light and got pink highlighting and blank glyphs (i.e., not a square with an x in it, just blank). Running the script just shows a null field (--> {}) in the replies section of the event log (AS Editor 2.3), and no characters get the character style applied to them.

Any ideas to nudge me in the right direction? Thanks.

Brad

steve harley

unread,
Dec 11, 2012, 4:20:07 PM12/11/12
to indesi...@googlegroups.com
On Tue, Dec 11, 2012 at 1:56 PM, Brad Walrod <br...@kenozatype.com> wrote:
> Steve,
>
> I’ve been trying to get this to work on a test doc, hoping to use it in the future as I could sure have used it in the past, and I can’t seem to get it to work. I suspect my test is faulty.
>
> After changing the ID version number (5.5) in the script and the character style name to one I created (“missingglyphs”) I tried running it on text that had been formatted as Garamond Premier Pro to pick up its support of Cyrillic glyphs.
>
> I changed one word to Univers 45 Light and got pink highlighting and blank glyphs (i.e., not a square with an x in it, just blank). Running the script just shows a null field (--> {}) in the replies section of the event log (AS Editor 2.3), and no characters get the character style applied to them.

the technique uses an unsupported "feature" in scripting finds, so
details can only be worked out by educated guesses; my guess is that
the blank vs. x-box representation is the key to why it's not working
— it seems InDesign thinks there's a glyph there, rather than a
missing glyph, but i don't know why

i can experiment later with Cyrllic in Univers to see if i get the
same results in ID6

Brad Walrod

unread,
Dec 11, 2012, 4:41:22 PM12/11/12
to indesi...@googlegroups.com
Yeah, I thought that the missing “missing glyph” glyph might be an issue, only thinking of it when I was trying to describe what I saw (or didn’t see) on the screen. Thanks for whatever you have time to suss out later.

In the meantime, I’ve saved the script as is and will look forward to using it to apply a searchable character style to x-box glyphs in the future.

Brad

steve harley

unread,
Dec 12, 2012, 5:20:31 PM12/12/12
to indesi...@googlegroups.com
On Tue, Dec 11, 2012 at 1:56 PM, Brad Walrod <br...@kenozatype.com> wrote:
> After changing the ID version number (5.5) in the script and the character style name to one I created (“missingglyphs”) I tried running it on text that had been formatted as Garamond Premier Pro to pick up its support of Cyrillic glyphs.
>
> I changed one word to Univers 45 Light and got pink highlighting and blank glyphs (i.e., not a square with an x in it, just blank). Running the script just shows a null field (--> {}) in the replies section of the event log (AS Editor 2.3), and no characters get the character style applied to them.

Univers seems like an odd duck for this script, but i found a
solution; first how i found it:

i pasted some sample Cyrillic text into a doc

На берегу пустынных волн
Стоял он, дум великих полн,
И вдаль глядел. Пред ним широко
Река неслася; бедный чёлн
По ней стремился одиноко.

then i applied Univers 45 to some of it and observed the same "blank
pink glyphs" you described

while probing further i found a clue, and i believe this technique may
have broader application:

i copied a character represented one of these glyphs, went into
Find/Change > Glyph, set the Font prefs to Univers 45 and the ID
pop-up to Unicode; then pasted; the Cyrillic glyph displayed, but when
i changed the pop-up to GID/CID, the glyph was replaced by the number
229

the GID is an index into the font's tables, and may vary according to
the character set the font uses use; when i opened InDesign's Glyph
window for Univers 45 and used the flyout menu to sort by CID/GID
(yes, the acronyms are reversed in this flyout versus the Find/Change
pop-up); scrolling to the end it was immediately evident that the
highest GID for Univers is 228

(aside, if you try this in Suitcase Fusion's View Glyphs window,
you'll see an off-by-one error — Suitcase thinks there's a glyph 229
because it starts counting glyphs at one instead of zero)

the upshot is that the pink blanks representing missing glyphs are
represented by GID 229 and we can use that in the script; if you've
got the script set up already, just replace 0 with 229 and give it a
try

(i tried several other fonts and found only one other that works like
Univers in this respect; for Carta Medium the magic number was 189;
from scant evidence, these unusual missing glyphs seem to use the
highest GID in the font plus one)

Brad Walrod

unread,
Dec 12, 2012, 8:08:04 PM12/12/12
to indesi...@googlegroups.com
Strange, indeed. Sorry I happened to pick that font! I tried changing the 0 to 229 but AS gave me a “Invalid Find Glyph” error.

Brad
> you'll see an off-by-one error -- Suitcase thinks there's a glyph 229
> because it starts counting glyphs at one instead of zero)
>
> the upshot is that the pink blanks representing missing glyphs are
> represented by GID 229 and we can use that in the script; if you've
> got the script set up already, just replace 0 with 229 and give it a
> try
>
> (i tried several other fonts and found only one other that works like
> Univers in this respect; for Carta Medium the magic number was 189;
> from scant evidence, these unusual missing glyphs seem to use the
> highest GID in the font plus one)
>

steve harley

unread,
Dec 12, 2012, 10:14:50 PM12/12/12
to indesi...@googlegroups.com
On Wed, Dec 12, 2012 at 6:08 PM, Brad Walrod <br...@kenozatype.com> wrote:
> Strange, indeed. Sorry I happened to pick that font! I tried changing the 0 to 229 but AS gave me a "Invalid Find Glyph" error.

can't explain that; i'm using the Adobe PS version of Univers with
CS6, activating via Suitcase Fusion 4 on OS X 10.7.5; you might try
repeating my steps to see what glyph number it produces, and take it
from there; or use a different font (i tried may 15, PS OT & TT, and
only Univers and Carta did the "blank pink")
Reply all
Reply to author
Forward
0 new messages