5

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} 
2
  • 4
    I sent mail to the maintainer of newtx about the issue. He's usually very responsive.
    – egreg
    Commented Feb 16, 2019 at 0:25
  • Well, that may be the ultimate solution. Thank you very much indeed.
    – Marcos
    Commented Feb 16, 2019 at 0:30

1 Answer 1

8

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}
7
  • 1
    @Marcos - Just out of curiosity: Do you have any other cases of g-f glyph collisions in your source file?
    – Mico
    Commented Feb 15, 2019 at 23:42
  • 1
    @Mico My most sincere and heartfelt compliments for your ability.
    – Sebastiano
    Commented Feb 15, 2019 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
    Commented Feb 15, 2019 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
    Commented Feb 16, 2019 at 0:00
  • 1
    @Marcos If you compare the ‘gy’ and ‘gj’ ligatures with ‘gf,’ it becomes evident that the kerning of ‘gf’ in EB Garamond is intentional.
    – Thérèse
    Commented Nov 24, 2019 at 23:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .