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.

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?

share|improve this question
    
I guess that this is not doable. fontspec can hardly know what language is current one. One could make - active character but this is not good solution. –  Igor Kotelnikov Jan 14 '13 at 14:49
    
It seems to me this could be done using XeTeX mapping files and LuaTeX OTF feature files. See e.g. Serbian Cyrillic using LuaTeX and XeTeX. –  Alan Munn Feb 26 '13 at 15:55
    
Shouldn't this be the responsibility of a package such as polyglossia, which knows the language you are using? Just as it was a responsibility of babel in the LaTeX world. –  nplatis Mar 17 '13 at 9:24

1 Answer 1

As nplatis pointed out, this is actually in the responsibility of polyglossia, which works for me, but is more or less font-dependent, as polyglossia just uses two “-” U+002D HYPHEN-MINUS and overlaps them, as can be inferred from the PT Sans example, where it does not work:

Russian em-dash example (XeLaTeX)

The key to getting this to work is to add the babelshorthands=true to the language selection, so the code to create the above image is as follows:

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
\documentclass{article}

\usepackage{polyglossia}
\setmainfont{PT Sans}
\setsansfont{PT Sans Caption}
\defaultfontfeatures{Scale=MatchLowercase, Mapping=tex-text}
\setdefaultlanguage[spelling=modern,babelshorthands=true]{russian}
\setotherlanguage{english}

\newfontfamily{\HT}[Scale=MatchLowercase]{Hoefler Text}
\newfontfamily{\GPP}{Garamond Premier Pro}
\newfontfamily{\BV}{Baskerville}
\newfontfamily{\CCY}{Charcoal CY}

\newcommand{\text}{Слово "--- слово.\\Слово — слово.\par}
%1. babelshorthand/2. U+2014 EM DASH

\begin{document}
PT Sans\\
\text
{\HT Hoefler Text\\
\text}
{\GPP Garamond Premier Pro\\
\text}
{\BV Baskerville\\
\text}
{\CCY Charcoal CY\\
\text}

\end{document}

For further information, see also this thread in the XeTeX mailing list. Also, babel apparently distinguishes several em-dashes for Russian:
"--- Cyrillic emdash in plain text.
"--~ Cyrillic emdash in compound names (surnames).
"--* Cyrillic emdash for denoting direct speech.
See here for more information.


On a side note, I have not succeeded in getting the shorter em-dash in regular LaTeX, just the narrower spacing, strangely enough:

Russian em-dash example (LaTeX)

Code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}

\begin{document}
\selectlanguage{russian}
\noindent
Слово "--- слово.\\
Слово --- слово.\\
Слово — слово.\par% U+2014 EM DASH
\end{document}
share|improve this answer
    
I accepted this anwser altough this is not what I had in mind. I see that it is impossible to map --- to a code point with a short em-dash (by the way, I did not find short em-dash in Open Type fonts). Also, \defaultfontfeatures{Scale=MatchLowercase, Mapping=tex-text} did not work for me until I added Ligatures={TeX} option. –  Igor Kotelnikov Apr 6 '13 at 5:47
    
I suppose one would have to resort to a somewhat “hacky” solution, yet this is what polyglossia already does. Of course, you could write your own macro with own kerning etc., but I am no expert on this. I have actually not found any code point in Unicode for the shorter em-dash, so I would guess the shorter em-dash—if at all present in a given font—would reside within the Private Use Area (PUA), so additionally, this would become very font-dependent. I really wonder how contemporary Russian typesetters solve this or if they just use the normal em-dash. –  brian-ammon Apr 10 '13 at 11:28
    
Both polyglossia and babel with russian option compose a shorter em-dash from two emdash as follows: \def\cyrdash{\hbox to.8em{--\hss--}}. My question in updated form is how to map the ligature --- to \cyrdash. –  Igor Kotelnikov Apr 11 '13 at 3:11
2  
I disagree. This should mainly be a responsibility of the fonts. When the font is used in a Russian context the dash should be shorter, if this is the usage. –  egreg Apr 11 '13 at 9:22
    
@egreg I completely agree with you, yet as I have not found any instances of fonts with such capabilities, one has to find a different way to get the expected output or create one’s own font—right now I can only think of the already present \cyrdash or some scaling of the regular em-dash. This is definitely something font-creators should take a look at, but this is the first time I ever hear of this phenomenon; even in the Russian Wiki article I could not find any remark towards the reduced-length em-dash, so I reckon it is difficult for typographers to know this if they are not Russian. –  brian-ammon Apr 11 '13 at 20:48

Your Answer

 
discard

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.