# Automatically apply a kern rule for all characters that follow a specific character

I am writing some text using the \calligra font and there are some specific instances where I want to manually reduce the kerning between letters.

See the MWE below. I have reduced the kerning between the N and a letters using \kern-0.2em.

\documentclass{article}
\usepackage{calligra}
\usepackage[T1]{fontenc}
\begin{document}
\calligra
Insert Name\vspace{.2cm}

Insert N\kern-0.2em ame
\end{document}


Is there a way to make this automatic? So I don't have to type \kern after every N?

I have seen this question which shows automatic kerning rules can be done using a macro defined in the preamble. But, this case was for one specific combination of characters. I want to make it general for every character that follows an N. I am not sure how to do this.

To complement Phelype's answer: if you are using pdftex, you may achieve the same result by adding the following lines to the preamble:

\usepackage[kerning=true]{microtype}
\DeclareMicrotypeSet*[kerning]{calligra}{encoding = T1, family = calligra}
\SetExtraKerning{encoding = T1, family = calligra}{N = {,-200}}


If you can use XeTeX, then you can use \XeTeXinterchartoks (idea by ShreevatsaR).

First you create a "character class" for the letter N (and for any other you wish):

\newXeTeXintercharclass \mycharclassN
\XeTeXcharclass \N \mycharclassN


then you say that XeTeX is supposed to insert \kern-0.2em between N and any other character (class 0):

\XeTeXinterchartoks \mycharclassN 0 = {\kern-0.2em}


then you only need to activate the inter-character tokens with:

\XeTeXinterchartokenstate = 1


\documentclass{article}
\usepackage{calligra}
\usepackage[T1]{fontenc}

\newXeTeXintercharclass \mycharclassN
\XeTeXcharclass \N \mycharclassN

\XeTeXinterchartoks \mycharclassN 0 = {\kern-0.2em}

\begin{document}
\calligra

\parskip=0.2cm

Insert Name

Insert N\kern-0.2em ame

\XeTeXinterchartokenstate = 1

Insert Name

Na Nb Nc Nd Ne Nf Ng

Nh Ni Nj Nk Nl Nm

Nn No Np Nq Nr Ns Nt

Nu Nv Nw Nx Ny Nz

\end{document}