6

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).

Example text showing too small an interword space at the beginning of letter-spaced text.

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 \emphs (depending on whether something should change to blackletter or not) and a few \antiquaemphs (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).

  • Does \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 with – jon Jun 2 '17 at 2:57
  • The soul 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. – gusbrs Jun 2 '17 at 15:46
  • Indeed, your issues seem to be considered by \so's implementation. The parameters used by it are stated in the form \sodef{font}{inter-letter space}{inner space}{outer space}. – gusbrs Jun 2 '17 at 15:49
  • 2
    @gusbrs -- Or, indeed, use 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. – jon Jun 2 '17 at 17:08
1

My earlier comment had this in mind:

\documentclass{article}
\usepackage[showframe]{geometry}\parindent0pt % just for this example
\usepackage{fontspec}
\usepackage{polyglossia}
\usepackage{xspace}

\setmainlanguage[babelshorthands=true,
                 spelling=new,
                 script=fraktur]
                 {german}
\setotherlanguage[variant=british]{english}
\setmainfont[Mapping=tex-text,
%             ItalicFont=LinBiolinumOI,
             ItalicFont=UnifrakturMaguntia,
             ItalicFeatures={LetterSpace=20.0,
                             Kerning=Off,
                             Ligatures=NoCommon,
                             WordSpace=1.2}]
%             {Linux Biolinum O}
             {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}
\newif\ifblackletter
\blacklettertrue

% \preto comes from the etoolbox package, which is loaded by polyglossia
\preto\emph{%
  \ifblackletter
    \ifhmode\kern1pt % how big of a 'space' do you want to add?
    \fi\fi}

\AtBeginEnvironment{english}{\blackletterfalse}


\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}

blackletter emphasis example

  • This looks very promising! Coincidentally, a corresponding \ifblackletter already exists in my document. I’ll do some testing probably tomorrow to see how it works out. Sorry for ‘disappearing’ after asking; a few other issues had popped up so I didn’t have time to come back here. – Jan Jun 6 '17 at 21:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.