4

I would like to avoid programmatically what, to my eyes, is a collision between the italic glyphs for "g" followed by "f" with the newtxtext package. Inserting a kern value between the two of them in the document is a no-go because it would make the contents of the source file typeface-dependent.

Please feel free to correct me if you think that I am wrong in the occurrence of the collision. It is slight, but it is there, and I do not think it qualifies as a ligature.

Any suggestions on how to proceed?

Follows an MWE (as trivial as it gets):

\documentclass{memoir}

\usepackage{newtxtext}

\begin{document}
\emph{meaningful}  
\end{document} 
  • 4
    I sent mail to the maintainer of newtx about the issue. He's usually very responsive. – egreg Feb 16 at 0:25
  • Well, that may be the ultimate solution. Thank you very much indeed. – Marcos Feb 16 at 0:30
7

Here's a solution that preserves LaTeX's ability to insert a line break (and a hyphenation symbol) between meaning and ful should LaTeX deem it to be necessary.

The solution inserts a kern of width 0.035em. (If that doesn't produce quite enough glyph separation for you taste, feel free to increase the kern to 0.04em.)

The code includes a test whether the newtxtext package is loaded; if that's not the case, the macro \meaningful does not insert a kern, i.e., it just outputs the string "meaningful".

enter image description here

\documentclass{memoir}
\usepackage{newtxtext}
\newcommand\gfkern{\discretionary{g-}{f}{g\kern0.035emf}}

\makeatletter
\AtBeginDocument{\@ifpackageloaded{newtxtext}{%
     \newcommand{\meaningful}{meanin\gfkern ul}}{%
     \newcommand{\meaningful}{meaningful}}}
\makeatother

\begin{document}

\emph{meaningful} -- unadjusted

\emph{\meaningful} -- adjusted

\emph{meanin\discretionary{g-}{f}{g\kern0.035emf}ul} -- brute force

\end{document} 


Addendum, meant to address some broader issues related to the apparent "entanglement" of, or "collision" between, the italic-shaped g and f glyphs.

Let's start by investigating how much extra kerning is needed to avoid the glyph entanglement for four separate fonts: Times Roman -- the text font used by the newtxtext package is based on a clone of Times Roman -- as well as Times New Roman, EB Garamond, and Latin Modern Roman. In the following table, the font sizes have been adjusted to that x-sizes of all four fonts are the same.

enter image description here

As is readily apparent, the italic versions of Times New Roman and especially EB Garamond require far more kerning (0.08em and 0.13em, respectively) than Times Roman does (0.035em) in order to keep the g and f glyphs from touching/colliding/getting entangled. On the other hand, Latin Modern needs no kerning adjustment at all. Observe, moreover, that introducing 0.08em and especially 0.13em of extra kern manages to create a visual void between "meaning" and "ful" -- not good!

My simple advice would be to learn to appreciate the font designers' work when it comes to the side-by-side placement of the g and f glyphs, and hence not to bother with any kerning adjustments. De facto, the entanglement of the g and f glyphs has created a composite or ligated glyph. Now, ligatures should be suppressed if their presence risks misleading the reader. (For sure, that's the basis of the work of the selnolig package.) In the case of the word "meaningful", however, there's got to be zero chance that any reader might be confused, slowed down, or otherwise inconvenienced by the presence of a gf "ligature" in the italic version of the word "meaningful". Hence, no (typographic) purpose is served by suppressing this de-facto ligature.

Last but not least, here's the code for the preceding table.

\documentclass{article}
\usepackage{fontspec,booktabs}
\newcommand\gfkern[1]{\discretionary{g-}{f}{g\kern#1emf}}
\newcommand{\ingful}[1][0.035]{in\gfkern{#1}ul}

\newlength\mylena
\newlength\mylenb
\setmainfont{Times}[ItalicFont=Times Italic]
\settowidth\mylena{Times New Roman}
\settowidth\mylenb{\textit{meaningful}\ \ \ }
\begin{document}

\noindent
\begin{tabular}{@{}p{\mylena}p{\mylenb}p{\mylenb}l@{}}
Font & Unadjusted & Adjusted & Required kern \\
\midrule
Times Roman &\textit{meaningful} & \textit{mean\ingful} &  0.035em \\
\end{tabular}

\setmainfont{Times New Roman}[ItalicFont=Times New Roman Italic,Scale=MatchLowercase]
\noindent
\begin{tabular}{@{}p{\mylena}p{\mylenb}p{\mylenb}l@{}}
Times New Roman &\textit{meaningful} & \textit{mean\ingful[0.08]} &  0.08em \\
\end{tabular}

\setmainfont{EB Garamond}[Numbers=Lining,Scale=MatchLowercase]
\noindent
\begin{tabular}{@{}p{\mylena}p{\mylenb}p{\mylenb}l@{}}
EB Garamond & \textit{meaningful} & \textit{mean\ingful[0.13]} & 0.13em\\
\end{tabular}

\setmainfont{Latin Modern Roman}[Scale=MatchLowercase]
\noindent
\begin{tabular}{@{}p{\mylena}p{\mylenb}p{\mylenb}l@{}}
Latin Modern Roman & \textit{meaningful} & \textit{mean\ingful[0]} & 0.00em\\
\end{tabular}

\end{document}
  • Your approach is the one I took in my document before asking the question. It certainly solves the issue, but I would rather act somehow where it is suitable on the newtxttext package so as to avoid having to tweak a "regular" word in the source file. – Marcos Feb 15 at 23:35
  • 1
    @Marcos - Just out of curiosity: Do you have any other cases of g-f glyph collisions in your source file? – Mico Feb 15 at 23:42
  • 1
    @Mico My most sincere and heartfelt compliments for your ability. – Sebastiano Feb 15 at 23:49
  • 1
    @Marcos - I've added a test to the code, so that the macro \meaningful inserts a kern only if the newtxtext package is loaded. Thus, it should be safe to replace all instances of the word meaningful that occur in text-italic mode with \meaningful. – Mico Feb 15 at 23:51
  • 1
    @Mico: It is the only occurrence. I do appreciate your effort, which I will validate as the answer if there is no sensible way to act directly on the package contents. The latter would be my first choice. – Marcos Feb 16 at 0:00

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.