About InDesign Hyphens

A hyphen is a “punctuation mark used to join words and to separate syllables of a single word. (…) As an orthographic concept, the hyphen is a single entity. In terms of character encoding and display, that entity is represented by any of several characters and glyphs (including hard hyphens, soft or optional hyphens, and nonbreaking hyphens), depending on the context of use”Wikipedia.

Among other uses, the hyphen is involved in automatic hyphenation, in which case no input character is associated to it while a printable mark is rendered (based on some default glyph.) Conversely, the soft hyphen is an actual character (U+00AD) but it may remain invisible in terms of printable mark, as this depends on its location within the composed line.

A clear terminology is needed when talking about hyphens and hyphenation. Here is the one we shall use in this article:

Hyphen Input Character Glyph Remarks
Regular Hyphen U+002D HYPHEN-MINUS /hyphen In InDesign, most hyphenation effects rely on the glyph of this character, also referred to as the ASCII hyphen.
Unicode Hyphen U+2010 HYPHEN /hyphentwo Underused in most applications (incl. InDesign.) In principle, should behave as the Regular Hyphen although not necessarily looking identical to it.
Nonbreaking Hyphen U+2011 NON-BREAKING HYPHEN /hyphen (should be /u2011) IndyFont allows this character to have a dedicated glyph, but InDesign ignores it and uses /hyphen.
Visible Soft Hyphen U+00AD SOFT HYPHEN /hyphen (should be /sfthyphen) IndyFont allows this character to have a dedicated glyph, but InDesign ignores it and uses /hyphen. Referred to as the “discretionary hyphen” in InDesign, it only displays if the underlying character occupies a position where hyphenation does actually occur.
Hidden Soft Hyphen U+00AD SOFT HYPHEN none Not rendered if the character occupies a position where hyphenation does not actually occur.
Automatic Hyphen none /hyphen No underlying character, although the glyph is rendered at the end of the hyphenated line (according to hyphenation settings.) InDesign then uses the glyph of the Regular Hyphen.

Note. — The present article only focuses on hyphens due to their particular behavior in InDesign. It does not mention dashes, minus signs and various horizontal bars that do not intervene in the process of hyphenation. Using IndyFont you can easily design custom dashes or glyph variants for characters like U+2012 FIGURE DASH, U+2013 EN DASH, U+2014 EM DASH, U+2015 HORIZONTAL BAR, as you would do with any other printable character. (About InDesign special characters, refer to this older post.)

Let's summarize the rules InDesign applies when it meets hyphens:

How InDesign deals with hyphens.

The glyph of the regular hyphen (U+002D) is used wherever a hyphen needs to be printed. InDesign explicitly reports glyph substitution (yellow mark) for nonbreaking and automatic hyphens, but the rule also applies to the visible soft hyphen. Regarding the Unicode hyphen, InDesign uses its dedicated glyph if available.

The Appalling Truth

Technically, IndyFont would be able to assign a particular glyph to every character we have mentioned above, but InDesign will ignore most of them due to glyph substitution mechanism. To prove this fact let's design a minimal font where each particular hyphen has a distinct shape:

A minimal font for crash-testing hyphens.

In our font template the regular hyphen is represented by a slightly inclined line so that we can instantly identify any occurrence of that glyph. Then we have assigned a vertical line to the (visible) soft hyphen, a triangle to the Unicode hyphen, and a circle to the nonbreaking hyphen.

Below is the dialog before exporting this font from IndyFont. All characters and glyphs are perfectly valid and no error occurs during OpenType generation:

IndyFont ready to OTF-export.

Once the font TestHyphens-Regular is ready, let's create a frame and insert some arbitrary text with all possible hyphens. Note that paragraph hyphenation is turned on in order to produce an automatic hyphen at the end of the text. Here is the result with the nonbreaking hyphen selected:

InDesign ignoring our tedious artwork!

(Click the image to see the Glyphs panel too.) As you can observe our extra glyphs are inhibited—with the exception of the triangular Unicode hyphen associated to U+2010. In other words InDesign takes the regular glyph as the fundamental shape for any special hyphen no matter what your font actually provides for the underlying characters. Having the nonbreaking character selected—in InDesign CC 2017—we also see in the glyph square popup that its actual glyph should be a circle, although not being rendered as so.

Towards a Clean Solution

What we can conclude for now is, loading extra hyphen characters in IndyFont is useless since InDesign only agrees to speak with the regular hyphen.

But suppose your client wants automatic and soft hyphens to look like tildes (~) while regular and nonbreaking hyphens are to be drawn in a more classical, orthographical, way. A simple idea comes to mind: we can create an alternate glyph from IndyFont, for example /hyphen.swash, and automatically assign the corresponding OpenType feature to the desired hyphens. We just need a dedicated character style and a GREP-style-based redirection. Easy!

However, we must keep in mind that the automatic hyphen is not a character, meaning it cannot be the target of any GREP query. So it will inherit the style of the preceding character in the text flow, which should be considered the default style (i.e, without glyph variant.) Hence, going back to our font template, we have to rework the glyph of the regular hyphen (/hyphen) so that it meets the requirements for automatic and soft hyphens. The swash variant (/hyphen.swash) will be added for the purpose of specifically altering the behavior of characters that InDesign can actually target, that is, the regular U+002D hyphen and the nonbreaking U+2011 hyphen.

Below is the new state of the font template after these changes:

Regular and nonbreaking hyphens addressed through the “swash” variant.

Now let's run IndyFont to distill the final version of the font. Note we now have two glyphs, namely /hyphen and /hyphen.swash, linked to the character U+002D:

Newly registered glyphs seen from IndyFont's main dialog.

Next step is to create a “Swash” character style in InDesign, just turning on the Swash Alternates OpenType feature:

The “Swash” character style.

Finally we need a paragraph style with a GREP Style running on the class [-~~], which represents either the regular or the nonbreaking hyphen character. Here it is:

GREP-style command for handling regular and nonbreaking hyphens.

Does the magic happen? Just type some text to check whether regular and automatic hyphens look different:

Result in InDesign.

What is cool with this solution is that it does not violate the semantics of Unicode characters and relies on a single font.

Thanks to Camilo Umana who originally asked the question behind this article.