How To Add Pill Glyph in LuaLaTeX

fontsluatexsymbolsunicode

I would like to add the (Matrix) "red pill" glyph into text that I am writing. To make it even more difficult and painful, my document originates in pandoc and becomes beamer, powerpoint, and slidy.

Usually, for a red pill in latex, I would just create a tiny png file that contains a pill image, bind it to a macro, use it repeatedly, and call it a day. Unfortunately, powerpoint does not seem to support inline graphics (only display graphics; can you believe that???), so I need to use a pill glyph.

My confusion starts pretty early now. My macos terminal (and textedit) display the same looking unicode pill no matter what font I select in my terminal. It is pulling a pill (which I don't like much either because of its dual color on macos, but at least it looks like a pill!) from somewhere—beats me from where. I am scrounging around the fontbook app to see if I can find some place for the emoji unicodes like the pill, but they don't seem to be there.

OK, but these are not latex questions. When I try to run the resulting beamer source through lualatex, the log informs me

Missing character: There is no 💊 (U+1F48A) in font Andika:mode=node;script=latn;language=dflt;+tlig;!

Missing character: There is no 💊 (U+1F48A) in font Ubuntu:mode=node;script=l

Ergo,

  • either I need to learn how to instruct beamer to switch briefly to a font that does contain a pill glyph when it sees an U+1F48A request, but I have no clue even how to interrogate my installed fonts which ones of them contain the U+1F48A glyph;

  • or, better, I need to learn how to take the Ubuntu font, insert a glyph that looks like pill surreptitiously, and save it.

(If I could learn how to do the latter, I presume I could use the font in all output formats, including powerpoint and wouldn't have to rely on the macos-type U+1F48A looking double-color pill, though I am not sure how this would look on other operating systems.)

Is it easy or hard to take the ubuntu font and add a pill shape into a slot (ideally, the right slot of U+1F48A) where I can ask LuaLaTeX to use it, too? Are there programs with tutorials that make this easy? I don't need high-quality; just a basic pill.

red pill, blue bill

Advice greatly appreciated.

Best Answer

With a current texsystem you can use albatross to query fonts. Call on a terminal

  albatross U+1F48A

It should give a list of fonts. On my system (windows) it found the followings for your glyph. Some of them can be colored, the technical details can differ here: some need the harfbuzz renderer, others can be colored with lua code. But I have no idea how pandoc and powerpoint handle such fonts.

Extending a font to add a glyph is neither trivial nor it is clear if the license allows it.

\documentclass{article}
\usepackage{fontspec}

\directlua{fonts.handlers.otf.registerpalette("demo", {
        { g = 0  },
        { g = 0  },
        { r = 0  },
        { r = 0, b= 1, g= 1},
    }
    )}

\begin{document}
{\fontspec{Segoe UI Symbol} ^^^^^^01f48a}

{\fontspec{Segoe UI Emoji}^^^^^^01f48a}

{\fontspec{file:seguiemj.ttf:mode=node;colr=yes;}^^^^^^01f48a}

{\fontspec{file:seguiemj.ttf:mode=node;colr=demo;}^^^^^^01f48a}

{\fontspec{EmojiOne Color}^^^^^^01f48a}
                                        
{\fontspec{Noto Color Emoji}[Renderer=Harfbuzz]^^^^^^01f48a}

{\fontspec{Noto Emoji}^^^^^^01f48a}
 
{\fontspec{Twemoji Mozilla}[Renderer=Harfbuzz]^^^^^^01f48a}

\end{document}

enter image description here

Related Question