Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have encountered something while using fontspec that I do not quite understand. What is the scope of a font feature added using the \addfontfeatures command? For instance, consider the example below using lualatex:

 \setmainfont{TeX Gyre Termes}





 Here is some text that is long enough so that it will involve a single proper hyphenation at the end of the first line.

      Here is some text that is long enough so that it will involve a single proper hyphenation at the end of the first line.%

 Here is some text that is long enough so that it will involve a single proper hyphenation at the end of the first line.


The option Numbers=OldStyle is only applied locally and does not exit the braces, but the option HyphenChar=None continues after the braces end. Is there a way to limit the scope of HyphenChar as Numbers is limited above?

share|improve this question

1 Answer 1

up vote 13 down vote accepted

Good question!

Some assignments performed by TeX (and also by XeTeX) are always global. You find the list on page 277 of the TeXbook or section 10.2 in TeX by Topic. Among them is setting the \hyphenchar of a font, which is the primitive operation performed by the


option, or any other setting of the same key.

So, no, there is no way to limit the scope of that declaration. Simply declaring a new font family using the same font but changing the hyphenchar will not work, as the value is associated to the memory location relative to the font and fonts loading the same TFM file (standard TeX) or the same OTF file (XeTeX) will share the hyphenchar.

A possible workaround is to define a new font family slightly scaling the font:







{\mainno\the\hyphenchar\font\lipsum*[2]} \the\hyphenchar\font \lipsum[3]


The settings are just to encourage hyphenation. The first part of the paragraph will have no hyphens and start with -1, while the second part will be hyphenated and start with 45. Of course the first part will have many overfull lines. Here's an image (second part truncated):

enter image description here

It's also possible to say

\the\hyphenchar\font \lipsum[3]
share|improve this answer
Well, with \aftergroup and some bookkeeping, fontspec could (and maybe should) take care of (re)setting the hyphenchar. –  Robert Dec 15 '12 at 2:14
@Robert TeX uses only one value of \hyphenchar for each font, the one current at the end of the paragraph. When TeX splits a paragraph into lines, it has forgotten about grouping structures and is just confronted with a horizontal list. And defining a new font family doesn't help either, because the hyphenchar is associated to the memory location for the font information and fonts corresponding to the same TFM file (or OTF or TTF in case of XeTeX) can't have different hyphenchars. –  egreg Dec 15 '12 at 11:04
after reading the surrounding material in the TeXbook it makes a lot more sense now...perhaps a note about HypenChar should be included in the fontspec documentation. The addfontfeatures command is introduced in the context of using it for local modifications, which is what prompted this question in the first place. –  Jeremy Engel Dec 15 '12 at 23:26
@grizzilus I've added a hack, which shouldn't be too noticeable (the font is scaled at 99.9%). –  egreg Dec 15 '12 at 23:38
@Robert Curious; it works if you say \hyphenchar=-1, but not if you say \hyphenchar=64 (or any other number). Seems like a bug in LuaTeX. –  egreg Dec 16 '12 at 23:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.