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?
2 Answers
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).
Here's the output with the default tex-text
mapping
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.
-
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?– UserDec 28, 2015 at 23:45 -
@User That happens at a different level: the font knows those ligatures.– egregDec 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 ofg
andy
by the ligaturegy
. 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?– UserDec 28, 2015 at 23:52 -
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.
% !TEX TS-program = xelatex
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Baskerville} % Monotype Baskerville
\begin{document}
a---a a\char"2014a a\char"2015a
\end{document}
---
in the tex-file by a convenient macro.