The most common way to emphasise in German (and probably other) blackletter typesetting was to use letter-spacing (Sperrsatz in German). I am attempting to implement a way to effectively redefine the \emph
command in such a way that it uses letter-spacing in specific contexts. For more information, read the background below.
The problem
Currently, I am implementing letter-spacing emphasis by using an appropriately constructed ItalicFont
:
\setmainfont[Mapping=tex-text,
CharacterVariant=81, CharacterVariant=13, HyphenChar="2010, % Needed for reasons.
ItalicFont = UnifrakturMaguntia,
ItalicFeatures={LetterSpace=20.0, Kerning=Off,
Ligatures=NoCommon, WordSpace=1.2}]
{UnifrakturMaguntia}
This beautifully is able to distinguish between a blackletter or an antiqua font being used and correctly emphasises blackletter with letter-spacing and antiqua (in all occurrances) as italics. The main issue I have is that letter-spacing as defined here introduces additional spacing only after the characters. This means, the interword-space preceeding the \emph{emphasised text}
command is too small, making it look like the emphasised part is connected to the previous word (see example image).
As a workaround, I have redefined \emph
(see code below) to include \xspace
. \xspace
usually does a good job of adding additional glue if the emphasised word does not start a new line. However, I am running into obvious issues in edge cases. A few of them I have chosen to manually work around by \unskip
for the time being but I do not like that solution.
\DeclareTextFontCommand{\emph}{\xspace\em}
The question
Is there an elegant way to add additional space before an emphasised word that does not cause additional space to be added before every occurance of \emph
as in the MWE below?
Glue should be added only if the current environment is blackletter and if the word is not the first word of a line (including the beginning of a paragraph).
The MWE (including test cases)
\documentclass{article}
\usepackage{fontspec}
\usepackage{polyglossia}
\usepackage{xspace}
\setmainlanguage[babelshorthands=true,
spelling=new,
script=fraktur]
{german}
\setotherlanguage[variant=british]{english}
\setmainfont[Mapping=tex-text,
ItalicFont=UnifrakturMaguntia,
ItalicFeatures={LetterSpace=20.0,
Kerning=Off,
Ligatures=NoCommon,
WordSpace=1.2}]
{UnifrakturMaguntia}
\newfontfamily\englishfont[Mapping=tex-text]{LiberationSerif}
\newfontfamily\antiquafont[Mapping=tex-text]{LiberationSerif}
\newcommand\antiqua[1]{{\antiquafont #1}}
\newcommand\antiquaemph[1]{{\antiquafont\textit{#1}}}
\DeclareTextFontCommand{\emph}{\xspace\em}
\begin{document}
\section{Teſting}
\emph{Sperrſatz} am Beginn und \emph{in der Mitte} einer Zeile.
Mehr Zeichen, damit man den Zeilenumbruch ſieht.
\begin{english}
\section{\antiqua{Testing}}
\emph{Emphasis} at the beginning and \emph{in the middle} of a line.
More text so the line break can be seen. The \antiquaemph{custom command}
does not cause problems.
\end{english}
\end{document}
(Naturally, any two sufficiently different fonts can be used here. For reference, my blackletter font is UnifrakturMaguntia which is free and can be downloaded from its sourceforge page.)
(For simplicity, I have not included the sophisticated \antiqua
switch mentioned below. Instead, I have just defined a simple \antiqua
command which is sufficient for this MWE.)
Background
I have a (long) XeTeX document that I wish to be able to typeset in either blackletter or antiqua depending on a true/false switch. I have already written quite a few \emph
s (depending on whether something should change to blackletter or not) and a few \antiquaemph
s (if it should never). This German document when set in blackletter, switches to antiqua typefaces for foreign languages (implemented by polyglossia
’s \englishfont
and variants) and for foreign loanwords (implemented as shown here).
\usepackage{etoolbox}
and\preto\emph{\ifhmode\hspace*{<length>}\fi}
work? Then you could wrap it in a boolean switch for what kind of font you're using. Of course, I'm not really sure what kind of edge cases you are stuck withsoul
package has a letterspacing macro\so
. I haven't used to know if it fulfills all your requirements, but I'd bet it is worth the try. If it does, it'd be easy to redefine\emph
to do\so
's job.\so
's implementation. The parameters used by it are stated in the form\sodef{font}{inter-letter space}{inner space}{outer space}
.microtype
and its letterspacing commands (such as\textls
). But you still need to wrap\emph
somehow if you want it to distinguish between blackletter fonts (or environments) and other situations.