16

I was looking for a new font for the manuals of my LaTeX packages and found the Linux Libertine most pleasing. However it seems that it doesn't support italic correction (yet).

I assume that a font normally defines the correct italic correction for every character, but I would settle if any extra amount would be added after italic text. At the moment a text used in \meta{...} hits the closing angle symbol because of the missing italic correction:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{libertine}
\begin{document}
(\textit{X})

\def\metastyle{\textit}
\def\meta#1{{\metastyle {\ensuremath \langle #1\/\ensuremath \rangle }}}
\meta{X}
\end{document}

I had the idea of the very quick and very dirty trick \let\/\, which works in this case, but not for general \textit{...} uses. (\/ is for explicit italic correction and \, adds a small space, IIRC half a normal space)

Checking the definition of \textit revealed that it finally uses \@@italiccorr which is let to the original \/ primitive. Defining this macro as well to \, seems to add the small space also on other places where it is not wanted.

Is there a better way to get some decent italic correction for this font? It doesn't have to be perfect, just better then the current one (i.e. literally "better than nothing").

Martin Scharrer
  • 262,582
  • Can you please give an example of a case where "defining this macro as well to \, seems to add the small space also on other places where it is not wanted"? – Hendrik Vogt Mar 14 '11 at 15:16
  • @Hendrik: I researched this now and apparently \@@italiccorr is placed before and after every \textXX macro, so redefining it to a fixed space is not good. – Martin Scharrer Mar 14 '11 at 18:30
  • @Martin: And what about redefining \/? – Hendrik Vogt Mar 14 '11 at 18:39
  • @Hendrik: This works only when \/ is used explicitly. The problem is that \/ is a primitive and \@@italiccorr is \let to it, so changing it afterwards doesn't affect it. – Martin Scharrer Mar 14 '11 at 18:46
  • @Hendrik: Checking on \/ again revealed that it produces a zero kerning in non-italic fonts (because the italic correction in them is 0) and is therefore save to be used before and after the normal \textXX macros. A manual redefinition doesn't know if italic correction should be applied or not :-( – Martin Scharrer Mar 14 '11 at 19:12
  • 3
    In pdfTeX you can't change the italic correction after a font is loaded. Probably you need to create a virtual font or switch to LuaTeX. – Philipp Mar 14 '11 at 22:09
  • 1
    Further to what Philipp says, I understand that in Luatex you can dynamically change the italic correction of each character in a font using the structure described in chapter 7 of the Luatex manual. @Philipp: maybe you'd like to post your comment as an answer? Maybe with a pointer on how to construct virtual fonts: I have no idea on how to do this. – Charles Stewart Mar 15 '11 at 08:11

1 Answers1

8

You can try it with hacking into LaTeX's \check@nocorr@. Remove the left correction and \let the italic correction to \, (or another suitable amount). This may have issues, but for your code it works. I have assumed that you use Linux Libertine throughout your document; otherwise you'll have to make the hack local.

Before:        After: 

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{libertine}
\makeatletter
\def \check@nocorr@ #1#2\nocorr#3\@nil {%
  \let \check@icl \@empty                    %%% removed left correction
  \def \check@icr {\ifvmode \else \aftergroup \maybe@ic \fi}%
  \def \reserved@a {\nocorr}%
  \def \reserved@b {#1}%
  \def \reserved@c {#3}%
  \ifx \reserved@a \reserved@b
    \ifx \reserved@c \@empty
      \let \check@icl \@empty
    \else
      \let \check@icl \@empty
      \let \check@icr \@empty
    \fi
  \else
    \ifx \reserved@c \@empty
    \else
      \let \check@icr \@empty
    \fi
  \fi
}
\let\/\,
\let\@@italiccorr\/
\makeatother
\begin{document}
(\textit{X})

\def\metastyle{\textit}
\def\meta#1{{\metastyle {\ensuremath \langle #1\/\ensuremath \rangle }}}
\meta{X}
\end{document}
Hendrik Vogt
  • 37,935