ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Wolfgang Schuster <schuster.wolfgang@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Different fonts for titles
Date: Sun, 14 Apr 2013 23:42:16 +0200	[thread overview]
Message-ID: <6AA76928-A71A-4686-9CF8-C2A439467B5C@gmail.com> (raw)
In-Reply-To: <516AA262.4080509@mmnetz.de>


Am 14.04.2013 um 14:34 schrieb H. Özoguz <h.oezoguz@mmnetz.de>:

> Hoping for some hints .... :)

What you’re looking for is the \definefont command, in one way a low level method to access a font
but also a usefull command to create styles for headings etc.


Let me start with the following example:

  \definefont[Test][texgyrepagellaregular at 12pt]

  \starttext
  \Test VA ffl
  \stoptext

What I do here is to create the new command \Test which loads the file “texgrepagellaregular”
at a size 12pt. With the optional prefix on front of the font name you can specify the search method,
context provides the three different methods a) file b) name and c) spec.

  a) \definefont[Test][file:texgyrepagellaregular]
  b) \definefont[Test][name:texgyrepagellaregular]
  c) \definefont[Test][spec:texgyrepagella-normal-normal]


Instead of a fixed size for the font you can also use a relative size which depends on the bodyfont.

  \definefont[Test][texgyrepagellaregular sa 1]

  \starttext
  \Test VA ffl \switchtobodyfont[20pt]\Test VA ffl
  \stoptext

When you use “sa XX” as argument for the size your font scales also when you change the bodyfont
in the middle of the document.


One problem of the definitions above is that kerning, ligatures etc. aren’t activated for the font
because no feature isn’t applied. To apply a feature set you have to use a different method than
the one which is used in a typescript because \definefont has no feature-key. What you have to
do to apply the set is to append it after the name name and separate both with a asterisks.

  \definefont[Test][texgyrepagellaregular*default sa 1]

  \starttext
  \Test VA ffl
  \stoptext


Instead of the real name of a file you can also use a symbolic name from a typescript.

  \definefont[Test][SansBold sa 1]

  \starttext
  \Test VA ffl
  \stoptext

In this example I used the bold version of the sans style for my \Test font, in this case
you don’t have to add the name of a feature because it has been already set in the typescript.


A complete example in a document could be look like this:

\definetypeface[mainface][rm][specserif][Antykwa Poltawskiego]
\definetypeface[mainface][ss][specsans] [Iwona]

\definefont[ChapterStyle][SansBold sa 3]

\setuphead[chapter][style=ChapterStyle]

\setupbodyfont[mainface]

\starttext

\chapter{Knuth}

\input knuth

\stoptext


Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


  reply	other threads:[~2013-04-14 21:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-14 12:34 "H. Özoguz"
2013-04-14 21:42 ` Wolfgang Schuster [this message]
2013-04-15  1:17   ` Tim Li
  -- strict thread matches above, loose matches on Subject: below --
2013-04-15  5:49 "H. Özoguz"
2013-04-15  5:57 ` Aditya Mahajan
2013-04-13  9:47 "H. Özoguz"

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6AA76928-A71A-4686-9CF8-C2A439467B5C@gmail.com \
    --to=schuster.wolfgang@gmail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).