5

How does one set an emoji font as a fallback in ConTeXt?

MWE is basically, following the contextgarden/simplefonts instructions:

\definefontfamily [main] [serif] [Minion Pro]
\definefallbackfamily[main] [serif] [Noto Emoji] [range=emoticon,force=yes]

Noto Emoji is a free emoticon font from Google, available under SIL at: https://github.com/googlei18n/noto-emoji/tree/master/fonts

The job log reports:

selectfont > The requested fallback font 'Noto Emoji' for typeface 'main' style 'rm' was ignored because no files where found.

The command mtxrun --script font --list noto shows:

notoemoji notoemoji /home/user/fonts/NotoEmoji-Regular.ttf

I've tracked the error down to http://source.contextgarden.net/tex/context/base/mkiv/font-sel.lua in selectfont.definefallbackfamily, but I'm not familiar enough to guess what might be the issue here.

[edit] Incidentally: context --version returns: ConTeXt Process Management 0.63 and current version: 2017.01.27 14:39; it also exhibits on MacTeX with version 2016.10.22 10:43

[edit] There seems to be some difference in the latest ConTeXt standalone, so I suspect there may be issues "on the edge". In any case, here's a full MWE:

% !TEX encoding = UTF-8 Unicode
% !TEX TS-program = ConTeXt (LuaTeX)
\enabletrackers[selectfont.register,selectfont.files,selectfont.alternatives]
\definefontfamily [main] [serif] [Minion Pro]
\definefallbackfamily[main] [serif] [Noto Emoji] [range=emoticon,force=yes]
\setupbodyfont[main]

\starttext
  Hello.  Some valid Noto Emoji:  🙂  ⌛  ⏳  ⌚ 
\stoptext

[edit] Here's a sample of the unicode range included:

\definefallbackfamily[main] [serif] [Noto Emoji] [force=yes,range={emoticons,dingbats,miscellaneoussymbols,ornamentaldingbats,miscellaneousmathematicalsymbolsa,miscellaneousmathematicalsymbolsb,miscellaneoussymbols,miscellaneoussymbolsandarrows,miscellaneoussymbolsandpictographs,miscellaneoustechnical}]

Further ranges can be seen in context/tex/texmf-context/tex/context/base/mkiv/char-ini.lua

2 Answers 2

6

To set a fallback font for \definefontfamily, put all \definefallbackfamily settings before the main font. You must use the correct arguments for the range key. In your case, use miscellaneoussymbols and dingbats (and probably a few more):

\definefallbackfamily [mainface] [serif] [Noto Emoji] [range={miscellaneoussymbols,dingbats}]
\definefontfamily     [mainface] [serif] [Minion Pro]

\setupbodyfont[mainface]

\starttext
Noto Emoji symbols: \utfchar{"26F5} \utfchar{"2712}
\stoptext

Noto Emoji as fallback font for Minion Pro

As another example, to define Gentium Plus as the font fallback family for Greek fonts, you could use:

\definefallbackfamily [mainface] [serif] [Gentium Plus] [range=greekandcoptic]

See \definefontfallback for more details about character ranges.

4
  • Thanks – I noted you used \utfchar; is it possible to embed the UTF characters directly? Mar 6, 2017 at 21:23
  • Yes you can also use the characters itself in your document. Mar 6, 2017 at 21:28
  • Is there a way to set it up so the range parameter is unnecessary? Mar 6, 2017 at 23:55
  • 1
    You need the range setting but you can use a wider range (e.g. range=0x00000-0xFFFFF) without forcing a replacement. Mar 7, 2017 at 11:51
1

try with another naming, like

\definefallbackfamily[main] [serif] [Noto Emoji Regular] [range=emoticon,force=yes]

or this

\definefallbackfamily[main] [serif] [file: NotoEmoji-Regular.ttf] [range=emoticon,force=yes]

EDIT what about this? (even without "regular")

  \definefallbackfamily[main] [serif] [notoemojiregular] [range=emoticon,force=yes]
1
  • I tried notoemoji and notoemojiregular too, but they also did not work. Mar 6, 2017 at 21:23

You must log in to answer this question.

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