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

Brian M. Hunt
  • 14,277

2 Answers2

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.

Dave Jarvis
  • 11,809
Wolfgang Schuster
  • 9,400
  • 1
  • 16
  • 19
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]
tuxador
  • 121