3

At Playing Cards (Unicode block) I found


enter image description here


The Chrome Browser says this should be the font TwemojiMozilla.ttf.

This font, I can find in my TeXLive under c:/texlive/2022/texmf-dist/fonts/truetype/public/twemoji-colr/
The font can also be found on CTAN: https://ctan.org/texarchive/fonts/twemoji-colr

Why does the following code not work?

enter image description here

How can I get this colored glyph?

% TeX Program = lualatex
% alternativ:
% arara: lualatex
\documentclass{article}  

\usepackage{fontspec}  

\newfontfamily\myfontA{TwemojiMozilla.ttf}[
Path="c:/texlive/2022/texmf-dist/fonts/truetype/public/twemoji-colr/"
]

\newfontfamily\myfontB{TwemojiMozilla.ttf}

\begin{document}
\section{With Path}
{\myfontA\char"1F0CF ABCDEFG}

\section{Without Path}
{\myfontB\char"1F0CF ABCDEFG}
\end{document}
3
  • 1
    If I remove the Path (as I don't have texlive 2022 the font loads from tl2024 but Missing character: There is no A (U+0041) in font [TwemojiMozilla.ttf]:mode=nod e;script=DFLT;language=dflt;! (and get no playing card in U+1F0CF Commented Apr 30 at 15:36
  • Did you read this: overleaf.com/learn/latex/Articles/… ? Try \newfontfamily\myfontA[Renderer=HarfBuzz]{TwemojiMozilla.ttf}. Commented Apr 30 at 15:38
  • The above link also explains nicely that there are different approaches to colored fonts, two are vector-based (one using the SVG table, one using the COLR/CPAL tables) and two are raster-based (one using the CBDT/CBLC tables, one using the sbix table). How you can access glyphs in these fonts depends on which technique is used. Commented Apr 30 at 16:10

1 Answer 1

4

Since the font is contained in TeXLive, you should be able to load it without path. But as is explained nicely over at Overleaf, you may want to try the Harfbuzz renderer (with LuaLaTeX). Note that the font does not contain the characters for latin letters.

\documentclass{article}
\usepackage{fontspec}  

\newfontfamily\myfontA[Renderer=HarfBuzz]{TwemojiMozilla.ttf}

\begin{document}
{\myfontA\char"1F0CF} ABCDEFG

\bigskip

{\Huge\myfontA\char"1F0CF}
\end{document}

enter image description here

But beware, the above link also explains nicely that there are different approaches to colored fonts, two are vector-based (one using the SVG [actually SVG␣, with a trailing space] table, one using the COLR/CPAL tables) and two are raster-based (one using the CBDT/CBLC tables, one using the sbix table).

How you can access glyphs in these fonts depends on which technique is used. Using the Harfbuzz renderer, you should at least be able to use fonts that make use of the COLR/CPAL and the CBDT/CBLC tables.

For SVG fonts, replace Renderer=Harfbuzz with RawFeature={+svg}.

I am currently unsure how to use fonts that make use of the sbix table as the data stored there may have various formats, but as far as I know Harfbuzz supports PNG data.

3
  • "For SVG fonts, replace..." isn't that a SVG-Font? I can zoom it as much I want.
    – cis
    Commented Apr 30 at 17:36
  • @cis Only because it uses vectors doesn't make it a SVG font. SVG is a special format for vector graphics, but not the only format that exists. I mean with SVG font a font that uses the SVG table. There are also fonts that use the COLR/CPAL tables which are also vector-based color fonts, and TwemojiMozilla is such a font. I added this, because I know you are currently experimenting with SVG color fonts. Commented Apr 30 at 17:52
  • 1
    All right, I asked with ulterior motives. I wanted to clarify this for myself and my project.
    – cis
    Commented Apr 30 at 17:54

You must log in to answer this question.

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