2

I'm using ConTeXt, with XeTex. So I'm compiling my document: texexec --xetex foo.tex

I would like to follow the convertion of having my headings all in Sans Serif, and my body text in Serif. I want to do this with my own fonts:

%&context
\definetypeface[BerlinSSDB][ss][sans][Berlin Sans FB Demi]
\definetypeface[Minion][rm][Xserif][Minion Pro]
\setupbodyfont[Minion, 12pt]

\setuphead[chapter][
    style=\ss,
    sectionnumber=yes
    ]

\setuphead[section][
    style=\ss,
    sectionnumber=no
    ]

\starttext

\chapter{Welcome}
A well known text, used to fill space.

\section{H. Rackham 1914}
But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness... But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?

\stoptext

Everything, headings, body and all is coming up in Minion Pro. This seems reasonable since no where have I told it what font to use, except to say "Use Minion". (I believe \setupbodyfont, uses the word body with a different meaning to what I have here.)

Mico
  • 506,678
  • This seems related: http://tex.stackexchange.com/questions/45853/sans-serif-fonts-for-section-titles-in-context?rq=1, but as someone new to ConTeX, and XeTex I can't see how to mesh in the XeTex font stuff with the ConTeXt style stuff – Frames Catherine White Jul 20 '12 at 10:47
  • See also: http://tex.stackexchange.com/a/58153/5245 – Marco Jul 20 '12 at 12:17
  • 1
    Is there a reason for not using LuaTeX with MkIV? The simplefonts module would make font switching more easy. – Marco Jul 20 '12 at 12:27
  • Not really, I'm quiet new to TeX (I've used LyX for a couple of years) I don't know the flags to send to tell it to use LuaTex, (it defaults to pdfTex according to output (or does LuaTex call itself pdfTex in its output?) – Frames Catherine White Jul 20 '12 at 13:17
  • 2
    Short incomplete explanation: If you compile with texexec <file> it's pdfTeX with MkII, if you compile with texexec --xetex <file> it's xeTeX with MkII (not well supported) and if you compile with context <file> it's LuaTeX with MkIV. When you're in doubt what to use, go for context <file>. – Marco Jul 20 '12 at 13:21
  • 1
    As an aside: your allusion to dolorem ipsum is a very nice touch. – Esteis Jul 20 '12 at 19:08

2 Answers2

4

Since you are starting with ConTeXt, I would suggest that you use LuaTeX backend instead of XeTeX.

With luatex backed (called Context MkIV), you can use the simplefonts module that makes it easy to load Opentype/Truetype fonts. For example (I changed the fonts to generic fonts) and made a few stylistic changes as well. Compile the document using context <filename>.

\usemodule[simplefonts][size=12pt]
\setmainfont[Linux Libertine O]
\setsansfont[Dejavu Sans]

\setuphead
  [chapter]
  [
    style=\ssb, % Same as \ss but uses bigger font size
    sectionnumber=yes, % Note the comma!
  ]

\setuphead
  [section]
  [
    style=\ssa, % Same as \ss but uses bigger font size
    sectionnumber=no, % Note the comma!
  ]

\starttext

\chapter{Welcome}
A well known text, used to fill space.

\section{H. Rackham 1914}
But I must explain to you how all this mistaken idea of denouncing pleasure
and praising pain was born and I will give you a complete account of the
system, and expound the actual teachings of the great explorer of the truth,
the master-builder of human happiness... But who has any right to find fault
with a man who chooses to enjoy a pleasure that has no annoying
consequences, or one who avoids a pain that produces no resultant pleasure?

\stoptext
Aditya
  • 62,301
  • Might want to note that simplefonts is a 3rd party module, and to install it use: first-setup.bat --modules="t-simplefonts" (There is probably a betterway to install it than this, since that seems to do alot of reinstalling) – Frames Catherine White Jul 21 '12 at 13:06
  • I usually use first-setup.sh --modules=all while installing context. – Aditya Jul 21 '12 at 13:45
  • Can I set the font size when I set the font: \setsansfont[Berlin Sans FB Demi][size=34pt] doesn't seem to work Berlin Sans is a tiny font, – Frames Catherine White Jul 21 '12 at 14:10
  • Use \setsansfont[...][scale=2] to scale the sans font by a factor of two. – Aditya Jul 21 '12 at 17:55
2

The answer is surprisingly simple: in your example, the first term in the line

\definetypeface[BerlinSSDB][ss][sans][Berlin Sans FB Demi]

is just an identifier which can be anything. If you want to have a full set (rm + sans), you need to use the same identifier so ConTeXt knows that these fonts form one collection. So here's your example rewritten (I have tested with other fonts because I don't have the ones you use; better use generic fonts for your MWE):

\definetypeface [Oxinabox] [rm] [Xserif] [Minion Pro]
\definetypeface [Oxinabox] [ss] [Xsans]  [Berlin Sans FB Demi]
\setupbodyfont  [Oxinabox, 12pt]

\setuphead[chapter][
    style=\ss,
sectionnumber=yes
]

\setuphead[section][
style=\ss,
sectionnumber=no
]

\starttext

\chapter{Welcome}
A well known text, used to fill space.

\section{H. Rackham 1914}
But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness... But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?

\stoptext

But as others have already said, if you're serious about using ConTeXt, better have a look at luatex/mkiv. It can almost everything that XeTeX can, and then so much more.

Thomas
  • 1,726
  • I'm accepting this answer, as it answers the question. (If someone comes back here looking for how to do this in XETEX, then this is the answer they will want. – Frames Catherine White Jul 21 '12 at 00:32