In Russian typography the emdash, which is typed as the ligature ---
in LaTeX, is 20% shorter than the standard emdash. The babel
package cares this difference so that ---
prints a shorter emdash if russian
is the current language. However this switch mechanism works only for latex.exe
engine whereas lualatex.exe
and xelatex.exe
type long emdash in any case.
This is because under LaTeX \selectlanguage{russian}
switches current encoding from, say, OT1
or T1
to, say, T2A
. As a result latin emdash comes from, say, cmr
font family, whereas russian emdash comes from LH fonts (as a rule). Under LuaTeX or XeLaTeX \selectlanguage
does not switch current encoding (it remains EU2 for LuaTeX or EU1 for XeTeX) so that ---
always came from same font.
Note however that most fonts contain dashes of different length and, thus, it is possible (in principle) to map ---
to different code points depending on the current script.
My question is: how to do that using instruments provided by the fontspec
package?
Note that babel
provides a shorthand "---
(if the russian
option is indicated) which always types 20% shorter emdash but it also reduces spaces around the emdash and prevents the line break after it.
UPDATE:
I have realised that there is no code point in modern Open Type fonts (in contrast to metafont LH fonts used in legacy LaTeX for typesetting cyrillic texts). Both polyglossia
and babel
with russian
option compose a shorter emdash from two endashes, they define a \cyrdash
macros as follows
\def\cyrdash{\hbox to.8em{--\hss--}}
and map it to a shorthand "---
. So final form of my question is
How to map the ligature ---
to \cyrdash
? Is there any solution except for making the dash -
active character?
fontspec
can hardly know what language is current one. One could make-
active character but this is not good solution.polyglossia
, which knows the language you are using? Just as it was a responsibility ofbabel
in the LaTeX world.