July 16 2008 • 9:52 AM

Removing Space Along the Left Edge of Text

Here’s another mystery of the deep explained: Why do some characters sit flush against the side of a text frame and others get inset a bit, even when the Text Inset values (inside Object > Text Frame Options) are set to zero?

For example, take a look at these five fonts in a row:

All five are exactly the same size, but some are inset, some are flush, and one sticks out the left side of the frame a bit. What’s the deal? It all has to do with the font’s left side bearing, also sometimes called underhang, overhang, or padding.

When a font is designed, each character is placed on a grid, with the lower-left corner (the origin) at zero,zero. The designer then has to decide how far from that origin the left edge of the character should sit. Here’s an example taken from the Apple web site (my apologies for appropriating it, but it’s for educational usage; and I was afraid that Apple might take that page down sooner or later):

Here’s another page that has some nice font “metrics” graphics I found.

Virtually all characters in all fonts have a little bit of a left side bearing. A few have negative or zero left side bearings and have a bit of a right-side bearing instead. If a font has no sidebearings, then each character would smash into the next in a line of text!

So different fonts have different side bearings for each character. Mystery solved, right?

Well, there are also a couple other factors that come into play. First, the Optical Margin Alignment feature (which you can find by choosing Type > Story) can change the space along the left side of a frame significantly. In some fonts, turning on OMA will cause characters to move in dramatically, adding lots of space where there was previously none. I love the OMA feature, but one must be careful of it, especially in numbered or bulletted paragraphs, where it can cause major alignment problems.

Also, Adobe added a very, very cool feature to its drop caps formatting: If you open the Drop Caps and Nested Styles dialog box (or choose that inside your paragraph styles dialog box), you’ll see a checkbox called called Align Left Edge:

When ALE (I’m in an intialism mood) is on, InDesign removes the left sidebearing of the drop cap entirely, so it becomes flush with the left edge of the frame. Cool!

I figured I could remove the left sidebearing from a one-line paragraph by setting the drop cap Lines to 1, and turning on Align Left Edge. But unfortunately it doesn’t work. I guess InDesign ignores ALE when Lines = 1. Oh well. Maybe in CS9.

In the meantime, there are, of course, tricks to fake InDesign into moving the left edge of a line of text — even moving it right out the left edge of the frame. The basic method is to place a space (or one of the whitespace characters) at the beginning of the line, then placing the cursor between the space and the first character of text, and then kerning backward… a lot!

You can also put the line of text into a table, make sure the cell insets are set to zero, right align the paragraph that the table is on, and make the table wider than the text frame. Did I say it was easy or fun? No. But you can do it!

[Note: See "script alert" in comments below to find a Dave Saunders script that removes the space for you automatically.]

20 Responses discussing this post. Add yours below.

  1. Scott
    July 16th, 2008 • 10:37 am • Link

    Great description, David… this pokes at my ribs once and a while too. Luckily I have a passion for kerning or it could be upsetting.

    What’s the font you used in the top instance of pear? It’s not a face I recognize. Thanks.

  2. David Blatner
    July 16th, 2008 • 11:16 am • Link

    @Scott: The font is District

  3. July 16th, 2008 • 2:52 pm • Link

    Thanks for this put-space-first-then-kern trick, David! It solves this rather annoying problem well enough. It’s a kludge, yes, but they also serve.

  4. Lauren
    July 16th, 2008 • 4:14 pm • Link

    this is something that has puzzled me in the past… and your solution was my solution! but it’s nice to know WHY.
    thanks again as always!

  5. July 16th, 2008 • 6:44 pm • Link

    Try this:

    1. Type into a new text frame: “Many are the ways.” (without the quotes).
    2. Set the type to be Myriad Pro Black 12 points.
    3. Switch on Optical Margin Alignment for the story.

    Huh? The “M” moves to the right? That I cannot explain. But there’s more:

    4. Open the Drop Caps and Nested Styles dialog and set the line of text to have a two-line, one-character drop-cap.
    5. Activate Align Left Edge.
    6. Close the dialog.

    Now, with the Story panel visible, toggle Optical Margin Alignment on and off and watch what happens to the gap between the “M” and “a” of many.

    However, all this has given me insight into how to write a script to do Align Left Edge for the first character of ordinary paragraphs. I’ll be back.

  6. July 16th, 2008 • 8:29 pm • Link

    Well, an update before I call it a day: the logic looks right. The math looks right. The results don’t.

    So, maybe tomorrow.

    Dave

  7. Jochen Uebel
    July 16th, 2008 • 10:15 pm • Link

    Hi Dave.
    As soon I am choosing justified alignement ID’s behaviour becomes clear for me:
    1. OMA widens the net space for every line (hyphenation left or right is the proof).
    2. ID is trying to avoid new breaks in this situation.
    3. Therefore all characters have to be pulled a bit to the left and right to fill the space (only those in the center of a line stay where they are). ((Means: OMA is changing the kerning!))
    4. Therefore it is not astounding (for me) that in case of ALE the drop cap is fixed but all the other characters are moving a bit.
    May be my early morning enlightenment (7 a.m. in Germany) could be of help for you and your script: Having such a script would be wonderful. (Having a ALE for one line still more.)
    Jochen

  8. July 17th, 2008 • 5:12 am • Link

    Math was right, my foot! There are 12 points in an em set at a size of 12 points, not the 72 I was working with last evening.

    [Editor's note: If you're interested in a more detailed analysis of Dave's script, how he wrote it, and why it works, check out the post he did on his blog. We've removed those matters from his comments on this page, to spare non-technical folks the scary details.]]

  9. July 17th, 2008 • 7:02 am • Link

    I’m wondering about “baseline” in that diagram borrowed from the Apple site. It looks to me like they’re trying to refer to “character width” or something like that.

  10. July 17th, 2008 • 7:12 am • Link

    Yes, Glyph origin should use an angled call-out line to indicate that it is pointing at a specific point and not a line. “Baseline” should be where they have the words “Glyph origin”.

    Dave

  11. David Blatner
    July 17th, 2008 • 8:17 am • Link

    SCRIPT ALERT: Dave Saunders has graciously allowed us to distribute the cool script he wrote, which removes the space to the left of any first line of text in a paragraph. For example, the first two lines below are “before,” and the last two lines are “after” running the script:

    You can download the (CS3 only) script by clicking on this link to the zip file.

    The script adds a hair space before the line, then figures out the proper kerning to “zero out” the space. Very clever, and a big timesaver!

  12. David Blatner
    July 17th, 2008 • 8:19 am • Link

    Dave S. also remarked that this version of the script:
    a) works on all paragraphs in a selection
    b) detects that a paragraph has a drop-cap and just makes sure that ALE is on for that paragraph
    c) skips over any paragraph that already starts with a hair space
    d) gives an alert if the attempt to process a paragraph pushes it overset breaking the attempts to read insertion point information (thinks: same thing will happen if the paragraphs start out overset). The user might have to do some repair in this case.

  13. July 17th, 2008 • 8:30 am • Link

    Wow, Dave! This works, so we don’t need to twiddle with this manually anymore — thank you!

  14. Eugene Tyson
    July 17th, 2008 • 8:49 am • Link

    That is just fantastic, not only did he write the script, but explained what each bit did, which is fascinating, I’ve never seen a break down of a script before and what each piece does. It’s fascinating.

    Any chance of making this a blog post of it’s own?

    Good job, Dave!

  15. July 20th, 2008 • 6:24 am • Link

    Great script, Dave. But have you noticed what happens when there’s no room at the bottom of the text frame (for instance if you have done a fit frame to content) and try the script on the last line? Ugly error message and we are left with problems…

  16. July 20th, 2008 • 7:24 am • Link

    Yep. I warned about that in point d of the comments David published above. I wrote this as a proof of concept and before you know it David wanted a version to publish so I banged out a control loop.

    I’ll try to improve on that. But you can probably fix it by just hitting Undo a small number of times (probably 3 times — once to undo the drop-cap and twice to get the ruler units back to what they were).

    Dave

  17. David Blatner
    July 21st, 2008 • 5:39 am • Link

    I’ve heard that it’s often true with scripts that it’s about 20% of the work to write the basic script, and 80% of the work to handle all the things that may go wrong with it (putting in error handling, dealing with edge cases, and so on). Especially with a free script, we can’t expect it to work perfectly.

    I find it’s often a good idea to save your documents before running a script; that way you can always use Revert to get back to where you were. Scripts may run dozens or even hundreds of “actions” on your document, and using Undo after that can get tedious (I’ve been there).

  18. July 21st, 2008 • 8:53 am • Link

    I’d probably put that ratio closer to 5% – 95% !!!

    To write the script may not take more than an hour or two, but to get rid of all those little holes can take weeks. (especially if it’s dealing with a large number of variables/uses…)

  19. Stephan Möbius
    July 30th, 2008 • 1:52 am • Link

    One more thank you! Thank you so much.

  20. Nik
    September 22nd, 2009 • 1:28 am • Link

    I can’t get my Drop Caps to align to the left margin! Help!

    I am using Myriad Pro Regular for my body and Myriad Pro Bold Condensed for my Drop Cap.

    I have set the Drop Cap to be a 5 lines deep and one character, I have set it to be left aligned in the Drop Cap and Nested Styles menu, it does move over but not enough, it needs to move over about twice the distance.

    I have tried the other methods and Daves script (though I know it’s me and not your awesome scripting handywork Dave!) but to no avail!

    Any and all help much appreciated.

    Regards,

    Nik.

Subscribe to the Discussion

Get the ongoing discussion surrounding "Removing Space Along the Left Edge of Text" delivered to you. Click here to subscribe via RSS.

Leave a Reply

You can use limited HTML tags, such as <em></em> for emphasis/italics and <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> .

InDesignSecrets reserves the right to edit and/or remove posts and comments.