8

I am struggling to switch the fonts in ConTeXt accordingly and feel that I am missing something basic. I try to mimic

\RequirePackage{fontspec}

% Use Neo Euler as math font
\RequirePackage[vargreek-shape=TeX]{unicode-math}% 
\setmathfont{Asana Math}%
% Use the Palatino-Clone Tex Gyre Pagella as main font
\setmainfont[Ligatures=TeX, Numbers=OldStyle]{Tex Gyre Pagella}%
% Use Tex Gyre Cursor as Monospace Font
\setmonofont{Tex Gyre Cursor}%
% Use Tex Gyre Heros Cn as Sans Serif Font
\setsansfont{Tex Gyre Heros}%
% fontsize is 10pt, 13pt for book and 12pt, 15pt for handout
\renewcommand{\normalsize}{\fontsize{10pt}{13pt}\selectfont}%
% fontsize is 10pt, 13pt for book and 9pt, 11pt for kindle
\renewcommand{\footnotesize}{\fontsize{8pt}{10pt}\selectfont}%

which works fine in a LuaLaTeX file.

My best try so far is

%setup the fonts
\usemodule[simplefonts] 
\definefontfeature[default][default][onum=yes]
%
\setmathfont[Asana Math]%
% Use the Palatino-Clone Tex Gyre Pagella as main font
\setmainfont[Tex Gyre Pagella]%
% Use Tex Gyre Cursor as Monospace Font
\setmonofont[Tex Gyre Cursor]%
% Use Tex Gyre Heros Cn as Sans Serif Font
\setsansfont[Tex Gyre Heros]%
\setupbodyfont[TeX Gyre Pagella,10pt]

\definebodyfontenvironment [10pt] [a=16pt]

\starttext
italic but not math \it mathmode 123

$123 mathmode$

\tfa Big
\stoptext

I know that a couple of things go wrong here. My question is now: What is best practice in context? I feel that I am mixing simplefonts macros (setmainfont) with context-core ones (\setupbodyfont[TeX Gyre Pagella,10pt]).

Could someone clarify if I have to use different simplefonts macros for e.g. fontsize? Do I have to decide, either only context-core or simplefonts. And which one is recommended?

  • Is there a preferred way? I guess without module is recommended? – Andy May 10 '12 at 15:49
9

Simplefonts based solution:

\definefontfeature[default][default][onum=yes]
\usemodule[simplefonts][size=10pt]

\setmathfont[Asana]
\setmainfont[Tex Gyre Pagella]
\setmonofont[Tex Gyre Cursor]
\setsansfont[Tex Gyre Heros]

\definebodyfontenvironment [10pt] [a=16pt]

\starttext
italic but not math {\it mathmode 123}

$123 mathmode$

\tfa Big

\stoptext
11
+50

Typescript-based version :

\usetypescriptfile[asana]

\definefontfeature[default][default][onum=yes]

\starttypescript[me]
    \definetypeface [me] [rm] [serif] [pagella] [default]
    \definetypeface [me] [ss] [sans]  [heros]   [default]
    \definetypeface [me] [tt] [mono]  [cursor]  [default]
    \definetypeface [me] [mm] [math]  [asana]   [default]
\stoptypescript

\definebodyfontenvironment [10pt] [a=16pt]

\setupbodyfont[me,10pt]

\starttext
italic but not math \it mathmode 123

$123 mathmode$

\tfa Big
\stoptext
  • Either you do not have the Asana font installed, or your ConTeXt is too old (the first is likelier). – Taco Hoekwater Sep 30 '13 at 8:40
5

Aditya's solution is great but unfortunately outdated. ConTeXt is developed at a very fast pace and a lot happened since 2012. The documentation of the simplefonts module lists some changes and I have implemented them on the basis of Aditya's example.

Today you perhaps want to use the official companion math font for TeX Gyre Pagella instead of Asana Math.

\definefontfeature[default][default][onum=yes]
\definefontfamily[texgyre][serif][TeX Gyre Pagella]
\definefontfamily[texgyre][sans] [TeX Gyre Heros]
\definefontfamily[texgyre][mono] [TeX Gyre Cursor][features=none]
\definefontfamily[texgyre][math] [TeX Gyre Pagella Math]
\setupbodyfont[texgyre,10pt]

\starttext
italic but not math {\it mathmode 123}

$123 mathmode$

\tfa Big
\stoptext

enter image description here

4

The best practice in my opinion is to use typescripts. The Context-Wiki is always a great place to look for Context specific stuff. In this case it's Fonts in Context (LauTeX).

  • 3
    What would be the code in the case at hand? – egreg May 10 '12 at 10:05
  • The given code is derived from that page (section:"With the simplefonts module") and kind of works, but my question goes in a different direction. – Andy May 10 '12 at 10:30

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.