Thanks for coming to InDesignSecrets.com, the world's #1 resource for all things InDesign!

Insert a Special Character with GREP Styles

You want to put a logo at the end of every story. Or you want to insert a special character or picture after each instance of a word in a document. Why not automate it in InDesign CS4 with GREP Styles? Well, because GREP Styles only lets you apply a character style, not perform a find/change… that is, you cannot insert or change any characters using this feature.

Or can you?

Here’s a fun workaround: You can replace any character in your story with another by choosing a different font! For example, if you apply a character style that is defined with the Zapf Dingbats font to the letter “n” you’ll get a black square.

So what if you change a character — say, the final period at the end of a story — to a font that has your logo in it? Or a dingbat of your choice? It’s easy to do: Just create a new font with a utility such as TypeTool. [Editor's note: A newer tool, called IndyFont, let's you do this right inside of InDesign.] For example, I opened a font (it’s easier to start with an exsiting font, I find), found the period character, and pasted this little logo into it:

I adjusted the right bearing (side) so that it would fit both the dot and the logo. Then I changed the font information (gave it a new name, etc.) and exported my new font. The whole thing took no more than 10 minutes. (Mostly just trying to get the outlines right in the character.)

After installing my font (I just put an alias of it in the Fonts folder inside the InDesign folder), I added a GREP Style to the paragraph style definition –  the paragraph style that I knew would be at the end of each story where I wanted that logo.

The backslash-period in the style above indicates a period. The backslash-Z means “at the end of the story.” The character style simply changes to my font that I created.

The result? InDesign automatically “inserts” my logo at the end of every story in that paragraph style:

And it does it on the fly, so if I add a new paragraph after this one, the logo drops off this one and is added to the new last paragraph. I love that.

I did something similar with the spacebar character: Just replaced the space with a special dingbat character (with space on either side of it). That way, I could make a grep style that searches for one space after a particular word.

Even better: When the text is exported, that formatting disappears (because the space is just a space, and the period is just a dot), so I just get the underlying story.

Tags
Related Articles
Comments

14 Comments on “Insert a Special Character with GREP Styles

  1. David,

    You need to legally change your name to Igor David or International Designer. Then when you put your icon at the end of the story, you are also putting your initials there too!

  2. Well, granted, the “ID” logo I created for this tip isn’t a real logo. I just grabbed a few characters and threw them together.

    This tip was inspired, by the way, by the formatting at The National newspaper in Abu Dhabi, UAE, where I was just doing some training. All their news stories start with a city name followed by two slashes. I was horrified to think that someone sits and types slash-slash all day long. So I changed my font’s space character to look like a double-slash with some space on either side. Then a quick grep style automatically applies my font to the proper space after the city name.

  3. Nice trick, but it’d be much better if ID’s character and paragraph styles let us specify start and end text strings for either sort of style, perhaps with their own character styles. Then an end of story logo would be easy, as would inserting text like “Name:” and “Price:” using Nested Styles when creating personnel lists and catalogs. And in technical writing, it’d allow terms like “Warning:” to be automatically inserted.

    Sigh! Yet another feature I miss from FrameMaker….

  4. @Mike

    You mean it can’t do that?

    In a way that’s actually a relief?as I’ve been searching high and low for a day looking for a way to do just that in ID CS3. At least I know I’ve all of a sudden forgot how to search!

    How or why that’s not available is really beyond me.

  5. I don’t want to hijack the discussion away from a useful use of grep styles, but…

    been having discussions w/ Legal teams about altering a font, or creation of new characters based on the original.

    I’m not a lawyer (and have yet to play one on TV) but my understanding is *modifying the font software is illegal* as it violates the license agreement. That is, the code that draws the characters is subject to copyright, and your license to use said software does not convey the right to modify or alter it.

    That said, the character *shapes* themselves – the plotted vectors and resulting typography resulting from the mathematical algorithms that define how the lines are drawn – are not subject to US copyright. (They are, I believe, in the UK.)

    You could still create a custom font – say, a logo as a character (I used to work for a publisher that had several such custom fonts) – and use that font wherever you’d use the logo (manually or via this tip).

    But what you’re specifically prohibited from doing is opening up one of your licensed fonts and making a change to the character set, even if you’re saving the change as a new font file.

  6. You could still create a custom font ? say, a logo as a character (I used to work for a publisher that had several such custom fonts) ? and use that font wherever you?d use the logo (manually or via this tip).

    Or you can use a font that allows modification in its license, such as a SIL OFL, or Apache license.

  7. For days I have been attempting to figure out how to take a self made .eps dingbat and have it appear on the first line of the first paragraph of my nested style group. I’m asking you…is there any way without doing the manouvers above you so adroitly figured out? I’m just a bit less inclined to download software at work for this. Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>