Changes

Jump to navigation Jump to search
dude, this is ConTeXt not LaTeX :)
==Quick start==
\setromanfont{Your font name here}If you want to start using some of the fonts installed in your system (e.g. Serapion Pro), start with the following snippet:
<texcode>
\definetypeface[Serapion][rm][Xserif][Serapion Pro]
\setupbodyfont[Serapion, 12pt]
</texcode>
 
In this case the document will be set in 12pt Serapion Pro typeface. If you want to start fiddling with the fonts a bit more, read on about the typescripts.
 
==Compatibility Typescripts==
 
The first class of typescript enables one to use familiar typescripts, such as times, palatino, postscript, and the like, from <tt>type-exa</tt>. The following typescripts are defined for the <tt>uc</tt> encoding:
; times : ''Times Roman'' - no slanted, no small caps
; palatino : ''Book Antiqua'' - (Apple's Palatino clone) no slanted, no small caps
; helvetica : ''Helvetica Neue'' - Apple's default Helvetica doesn't offer an oblique, so Helvetica Neue is substituted
; courier : ''Courier'' - No italics or oblique. None of Apple's default monospaced fonts ship with an oblique, so this typescript is necessarily limited.
; lucida : ''Lucida Bright, Sans, Typewriter, Calligraphy, Handwriting,'' and ''Fax'' are all provided with Microsoft's Office 2004. For those with that software and those fonts, these typescripts are provided to take advantage of the predefined ones in ConTeXt. Keep in mind that the lucida math fonts are still for-pay only.
 
You can simply invoke these typescripts with the familiar calls, except that they have the <tt>uc</tt> encoding:
<texcode>
\usetypescript[times][uc]
\setupbodyfont[times]
</texcode>
 
Please note that there is absolutely no attempt to retain font metrics, so this will almost certainly re-flow legacy documents. The following typescripts/typefaces from <tt>type-exa</tt> are thus available:
* postscript
* times
* palatino
* lucida (if you have the fonts)
 
==Wildcard typescripts==
XeTeX offers some nice features in terms of automatically finding related fonts in a family, namely the italic, bold, and bolditalic alternatives. To take advantage of that, there's a set of wildcard typescripts that take an arbitrary Macintosh font name as input, and provide as many of the alternatives it can find. To set these typescripts (and the calling conventions) apart from the familiar ones, the typescripts are identified with <tt>Xserif</tt>, <tt>Xsans</tt>, and <tt>Xmono</tt>. As they use some specific XeTeX features, they all use the <tt>uc</tt> encoding.
 
To call the typescripts, it's most convenient to define a typeface that uses these features. The named font slot should contain the display name of the Regular alternative (not the family name) of the font in question. The typefaces are callable with four, five, or six arguments:
 
<texcode>
\definetypeface[myface][rm][Xserif][Baskerville]
\definetypeface[myface][tt][Xmono] [Courier] [default]
\definetypeface[myface][ss][Xsans] [Optima Regular][default][rscale=.87]
</texcode>
 
As you can see, you can activate relative scaling of face sizes. The above definitions look very much like any other typeface definition, except that the serif/sans/mono identifier is preceded with X, and that there is no underlying "Optima Regular" typescript defined anywhere. The rest is typescript and XeTeX magic.
 
==Other typescripts==
Typescript usage is best done by creating your own typeface and using it. There are no pre-defined combinations, only tools for making your own combinations. As you can use arbitrary fonts "on-the-fly" with the above wildcard typescripts, I see pre-built typescripts for Apple fonts as being more stifling to the designer than anything else!
; hoefler : Rich serif AAT font from Apple. There are many features in the font, not yet exploited by the basic typescript.
<texcode>
\definetypeface [MyFace][rm][serif][hoefler][default][encoding=uc]
</texcode>
; lucidagrande : Very extensive Unicode and language support in this sans serif AAT font from Apple. Only Regular and Bold weights are available.
<texcode>
\definetypeface [MyFace][ss][sans][lucidagrande][default][encoding=uc]
</texcode>
; gillsans & gillsanslt : Although there are not many features in this classic humanist sans, it is available at three different font weights. ''gillsans'' offers regular and bold, and ''gillsanslt'' offers light as the <tt>\tf</tt> variant and regular as the <tt>\bf</tt> weight.
<texcode>
\definetypeface [MyFace][ss][sans][gillsanslt][default][encoding=uc]
</texcode>
; optima : Nothing special in this typescript, except that it defines an ''OptimaBlack'' synonym for your use.
<texcode>
\definetypeface [MyFace][ss][sans][optima][default][encoding=uc]
</texcode>
; zapfino & applechancery : These rich AAT fonts are defined as 'handwriting' and 'calligraphy' fonts, respectively. By using them as 'serif' fonts, however, you can use other variants through the <tt>\it</tt>, <tt>\bf</tt>, etc. alternatives.
<texcode>
\definetypeface [MyFace][hw][handwriting][zapfino][default][encoding=uc] % or
\definetypeface [MyFace][rm][serif] [zapfino][default][encoding=uc]
</texcode>
===Non-Apple fonts===
A couple of typescripts to get you started with non-Apple fonts:
; timesnewroman & arial : MS Office 2004 updates these fonts with quite impressive Unicode coverage.
<texcode>
\definetypeface [MS][rm][serif][timesnewroman][default][encoding=uc]
\definetypeface [MS][ss][sans] [arial] [default][encoding=uc]
</texcode>
; gentium : SIL also produce a very attractive Unicode font, [http://scripts.sil.org/gentium Gentium], that is available in both regular and italic varieties.
<texcode>
\definetypeface [MyFace][rm][serif][gentium][default][encoding=uc]
</texcode>
 
===Usage===
Once you define your own typeface combination, you invoke it with the name you gave it (the first parameter in <tt>\definetypeface</tt>), in <tt>\setupbodyfont</tt> or <tt>\switchtobodyfont</tt>:
<texcode>
\setupbodyfont[MyFace, 11pt]
</texcode>
 
==Creating your own typescripts==
 
Let's take a look at the components of a new typescript:
 
<texcode>
\starttypescript[serif][didot][uc]
</texcode>
The family (serif), typescript name (didot), and encoding (uc) are established.
<texcode>
\definefontsynonym [DidotRegular]['Didot:mapping=tex-text'] [encoding=uc]
</texcode>
The first font synonym has a font-specific name (DidotRegular), and then a quoted font specification. The font name (''Didot'', which is the display name of the regular alternative of the font) is followed by a colon and then a feature (mapping=tex-text). This particular feature enables TeX-like markup with fonts that don't necessarily have features for understanding such things as '<tt>---</tt>'. The final argument tells ConTeXt that this is a Unicode font, and that it should convert named glyphs to Unicode values (as defined in <tt>enco-uc</tt>).
<texcode>
\definefontsynonym [DidotItalic] ['Didot/I:mapping=tex-text'] [encoding=uc]
\definefontsynonym [DidotBold] ['Didot/B:mapping=tex-text'] [encoding=uc]
</texcode>
The next two font synonyms use a XeTeX feature as a shortcut: <tt>Didot/I</tt> and <tt>Didot/B</tt> are abbreviations for ''Didot Italic'' and ''Didot Bold'', respectively.
<texcode>
\definefontsynonym [DidotCaps] ['Didot:mapping=tex-text;
Letter Case=Small Capitals;Ligatures=!Common Ligatures'][encoding=uc]
\stoptypescript
</texcode>
Didot Caps require a few more features to be added, separated by a semicolon (or comma). The exclamation mark in <tt>!Common Ligatures</tt> is there to suppress that feature, which is turned on by default.
 
The 'name' typescript, which maps from the font-specific names to ConTeXt-wide names then follows:
<texcode>
\starttypescript[serif][didot][name]
\definefontsynonym [Serif] [DidotRegular]
\definefontsynonym [SerifItalic] [DidotItalic]
\definefontsynonym [SerifBold] [DidotBold]
\definefontsynonym [SerifCaps] [DidotCaps]
</texcode>
...four of the usual typescripts are named above, but you need:
<texcode>
\definefontsynonym [SerifSlanted] [DidotItalic]
\definefontsynonym [SerifBoldItalic] [DidotBold]
\definefontsynonym [SerifBoldSlanted][DidotBold]
\stoptypescript
</texcode>
...three further synonyms acting as fallbacks for the typescript to be complete.
 
==Other font specifications==
Don't forget that you can use one-off font definitions for special uses with <tt>\definedfont</tt>, <tt>\startfont</tt>/<tt>\stopfont</tt> and the like:
<texcode>
\definedfont["Hoefler Text:mapping=tex-text;Style Options=Engraved Text;
Letter Case=All Capitals;color=229966" at 24pt]
Big Title
</texcode>
[[Image:HoeflerTitling.jpg]]
<texcode>
\usetypescript[sans][optima][all]
\startfont[OptimaBlack sa 2]
Fat title
\stopfont
</texcode>
[[Image:OptimaBlack.jpg]]
 
--[[User:Adam|Adam]] 02:39, 26 Nov 2004 (CET)
 
==Accessing glyphs from OpenType fonts by name==
 
<code>\XeTeXglyphindex</code> returns the index of a named glyph from (an OpenType) font.
 
<texcode>
\def\getglyph#1{\XeTeXglyph\XeTeXglyphindex "#1"} % getglyph is already taken in ConTeXt!!!
 
\definedfont['Antykwa Torunska']
 
I \getglyph{heart} this feature!
</texcode>
 
''(An image will be put here as soon as XeTeX will be enabled on contextgarden.)''
 
==Using PostScript fonts==
 
Note: It's '''not''' possible to use oldfashioned Mac resource fork fonts (where you have a "suitcase" with screen fonts) with ConTeXt!
 
This example uses PostScript fonts installed in the texmf tree:
 
<texcode>
\starttypescript [sans] [urw-grotesk]
% PostScript name file name instead of an encoding
\definefontsynonym [URWGroteskT-LighNarr] [file:u004242t] [features=default]
\definefontsynonym [URWGroteskT-MediNarr] [file:u004244t] [features=default]
\definefontsynonym [URWGroteskT-LighNarrObli] [file:u004262t] [features=default]
\definefontsynonym [URWGroteskT-MediNarrObli] [file:u004264t] [features=default]
\stoptypescript
 
\starttypescript [sans] [urw-grotesk]
\definefontsynonym [Sans] [URWGroteskT-LighNarr]
\definefontsynonym [SansItalic] [URWGroteskT-LighNarrObli]
\definefontsynonym [SansBold] [URWGroteskT-MediNarr]
\definefontsynonym [SansBoldItalic] [URWGroteskT-MediNarrObli]
\definefontsynonym [SansSlanted] [SansItalic]
\definefontsynonym [SansBoldSlanted] [SansBoldItalic]
\stoptypescript
 
\starttypescript [my] [urw-grotesk]
% \definetypeface [urw-grotesk] [rm] [serif] [schola] [default]
\definetypeface [urw-grotesk] [ss] [sans] [urw-grotesk] [default] [encoding=uc]
\stoptypescript
 
\usetypescript [my][urw-grotesk]
\setupbodyfont [urw-grotesk,ss,8pt]
 
</texcode>
 
If you'd like to use active (OS-installed) fonts, replace "file:filename" with "name:public name" like this:
 
<texcode>
\definefontsynonym [Eco-Regular] [name:Eco101Roman] [features=default]
\definefontsynonym [Eco-Bold] [name:Eco301Bold] [features=default]
\definefontsynonym [Eco-Italic] [name:Eco102Italic] [features=default]
\definefontsynonym [Eco-BoldItalic] [name:Eco302BoldItalic] [features=default]
</texcode>
 
(Sample from [[http://archive.contextgarden.net/message/20080120.125423.babb9aea.en.html this thread]].)
(Sample from [[http://archive.contextgarden.net/message/20080120.125423.babb9aea.en.html this thread]].)<br>
{{SERVER}}/[http://www.writers.ph freelance writing]
[[Category:Fonts]]
68

edits

Navigation menu