2

In a (OTF) font I'm using with xetex, loaded with the mapping=tex-text option, I found that the em-dash character is too thin, so I would like to replace it with a heavier one. For example, suppose I want to replace it with an \hrule (or, equivalently, a \vrule). What should I do? How are characters mapped to ligature combinations?

4
  • 1
    Which opentype font do you use -- some have more than one glyph to represent an em-dash. Separately, are you constrained to use XeTeX, or might a Lua(La)TeX-based solution be of interest to you?
    – Mico
    Nov 20, 2015 at 7:58
  • 1
    Even if that sounds patronizing: Don't! If it is a well designed font, there is usually a good reason for things to look like they do. If it isn't well designed and you still think it looks bad: Could you use another font?
    – Florian
    Nov 20, 2015 at 10:44
  • If you have to: Modifying the font itself is probably the easiest. Alternatively: Just search-replace the --- in the tex-file by a convenient macro.
    – Florian
    Nov 20, 2015 at 10:50
  • @Mico. I am using Monotype Baskerville. How can I check if there are other em-dash symbols in the font? And, eventually, how can I use them? I am constrained to use xetex, but a luatex solution could be of interest to someone else or as a future reference for me.
    – User
    Nov 20, 2015 at 12:31

2 Answers 2

5

XeTeX can use the powerful method of mapping files.

Locate on your TeX system the file tex-text.map and copy it into the working directory as baskerville-dash.map.

Open the file with a text editor and modify it to look like

; TECkit mapping for TeX input conventions <-> Unicode characters

LHSName "baskerville-dash"
RHSName "UNICODE"

pass(Unicode)

; ligatures from Knuth's original CMR fonts
U+002D U+002D           <>      U+2013  ; -- -> en dash
U+002D U+002D U+002D    <>      U+2015  ; --- -> horizontal bar (was U+2014)
U+2014                  <>      U+2015  ; em dash -> horizontal bar

U+0027                  <>      U+2019  ; ' -> right single quote
U+0027 U+0027           <>      U+201D  ; '' -> right double quote
U+0022                   >      U+201D  ; " -> right double quote

U+0060                  <>      U+2018  ; ` -> left single quote
U+0060 U+0060           <>      U+201C  ; `` -> left double quote

U+0021 U+0060           <>      U+00A1  ; !` -> inverted exclam
U+003F U+0060           <>      U+00BF  ; ?` -> inverted question

; additions supported in T1 encoding
U+002C U+002C           <>      U+201E  ; ,, -> DOUBLE LOW-9 QUOTATION MARK
U+003C U+003C           <>      U+00AB  ; << -> LEFT POINTING GUILLEMET
U+003E U+003E           <>      U+00BB  ; >> -> RIGHT POINTING GUILLEMET

Save the file and run

teckit_compile baskerville-dash

that should produce a file baskerfille-dash.tec.

Now test the new mapping file:

\documentclass{article}

\usepackage{fontspec}

\setmainfont[Mapping=baskerville-dash]{Baskerville}

\begin{document}

a---b—c

\end{document}

Between b and c in the input file there's U+2014 (em dash).

enter image description here

Here's the output with the default tex-text mapping

enter image description here

Now keep the baskerville-dash file along with the TeX source, or place it in some place that XeTeX will look in for files, presumably

mkdir -p $(kpsewhich -var-value TEXMFHOME)/fonts/misc/xetex/fontmapping/baskerville-dash
mv baskerville-dash.* $(kpsewhich -var-value TEXMFHOME)/fonts/misc/xetex/fontmapping/baskerville-dash

or a similar trick for other operating systems.

Run XeLaTeX on the test file again for being sure all went well.

4
  • How can other ligatures like ff, fi, ffl be typeset correctly if they don't appear in the .map file? How does XeTeX know about them?
    – User
    Dec 28, 2015 at 23:45
  • @User That happens at a different level: the font knows those ligatures.
    – egreg
    Dec 28, 2015 at 23:47
  • I managed to add another ligature for gy by creating a new character in the font and by adding a line in the map file which replaces the combination of g and y by the ligature gy. This works. But, what should I have done instead for making the font know about the ligature and so for not needing to modify the .map file?
    – User
    Dec 28, 2015 at 23:52
  • @User You have to modify the font tables (with fontforge)
    – egreg
    Dec 28, 2015 at 23:56
4

Since you're using the "Monotype Baskerville" font, you actually have a choice of two weights for the em-dash symbol: \char"0214 (the default) and \char"0215. The former glyph is indeed extremely thin; the latter is a lot thicker, and it may even be too thick for your taste. Your call.

If you like the latter form, you could set up a macro via an instruction such as

    \newcommand\thickemdash{\char"0215}

so that you don't have to remember the Unicode character slot of the glyph.

The following MWE runs on my system (MacOSX 10.11.1., MacTeX2015) under both XeLaTeX and LuaLaTeX.

enter image description here

% !TEX TS-program = xelatex
\documentclass{article}

\usepackage{fontspec}
\setmainfont{Baskerville} % Monotype Baskerville

\begin{document}

a---a a\char"2014a a\char"2015a

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .