4

I assume mine is a general problem with remapping, but what I want to do is to use, with Linux Libertine (and XeLaTeX), the round (ligature ss) form of German sharp s (E04C) instead of the standard form (00DF).

I thought this could be done by adding

U+00DF <> U+E04C

to my tex-text.map.

This does not seem to work however. Compiling

\documentclass{minimal}
\usepackage{xltxtra}
\setmainfont[Mapping=tex-text]{Linux Libertine O}
\begin{document}
Lessingstraße
\end{document}

with XeLaTeX still gives me 00DF in ``Lessingstra_ß_e''.

Can someone please tell me what I am missing here?

Thanks in advance,

Rainer

  • Welcome to TeX.SE! Would you be open to using LuaLaTeX instead of XeLaTeX? If so, you could use an OpenType feature file to perform the substitution from ß (00DF) to ß (E04C). – Mico Mar 28 '15 at 13:04
  • 1
    How exactly did you add the mapping? Did you call teckit afterwards? See http://tex.stackexchange.com/questions/230118/ligatures-for-fi-fl-ffl-do-not-work-for-times-new-roman-xelatex/230140#230140 – Ulrike Fischer Mar 28 '15 at 16:50
  • @Mico: XeLaTeX supports OpenType as well. The problem is that there is no OpenType feature for this glyph for some reason – except for access all alternates, which is not natively supported by Fontspec, as far as I know. – Wrzlprmft Jul 14 '15 at 07:59

3 Answers3

3

If using LuaLaTeX is an option for you, you could achieve your objective by (a) defining a Lua function that replaces all instances of ß with \char"E04C and (b) adding this function to the process_input_buffer callback. As its name indicates, this callback processes the input buffer before TeX does any processing.

enter image description here

\documentclass{article}
\usepackage{fontspec,luatextra}
\setmainfont{Linux Libertine O}

\begin{luacode}
function replace_eszett( line )
    return string.gsub( line, 'ß', '\\char"E04C ' )
end
luatexbase.add_to_callback( "process_input_buffer",  
    replace_eszett, "replace_eszett" )
\end{luacode}

\begin{document}
Lessingstraße \emph{Lessingstraße}
\end{document}

For completeness, here's what the output of the preceding example looks like without the lua-based code:

enter image description here

Mico
  • 506,678
  • I know this is not a tex question, but I would be curious to know what the problem with one or the other is and where and when it would be preferable to use the former or the latter. I see that they are different, but is there any reason why one should be "right" and the other one "wrong"? – Andyc Aug 22 '21 at 16:15
3

I managed to do achieve the desired output as follows using newunicodechar:

\documentclass{minimal}
\usepackage{xltxtra, newunicodechar}
\setmainfont[Mapping=tex-text]{Linux Libertine O}
\newunicodechar{ß}{^^^^e04c}
\begin{document}
Lessingstraße
\end{document}

In the fourth line, you can also use \newunicodechar{ß}{}, where the second argument is the Unicode character U+E04C.

Finally, you can use the way described in this answer to directly access a font’s glyphs:

\newunicodechar{ß}{\XeTeXglyph\the\XeTeXglyphindex "germandbls.alt"\relax}

This way, you do not not employ Unicode’s Private-Use Area at any point, which makes the mapping more robust to changes to the font’s encoding, also works for characters that are not assinged to a Unicode code point in the first place and also works with other fonts using the same naming convention.

Wrzlprmft
  • 759
  • Maybe you prefer \newunicodechar{ß}{^^^^e04c} that's more readable. Avoid loading xltxtra, just fontspec is needed. – egreg Jul 14 '15 at 10:05
  • 1
    @egreg: Thanks for the hint. I used xltxtra, because the question used it and it does not matter for this purpose. – Wrzlprmft Jul 14 '15 at 10:23
1

Solved: I needed to compile the relevant .map-file:

teckit_compile tex-text.map -o tex-text.tec

  • 12
    I think it's a bad idea to modify a standard mapping file; create a new one, with a different name. – egreg Mar 28 '15 at 17:13