3

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

4

To set a fallback font for \definefontfamily you have to put all \definefallbackfamily settings before the main font. It is also necessary to use the correct arguments for the range key, in your case you need 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

  • Thanks – I noted you used \utfchar; is it possible to embed the UTF characters directly? – Brian M. Hunt Mar 6 '17 at 21:23
  • Yes you can also use the characters itself in your document. – Wolfgang Schuster Mar 6 '17 at 21:28
  • Is there a way to set it up so the range parameter is unnecessary? – Brian M. Hunt Mar 6 '17 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. – Wolfgang Schuster Mar 7 '17 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]
  • I tried notoemoji and notoemojiregular too, but they also did not work. – Brian M. Hunt Mar 6 '17 at 21:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.