Possible to dot your Is with hearts?

https://tex.stackexchange.com/questions/716175/possible-to-dot-your-is-with-hearts

Why not also j?

\documentclass{article}
\usepackage{amsmath}
\usepackage{l3draw}
\makeatletter
\NewDocumentCommand{\iheart}{}{\mathord{\mathpalette\iheart@{\imath{7}{1}}}}
\NewDocumentCommand{\jheart}{}{\mathord{\mathpalette\iheart@{\jmath{12}{2}}}}
\newcommand{\iheart@}[2]{\iheart@@#1#2}
\newcommand{\iheart@@}[4]{%
  \vbox{\m@th\offinterlineskip
    \sbox\z@{$\mkern1mu$}%
    \ialign{##\cr\hidewidth\smallheart@{#1}{#3}\hidewidth\cr\noalign{\kern\wd\z@}\cr$#1#2$\cr}%
  }%
  \mkern#4mu
}
\ExplSyntaxOn
\cs_new_protected:Npn \smallheart@ #1 #2
 {
  \draw_begin:
  \draw_transform_matrix_absolute:nnnn { 0.4 } { 0 } { 0.2 } { 0.3 }
  \draw_path_moveto:n { 0cm, 0cm }
  \hbox_set:Nn \l_tmpa_box { \boldmath$#1\mkern#2mu\heartsuit$ }
  \draw_box_use:N \l_tmpa_box
  \draw_end:
 }
\ExplSyntaxOff
\makeatother
\begin{document}
$2\pi\iheart_{\jheart}+\jheart$
\end{document}

enter image description here

How do the macros work? First off, some mathpalette trickery to have four arguments:

  1. the current math style, as usual
  2. the letter to be typeset, so either \imath and \jmath
  3. the (math) kern in front of the heart
  4. the math kern after the combination, to compense for the protrusion of the heart which is not taken into account because of \hidewidth

I make a \vbox with \ialign inside it that oversets the heart to the letter.

Finally, the heart is a bold \heartsuit in the suitable math style subject to an affine transformation that applies reduction and shearing.

Maybe some more experiments are needed for the various parameters.

{
"by": "jjgreen",
"descendants": 10,
"id": 40221035,
"kids": [
40238048,
40240259,
40243485,
40234988
],
"score": 88,
"time": 1714554444,
"title": "Possible to dot your Is with hearts?",
"type": "story",
"url": "https://tex.stackexchange.com/questions/716175/possible-to-dot-your-is-with-hearts"
}
{
"author": "Infimum",
"date": "2024-04-22T08:13:35.000Z",
"description": "I was wondering if it is possible to replace just the mathmode i from the default latex font with nearly the same letter, but where the dot on the i is a small heart. For example: Thank you!",
"image": "https://cdn.sstatic.net/Sites/tex/Img/[email protected]?v=eaf26b461720",
"logo": "https://logo.clearbit.com/stackexchange.com",
"publisher": "Stack Exchange",
"title": "Possible to dot your Is with hearts?",
"url": "https://tex.stackexchange.com/questions/716175/possible-to-dot-your-is-with-hearts"
}
{
"url": "https://tex.stackexchange.com/questions/716175/possible-to-dot-your-is-with-hearts",
"title": "Possible to dot your Is with hearts?",
"description": "I was wondering if it is possible to replace just the mathmode i from the default latex font with nearly the same letter, but where the dot on the i is a small heart. For example:\n\nThank you!",
"links": [
"https://tex.stackexchange.com/questions/716175/possible-to-dot-your-is-with-hearts"
],
"image": "https://cdn.sstatic.net/Sites/tex/Img/[email protected]?v=eaf26b461720",
"content": "<div>\n<p>Why not also j?</p>\n<pre><code>\\documentclass{article}\n\\usepackage{amsmath}\n\\usepackage{l3draw}\n\\makeatletter\n\\NewDocumentCommand{\\iheart}{}{\\mathord{\\mathpalette\\iheart@{\\imath{7}{1}}}}\n\\NewDocumentCommand{\\jheart}{}{\\mathord{\\mathpalette\\iheart@{\\jmath{12}{2}}}}\n\\newcommand{\\iheart@}[2]{\\iheart@@#1#2}\n\\newcommand{\\iheart@@}[4]{%\n \\vbox{\\m@th\\offinterlineskip\n \\sbox\\z@{$\\mkern1mu$}%\n \\ialign{##\\cr\\hidewidth\\smallheart@{#1}{#3}\\hidewidth\\cr\\noalign{\\kern\\wd\\z@}\\cr$#1#2$\\cr}%\n }%\n \\mkern#4mu\n}\n\\ExplSyntaxOn\n\\cs_new_protected:Npn \\smallheart@ #1 #2\n {\n \\draw_begin:\n \\draw_transform_matrix_absolute:nnnn { 0.4 } { 0 } { 0.2 } { 0.3 }\n \\draw_path_moveto:n { 0cm, 0cm }\n \\hbox_set:Nn \\l_tmpa_box { \\boldmath$#1\\mkern#2mu\\heartsuit$ }\n \\draw_box_use:N \\l_tmpa_box\n \\draw_end:\n }\n\\ExplSyntaxOff\n\\makeatother\n\\begin{document}\n$2\\pi\\iheart_{\\jheart}+\\jheart$\n\\end{document}\n</code></pre>\n<p><a target=\"_blank\" href=\"https://i.sstatic.net/wiBLQLoY.png\"><img src=\"https://i.sstatic.net/wiBLQLoY.png\" alt=\"enter image description here\" /></a></p>\n<p>How do the macros work? First off, some mathpalette trickery to have four arguments:</p>\n<ol>\n<li>the current math style, as usual</li>\n<li>the letter to be typeset, so either <code>\\imath</code> and <code>\\jmath</code></li>\n<li>the (math) kern in front of the heart</li>\n<li>the math kern after the combination, to compense for the protrusion of the heart which is not taken into account because of <code>\\hidewidth</code></li>\n</ol>\n<p>I make a <code>\\vbox</code> with <code>\\ialign</code> inside it that oversets the heart to the letter.</p>\n<p>Finally, the heart is a bold <code>\\heartsuit</code> in the suitable math style subject to an affine transformation that applies reduction and shearing.</p>\n<p>Maybe some more experiments are needed for the various parameters.</p>\n </div>",
"author": "",
"favicon": "https://cdn.sstatic.net/Sites/tex/Img/favicon.ico?v=91427af8e60a",
"source": "tex.stackexchange.com",
"published": "",
"ttr": 33,
"type": "website"
}