https://wiki.contextgarden.net/api.php?action=feedcontributions&user=Nicolas+Girard&feedformat=atomWiki - User contributions [en]2024-03-29T14:44:36ZUser contributionsMediaWiki 1.34.1https://wiki.contextgarden.net/index.php?title=Command/definefirstline&diff=22021Command/definefirstline2013-08-25T08:50:38Z<p>Nicolas Girard: Added to category Command/Paragraphs</p>
<hr />
<div>{{Reference<br />
|name=definefirstline<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\definefirstline<span class="first">[..]</span><span class="third">[]</span></td><br />
<tr><br />
<td colspan="2" class="cmd">\definefirstline<span class="first">[...]</span><span class="second">[...]</span><span class="third">[...=...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>''name of firstline style''</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[...]</td><br />
<td>''name of firstline style to inherit from''</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">alternative</td><br />
<td><code>line</code> <code>word</code></td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:n|n]]</td><br />
<td><code>integer</code>: number of words to affect</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:style|style]]</td><br />
<td>[[Style Alternatives|Style Alternative]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:color|color]]</td><br />
<td>[[Colors|IDENTIFIER]]: color name</td><br />
</tr><br />
</table><br />
<br />
== Description == <br />
Define a style to apply only to the first line of a paragraph.<br />
Once defined, the style can be applied by invoking<br />
{{cmd|setfirstline}} on a paragraph.<br />
One of two methods can be requested by setting the keyword<br />
<code>alternative</code>:<br />
<br />
* ''line'' applies the style to the entire line,<br />
* ''word'' applies the style only to the first <code>n</code> words of the first line.<br />
<br />
''NB'':<br />
The style substitution takes place on node level, hence small capitals<br />
require a font which implements them as a feature, not as a separate<br />
file<br />
(e. g. as of 2013<br />
[[Wishes_for_Latin_Modern#General_things|Latin Modern won’t do]]).<br />
<br />
== Example ==<br />
<br />
Typeset the first line once in bold, and then in small caps:<br />
<br />
<context mode=mkiv source=yes><br />
\setupbodyfont [heros] %% important: smallcaps capable font!<br />
<br />
\definefirstline [italicfirstline] [<br />
alternative=line,<br />
style=italic,<br />
]<br />
<br />
\definefirstline [smallcapsfirstline] [<br />
alternative=line,<br />
color=darkred,<br />
style=smallcaps,<br />
]<br />
<br />
\starttext<br />
<br />
\setfirstline[italicfirstline] \input knuth \par<br />
\setfirstline[smallcapsfirstline] \input knuth \par<br />
<br />
\stoptext<br />
</context><br />
<br />
To affect only the first three or six words change to the alternative<br />
''word'' and set the parameter <code>n</code> to the desired value:<br />
<br />
<context mode=mkiv source=yes><br />
\definefirstline [threegreenwords] [<br />
alternative=word,<br />
color=green,<br />
n=3,<br />
]<br />
<br />
\definefirstline [sixbluewords] [<br />
alternative=word,<br />
color=blue,<br />
n=6,<br />
]<br />
<br />
\starttext<br />
<br />
\setfirstline[threegreenwords] \input ward \par<br />
\setfirstline[sixbluewords] \input ward \par<br />
<br />
\stoptext<br />
</context><br />
<br />
== See also ==<br />
* {{cmd|setfirstline}}<br />
* [[Style Alternatives]]<br />
* Source code: {{src|typo-fln.mkiv}} (with examples) {{src|typo-fln.lua}}.<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|definefirstline}}<br />
<br />
[[Category:Command/Fonts|definefirstline]]<br />
[[Category:Command/Paragraphs|defineindenting]]</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Thumb_index&diff=21941Thumb index2013-07-04T14:42:41Z<p>Nicolas Girard: \somestructureheadnumber renamed as \someheadnumber</p>
<hr />
<div>{{todo | this page needs to be cleaned up}}<br />
<br />
The following code is an example of how to draw a graphic on every page of a document. The graphic (a grey rectangle) appears in a different place for each chapter, and the chapter number appears in the rectangle as well. This is often called a thumb index - your thumb can flip the pages of a book while you watch the contents flash past...<br />
<br />
<texcode><br />
% by Hans Hagen, of course :-)<br />
<br />
\unprotected \def\rawsectionnumber#1{\countervalue{\??se#1}} % will be in kernel<br />
<br />
\setuppagenumbering<br />
[alternative=doublesided]<br />
<br />
\setupcolors<br />
[state=start]<br />
<br />
\setupbackgrounds<br />
[page]<br />
[background=thumbs]<br />
<br />
\defineoverlay<br />
[thumbs]<br />
[\setups{thumbs}]<br />
<br />
\def\NOfChapters{4} % i need to make this one available<br />
<br />
\startsetups thumbs<br />
<br />
\definemeasure[thumbheight][\dimexpr\paperheight/\NOfChapters\relax]<br />
<br />
\vbox to \paperheight \bgroup<br />
\vskip \rawsectionnumber{section-2} \measure{thumbheight}<br />
\vskip -1 \measure{thumbheight}<br />
\doifoddpageelse\hfill\donothing<br />
\framed<br />
[background=color,<br />
backgroundcolor=darkgray,<br />
frame=off,<br />
foregroundcolor=white,<br />
height=\measure{thumbheight},width=1cm]<br />
{\bfa \rawsectionnumber{section-2}}<br />
\doifoddpageelse\donothing\hfill<br />
\vss<br />
\egroup<br />
<br />
\stopsetups<br />
<br />
\starttext<br />
<br />
\chapter{first} \dorecurse{10}{\input tufte }<br />
\chapter{second} \dorecurse{10}{\input davis }<br />
\chapter{third} \dorecurse{10}{\input zapf }<br />
\chapter{fourth} \dorecurse{10}{\input bryson }<br />
<br />
\stoptext<br />
</texcode><br />
<br />
<br />
== Another Example ==<br />
An example (MkIV) for using Metapost to create thumb indices for chapters.<br />
<br />
<texcode><br />
\setuppapersize[A4][A4,oversized]<br />
<br />
\setuplayout<br />
[width=middle,<br />
% margin=\dimexpr\backspace-\margindistance\relax<br />
location=middle]<br />
<br />
\definecolor[chap_frame][g=1,t=1,a=12]<br />
\definecolor[sect_frame][b=1,t=1,a=12]<br />
\definecolor[textcolor] [r=1,t=1,a=12]<br />
<br />
\startuseMPgraphic{chapter thumb}<br />
path chap_frame, sect_frame ; pair pos,a,b ; picture text ;<br />
<br />
if \somenamedheadnumber{chapter}{current} > 0 :<br />
curr_chap := \somenamedheadnumber{chapter}{current} ; <br />
else :<br />
curr_chap := 1 ;<br />
fi;<br />
if \somenamedheadnumber{chapter}{last} > 0 :<br />
last_chap := \somenamedheadnumber{chapter}{last} ;<br />
else :<br />
last_chap := 1 ;<br />
fi;<br />
if \somenamedheadnumber{section}{current} > 0 : <br />
curr_sect := \somenamedheadnumber{section}{current} ; <br />
else: <br />
curr_sect := 1 ;<br />
fi;<br />
if \somenamedheadnumber{section}{last} > 0 :<br />
last_sect := \somenamedheadnumber{section}{last};<br />
else:<br />
last_sect := 1;<br />
fi; <br />
<br />
skip := TextHeight * (curr_chap-1)/last_chap ;<br />
height := TextHeight/last_chap ;<br />
sskip := height*curr_sect/last_sect ;<br />
<br />
text := textext("\ssbfb\textcolor Chapter\enspace\getmarking[chapternumber]");<br />
<br />
StartPage ;<br />
chap_frame := fullsquare xyscaled(RightMarginWidth,height) ;<br />
<br />
a := ulcorner chap_frame ;<br />
b := urcorner chap_frame ;<br />
<br />
sect_frame := a--b--(xpart b,ypart b-sskip)--(xpart a,ypart a-sskip)--cycle;<br />
<br />
pos := urcorner Field[Text][RightMarginSeparator] -<br />
ulcorner chap_frame - (0,skip);<br />
<br />
fill chap_frame shifted pos withcolor \MPcolor{chap_frame};<br />
unfill sect_frame shifted pos withcolor white ;<br />
fill sect_frame shifted pos withcolor \MPcolor{sect_frame};<br />
draw text rotated 90 shifted pos ;<br />
StopPage ;<br />
\stopuseMPgraphic<br />
<br />
<br />
\defineoverlay[chapter thumb][\useMPgraphic{chapter thumb}]<br />
<br />
\setupbackgrounds[page][background=chapter thumb]<br />
<br />
<br />
\starttext \showframe<br />
\dorecurse{6}{\chapter{Test Chapter #1}<br />
Chapter \someheadnumber[chapter][current] of<br />
\someheadnumber[chapter][last]<br />
\dorecurse{9}{\section{Test Section}<br />
Section \someheadnumber[section][current] of<br />
\someheadnumber[section][last] \blank<br />
\input tufte \par \input knuth \par<br />
}<br />
}<br />
\stoptext<br />
</texcode></div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Fonts_in_LuaTeX&diff=10263Fonts in LuaTeX2010-01-19T14:55:33Z<p>Nicolas Girard: /* Getting access to the system fonts */ Added a note about dfont fonts (greetings to Wolfgang Schuster / http://www.ntg.nl/pipermail/ntg-context/2009/042238.html )</p>
<hr />
<div>{{note|This page is not finished yet}}<br />
<br />
'''Please, someone, fill this page !'''<br />
<br />
'''This page is beeing regorganized'''<br />
<br />
= Getting access to the system fonts =<br />
<br />
LuaTeX can use non-TeX fonts (in OpenType, TrueType or Type1 format) directly. <br />
<br />
Mac OS users should note that many of their system fonts come packaged in the .dfont format. This format is Mac-specific and isn't recognized by LuaTeX ; but the free software [http://fondu.sourceforge.net/#Fondu fondu] program can be used to convert dfont fonts to TrueType.<br />
<br />
The first time that you run<br />
<br />
context myfile.tex<br />
<br />
on a file that uses such non-traditional fonts (which is probably always), the actual fonts themselves have to be loaded in luatex's embedded section of fontforge to extract their metric information. This removes the need for tfm and vf files on your disk, but it is also a somewhat lengthy and often memory-hungry process.<br />
<br />
That is why the results of that internal preprocessing are also saved inside the texmf cache. Future runs using the same font (not just this file, but all files using that particular font) can then use the cached version of the metrics instead. <br />
<br />
== Building the font database ==<br />
<br />
You need to specify where the fonts should be looked for, by setting the <code>OSFONTDIR</code> environment variable. For instance,<br />
set OSFONTDIR=c:/windows/fonts/<br />
if the fonts should be found in <code>c:/windows/fonts/</code>; or<br />
export OSFONTDIR="/usr/local/share/fonts;$HOME/.fonts"<br />
if the fonts should be found in both <code>/usr/local/share/fonts</code> and <code>$HOME/.fonts</code>.<br />
<br />
The font database will then be automatically generated in the next run of <code>context</code><br />
<br />
You can also generate it manually by typing <br />
mtxrun --script font --reload<br />
or equally<br />
mtxrun --script fonts --reload<br />
<br />
The output should look like<br />
MTXrun | fontnames: identifying tree font files with suffix otf<br />
MTXrun | fontnames: identifying tree font files with suffix OTF<br />
MTXrun | fontnames: 331 tree files identified, 332 hash entries added, runtime 7.653 seconds<br />
MTXrun | fontnames: identifying tree font files with suffix ttf<br />
MTXrun | fontnames: identifying tree font files with suffix TTF<br />
MTXrun | fontnames: 17 tree files identified, 14 hash entries added, runtime 4.645 seconds<br />
...<br />
MTXrun | fontnames: 94 system files identified, 94 hash entries added, runtime 0.554 seconds<br />
MTXrun | fontnames: 3837 files read, 3342 normal and 49 extra entries added, 5 rejected, 3386 valid<br />
<br />
<br />
<br />
== Querying the font database ==<br />
<br />
The command<br />
mtxrun --script fonts --list<br />
will return the whole entries of the font database as a list, such as<br />
<br />
...<br />
warnockprobold WarnockPro-Bold E:/Fonts/Warnock Pro/WarnockPro-Bold.otf<br />
warnockproboldcapt WarnockPro-BoldCapt E:/Fonts/Warnock Pro/WarnockPro-BoldCapt.otf<br />
warnockprobolddisp WarnockPro-BoldDisp E:/Fonts/Warnock Pro/WarnockPro-BoldDisp.otf<br />
warnockproboldit WarnockPro-BoldIt E:/Fonts/Warnock Pro/WarnockPro-BoldIt.otf<br />
warnockprobolditcapt WarnockPro-BoldItCapt E:/Fonts/Warnock Pro/WarnockPro-BoldItCapt.otf<br />
warnockprobolditdisp WarnockPro-BoldItDisp E:/Fonts/Warnock Pro/WarnockPro-BoldItDisp.otf<br />
warnockprobolditsubh WarnockPro-BoldItSubh E:/Fonts/Warnock Pro/WarnockPro-BoldItSubh.otf<br />
warnockproboldsubh WarnockPro-BoldSubh E:/Fonts/Warnock Pro/WarnockPro-BoldSubh.otf<br />
...<br />
<br />
You can query the database against a particular pattern. For instance,<br />
mtxrun --script fonts --list --pattern=Delicious*<br />
will return<br />
deliciousbold Delicious-Bold /usr/local/share/fonts/d/delicious_bold.otf<br />
deliciousbolditalic Delicious-BoldItalic /usr/local/share/fonts/d/delicious_bolditalic.otf<br />
deliciousheavy Delicious-Heavy /usr/local/share/fonts/d/delicious_heavy.otf<br />
deliciousitalic Delicious-Italic /usr/local/share/fonts/d/delicious_italic.otf<br />
deliciousroman Delicious-Roman /usr/local/share/fonts/d/delicious_roman.otf<br />
delicioussmallcaps Delicious-SmallCaps /usr/local/share/fonts/d/delicious_smallcaps.otf<br />
<br />
You can get useful informations about your fonts by using the <code>--info</code> option. For instance,<br />
mtxrun --script fonts --list --info --pattern=Delicious*Roman<br />
will return<br />
MTXrun | fontname: deliciousroman<br />
MTXrun | fullname: Delicious-Roman<br />
MTXrun | filename: /usr/local/share/fonts/d/delicious_roman.otf<br />
MTXrun |<br />
MTXrun | gpos features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | kern latn dflt<br />
MTXrun |<br />
MTXrun | gsub features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | tlig all all<br />
MTXrun | trep all all<br />
<br />
== Installing new fonts ==<br />
<br />
After installing new fonts, the font database must be rebuilt for LuaTeX to access them.<br />
<br />
In current versions of Mark IV (earlier than July 2008) this is automatically done whenever a named font cannot be found.<br />
<br />
You only have to do the reload manually when you have installed updates to already installed fonts that cause the font and/or file names to change. <br />
This normally only happens for fonts that are still in development like [[TeX Gyre]] and [[Latin Modern]].<br />
<br />
You can rebuild the database manually, using the already-mentioned command<br />
mtxrun --script fonts --reload<br />
<br />
Alternatively, you can turn off the automatic rebuild of the database, by setting either of<br />
MTX.FONTS.AUTOLOAD<br />
MTX_FONTS_AUTOLOAD<br />
to "no".<br />
<br />
== References ==<br />
<br />
[http://context.aanhet.net/svn/contextman/context-reference/en/co-fonts.pdf The new manual chapter on fonts]<br />
<br />
= Using fonts =<br />
<br />
Handling fonts in LuaTeX can be done<br />
* in a simple but limited way, using the <code>simplefonts</code> module;<br />
* in the standard way, using [[TypeScripts]]<br />
<br />
== With the <code>simplefonts</code> module ==<br />
<br />
[http://www.ctan.org/tex-archive/macros/context/contrib/context-simplefonts simplefonts] is a third-party module written by Wolfgang Schuster.<br />
<br />
It simplifies the use of fonts in LuaTeX by<br />
* freeing the user from writing or using [[TypeScripts]];<br />
* offering an interface similar to the [http://www.ctan.org/tex-archive/macros/xetex/latex/fontspec/ fontspec package for XeTeX]<br />
<br />
For instance, assuming the [http://www.josbuivenga.demon.nl/delicious.html Delicious fonts] are properly installed and recognized by ConTeXt, you can simply write:<br />
<br />
<texcode><br />
\usemodule[simplefonts] % load the module<br />
\setmainfont[Delicious] % set Delicious as main (serif) font<br />
<br />
\starttext<br />
\rm\tf roman \it italic \bf bold \bi bolditalic \sc smallcaps<br />
\stoptext<br />
</texcode><br />
<br />
=== Installing <code>simplefonts</code> ===<br />
<br />
* If you're using LuaTeX along with TeXlive 2009, <code>simplefonts</code> is already installed<br />
* If you're running [[ConTeXt Minimals]], <code>simplefonts</code> can be installed like [http://wiki.contextgarden.net/ConTeXt_Minimals#Installing_third_party_modules any third-party module]:<br />
first-setup.sh --extras="t-simplefonts"<br />
<br />
== The standard way: Typescripts ==<br />
<br />
=== Installing typescripts ===<br />
<br />
Installing typescripts consists in the following:<br />
<br />
1. Copy the typescript files into either <br />
<texcode>$TEXMF/tex/texmf-fonts/tex/context/user<br />
$TEXMF/tex/texmf-project/tex/context/user</texcode><br />
2. Run <code>context --generate</code><br />
<br />
By convention, typescript files are named like <code>type-(fontname|foundry).tex</code>. <br />
<br />
It may happen that some <code>type-xx.tex</code> typescript file depends on mkiv-specific code located in a matching <code>type-xx.mkiv</code> file. In this case, both files need to be installed.<br />
<br />
=== Loading typescripts ===<br />
<br />
A typescript file named <code>type-xx.tex</code> should be loaded using<br />
\usetypescriptfile[type-xx]<br />
<br />
An alternative way is<br />
\usetypefile[xx]<br />
where ConTeXt prepends <code>type-</code> when it loads the file; but <br />
<cmd>usetypescriptfile</cmd> is the preferred command because it takes care of the<br />
<cmd>starttypescriptcollection</cmd>/<cmd>stoptypescriptcollection</cmd> environments.<br />
<br />
=== Where to find existing typescripts ===<br />
<br />
Each of the typescripts below defines a keyword to use with <cmd>setupbodyfont</cmd>. Usually this is the same as the name of the typescript, but there is one exception (<code>antykwa-torunska</code>)<br />
<br />
* Latin Modern (typescript name: <code>modern</code>; this is the default font set)<br />
* Latin Modern variant (ts name: <code>modernvariable</code>; LM variable typewriter for serif)<br />
* Postscript (ts name: <code>postscript</code>; Termes for serif, Heros for sans, Cursor for mono)<br />
* Antykwa Toruńska (ts name: <code>antykwa-torunska</code>; only serif; defines <tt>antykwa</tt> as keyword for <cmd>setupbodyfont</cmd>)<br />
* Iwona (ts name: <code>iwona</code>; only sans serif)<br />
* Iwona Light, Medium and Heavy (ts names: <code>iwona-light</code>, <code>iwona-medium</code>, <code>iwona-heavy</code>; only sans; the medium variant is a small bit heavier than a "regular" one)<br />
* Pagella (ts name: <code>palatino</code>; only serif)<br />
* Termes (ts name: <code>times</code>; only serif, Heros for sans)<br />
<br />
=== Usage example ===<br />
<br />
<texcode><br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,18pt]<br />
<br />
\starttext<br />
Hello world, I'm Pagella!<br />
\stoptext<br />
</texcode><br />
<br />
The first line seems to order ConTeXt to "install" (for the current file) the given typescript (it accepts what I have earlier called a "typescript name"). The last one starts using it (you may omit the size if you are satisfied with the default).<br />
<br />
=== Combining predefined fonts in your own typescripts ===<br />
<br />
It is also possible to combine fonts from the TeX Gyre collection in your own typescripts. The example below combines Bonum (Bookman) roman, Adventor (AvantGarde) for sans serif, Cursor (Courier) for teletype, and Euler for math. The <code>rscale=...</code> option ensures that all fonts have the same x-height. (You can lookup the relative x-heigt of a font using fontforge.)<br />
<br />
<texcode><br />
\starttypescript [Bonum]<br />
\definetypeface [Bonum] [rm] [serif] [bonum] [default]<br />
\definetypeface [Bonum] [ss] [sans] [adventor] [default] [rscale=0.887]<br />
\definetypeface [Bonum] [tt] [mono] [cursor] [default] [rscale=1.163]<br />
\definetypeface [Bonum] [mm] [math] [euler] [default] [rscale=1.050]<br />
\stoptypescript<br />
<br />
\usetypescript[Bonum]<br />
\setupbodyfont[Bonum,12pt]<br />
<br />
\starttext<br />
Hello world, I'm Bonum!<br />
\stoptext<br />
</texcode><br />
<br />
= Old contents =<br />
<br />
* [[TrueType fonts in luaTeX]]<br />
<br />
==== Good ol' typescripts ====<br />
<br />
Of course, Mark IV allows you to use typescripts as you've always done; for example:<br />
<br />
<texcode><br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,12pt]<br />
effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
<br />
\sc effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
</texcode><br />
<br />
That's as simple as using a traditional ConTeXt typescript!<br />
<br />
But ... how is it any different, then? Well, the difference is that in Mark IV, we can use an Opentype font directly, so that what is done here: when we want to use Palatino, the [[TeX Gyre]] equivalent (“Pagella”) is called and we can use its Opentype “features”; read on.<br />
<br />
==== Opentype features ====<br />
<br />
A “feature”, in the Opentype jargon, is a set of rules describing changes in the appearance of the text. Hmm, that's not very precise. Let's show some examples. First of all, you have to know that features are referred to by 4-letter tags, and you will see this a lot. One of them is ‘smcp‘, for “small caps“. Let's consider the following Mark IV-only code:<br />
<br />
<texcode><br />
\definefontfeature[smallcaps][language=DFLT,script=latn,smcp=yes]<br />
\font\palasmallcaps=texgyrepagella-regular*smallcaps<br />
\palasmallcaps This is a text in small capitals.<br />
</texcode><br />
<br />
Here you basically define a (Mark IV) feature with the name ”smallcaps”, and associate it with the (Opentype) feature “smcp”. You have to specify which script you want to use it with; scripts in Opentype are also tagged with four letters, and “latn” is of course Latin.<br />
<br />
Then you define a TeX font with that feature.<br />
<br />
You can see what features are defined in a particular font with the following bit of code<br />
<br />
<texcode><br />
\ctxlua<br />
{<br />
fontname = 'texgyrepagella-regular.otf'<br />
<br />
--[[ First read the font data.<br />
This makes heavy use of some of the Mark IV code]]<br />
tfmdata = fonts.tfm.read_and_define("file:" .. fontname, 655360)<br />
font = tfmdata.shared.otfdata<br />
if font<br />
then<br />
gsubfeatures = fonts.otf.analyze_features(font.gsub)<br />
gposfeatures = fonts.otf.analyze_features(font.gpos)<br />
end<br />
<br />
if gsubfeatures then<br />
table.sort(gsubfeatures) % We want our list sorted alphabetically!<br />
tex.sprint("\\rm GSUB features: \\tt ") % Beware: you don't want \rm to be interpreted by lua (\rm would yield carriage return + letter m)!<br />
for _, feat in ipairs(gsubfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GSUB features")<br />
end<br />
tex.sprint("\\par")<br />
<br />
if gposfeatures then<br />
tex.sprint("\\rm GPOS features: \\tt ")<br />
table.sort(gposfeatures)<br />
for _, feat in ipairs(gposfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GPOS features")<br />
end<br />
}<br />
</texcode><br />
<br />
It prints the list on the page. You'll notice there are two sets of features, each one of them defined in a different table of the Opentype font: the <code>GSUB</code> table (for Glyph SUBstitution) gives rules for replacing glyphs in certains circumstances (think of ligatures: f + i -> fi); the <code>GPOS</code> table (Glyph POSititioning) gives rules for moving glyphs (think of kerning: A + V -> A <kerning> V).<br />
<br />
Incidentally, the above code gives some basic examples of LuaTeX programming, a mixture of both Lua and TeX programming with some special features (features in the general sense, not the Opentype one :-).<br />
<br />
==== A (Complete) Typescript Example ====<br />
<br />
<texcode><br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [FranklinBookRegular] [name:FranklinGothicBookITC-Regular] [features=default]<br />
\definefontsynonym [FranklinMediumRegular] [name:FranklinGothicMediumITC-Regular] [features=default]<br />
\definefontsynonym [FranklinDemiRegular] [name:FranklinGothicDemiITC-Regular] [features=default]<br />
\definefontsynonym [FranklinHeavyRegular] [name:FranklinGothicHeavyITC-Regular] [features=default]<br />
<br />
\definefontsynonym [FranklinBookItalic] [name:FranklinGothicBookITC-Italic] [features=default]<br />
\definefontsynonym [FranklinDemiItalic] [name:FranklinGothicMediumITC-Italic] [features=default]<br />
\definefontsynonym [FranklinHeavyItalic] [name:FranklinGothicDemiITC-Italic] [features=default]<br />
\definefontsynonym [FranklinMediumItalic] [name:FranklinGothicHeavyITC-Italic] [features=default]<br />
<br />
\stoptypescript<br />
<br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [Sans] [FranklinBookRegular] [features=default]<br />
\definefontsynonym [SansItalic] [FranklinBookItalic] [features=default]<br />
\definefontsynonym [SansBold] [FranklinDemiRegular] [features=default]<br />
\definefontsynonym [SansBoldItalic] [FranklinDemiItalic] [features=default]<br />
\definefontsynonym [SansSlanted] [SansItalic] [features=default]<br />
\definefontsynonym [SansBoldSlanted] [SansBoldItalic] [features=default]<br />
\definefontsynonym [SansCaps] [Sans] [features=smallcaps]<br />
<br />
\stoptypescript<br />
<br />
\definetypeface[franklin][rm][sans][franklin][default]<br />
\definetypeface[franklin][ss][sans][franklin][default]<br />
\definetypeface[franklin][tt][mono][modern] [default][rscale=1.12]<br />
\definetypeface[franklin][mm][math][iwona] [default][rscale=1.02]<br />
<br />
\setupbodyfont[franklin,ss,10pt]<br />
</texcode><br />
<br />
<br />
<br />
Just the simplest way to use an otf font — or any font that does appear in <tt>mtxrun --script font --list</tt> — in all the document.<br />
<br />
I’m stick here :<br />
<br />
\definefontfeature [myfontfeature] [method=node, kern=yes, OTHER_FEATURE_COMMA_SEPERATED]<br />
\definefontsynonym [MyFontRegular] [name:TheFontName-Regular][features=myfontfeature]<br />
\definedfont [MyFontRegular at 16pt]<br />
<br />
This doesn’t run for my title which use « \tfc », only for the body of the text.<br />
<br />
*\definefontfeature<br />
**[myfontfeature] : you can use the name you want. It will be use at the next line ;<br />
**the fonts feature can be found with <tt>otfinfo -f TheFontFile.otf</tt>.<br />
*\definefontsynonym :<br />
**[MyFontRegular] : you can use the name you want. It will be use at the next line ;<br />
**The name after <tt>name:</tt> is the name given by <tt>mtxrun --script font --list</tt><br />
**The « name: » part can be replaced by <tt>file:TheFontFile.otf</tt><br />
<br />
<br />
== Example ==<br />
<br />
<br />
Now to access, say the regular warnock font, the following are valid. And I ought to mention that Hans recommends the first http://article.gmane.org/gmane.comp.tex.context/43685.<br />
<br />
<texcode><br />
% Hans recommends this format;<br />
\definefontsynonym [WarnockPro-Regular] [name:warnockproregular] <br />
</texcode><br />
<br />
and<br />
<br />
<texcode><br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular]<br />
</texcode><br />
<br />
An entire typescript would be defined as;<br />
<br />
<texcode><br />
\definefontfeature[latin-smallcaps][smallcaps][script=latn]<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\setups[font:fallback:sans]<br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular] <br />
\definefontsynonym [WarnockPro-Bold] [name:WarnockPro-Bold] <br />
\definefontsynonym [WarnockPro-Italic] [name:WarnockPro-It] <br />
\definefontsynonym [WarnockPro-BoldItalic] [name:WarnockPro-BoldIt] <br />
\stoptypescript<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\definefontsynonym [Serif] [WarnockPro-Regular] [features=default]<br />
\definefontsynonym [SerifBold] [WarnockPro-Bold] [features=default]<br />
\definefontsynonym [SerifItalic] [WarnockPro-Italic] [features=default]<br />
\definefontsynonym [SerifBoldItalic] [WarnockPro-BoldItalic] [features=default]<br />
\definefontsynonym [SerifCaps] [Serif] [features=latin-smallcaps]<br />
\stoptypescript<br />
<br />
\definetypeface[adobe][rm][serif][warnockpro][default]<br />
\setupbodyfont[adobe,11pt]<br />
<br />
</texcode><br />
<br />
[[Category:Fonts]]<br />
[[Category:International]]</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Fonts_in_LuaTeX&diff=10262Fonts in LuaTeX2010-01-19T14:46:03Z<p>Nicolas Girard: /* With the simplefonts module */ Added "Installing simplefonts"</p>
<hr />
<div>{{note|This page is not finished yet}}<br />
<br />
'''Please, someone, fill this page !'''<br />
<br />
'''This page is beeing regorganized'''<br />
<br />
= Getting access to the system fonts =<br />
<br />
LuaTeX can use non-TeX fonts (in OpenType, TrueType or Type1 format) directly.<br />
<br />
The first time that you run<br />
<br />
context myfile.tex<br />
<br />
on a file that uses such non-traditional fonts (which is probably always), the actual fonts themselves have to be loaded in luatex's embedded section of fontforge to extract their metric information. This removes the need for tfm and vf files on your disk, but it is also a somewhat lengthy and often memory-hungry process.<br />
<br />
That is why the results of that internal preprocessing are also saved inside the texmf cache. Future runs using the same font (not just this file, but all files using that particular font) can then use the cached version of the metrics instead. <br />
<br />
== Building the font database ==<br />
<br />
You need to specify where the fonts should be looked for, by setting the <code>OSFONTDIR</code> environment variable. For instance,<br />
set OSFONTDIR=c:/windows/fonts/<br />
if the fonts should be found in <code>c:/windows/fonts/</code>; or<br />
export OSFONTDIR="/usr/local/share/fonts;$HOME/.fonts"<br />
if the fonts should be found in both <code>/usr/local/share/fonts</code> and <code>$HOME/.fonts</code>.<br />
<br />
The font database will then be automatically generated in the next run of <code>context</code><br />
<br />
You can also generate it manually by typing <br />
mtxrun --script font --reload<br />
or equally<br />
mtxrun --script fonts --reload<br />
<br />
The output should look like<br />
MTXrun | fontnames: identifying tree font files with suffix otf<br />
MTXrun | fontnames: identifying tree font files with suffix OTF<br />
MTXrun | fontnames: 331 tree files identified, 332 hash entries added, runtime 7.653 seconds<br />
MTXrun | fontnames: identifying tree font files with suffix ttf<br />
MTXrun | fontnames: identifying tree font files with suffix TTF<br />
MTXrun | fontnames: 17 tree files identified, 14 hash entries added, runtime 4.645 seconds<br />
...<br />
MTXrun | fontnames: 94 system files identified, 94 hash entries added, runtime 0.554 seconds<br />
MTXrun | fontnames: 3837 files read, 3342 normal and 49 extra entries added, 5 rejected, 3386 valid<br />
<br />
<br />
<br />
== Querying the font database ==<br />
<br />
The command<br />
mtxrun --script fonts --list<br />
will return the whole entries of the font database as a list, such as<br />
<br />
...<br />
warnockprobold WarnockPro-Bold E:/Fonts/Warnock Pro/WarnockPro-Bold.otf<br />
warnockproboldcapt WarnockPro-BoldCapt E:/Fonts/Warnock Pro/WarnockPro-BoldCapt.otf<br />
warnockprobolddisp WarnockPro-BoldDisp E:/Fonts/Warnock Pro/WarnockPro-BoldDisp.otf<br />
warnockproboldit WarnockPro-BoldIt E:/Fonts/Warnock Pro/WarnockPro-BoldIt.otf<br />
warnockprobolditcapt WarnockPro-BoldItCapt E:/Fonts/Warnock Pro/WarnockPro-BoldItCapt.otf<br />
warnockprobolditdisp WarnockPro-BoldItDisp E:/Fonts/Warnock Pro/WarnockPro-BoldItDisp.otf<br />
warnockprobolditsubh WarnockPro-BoldItSubh E:/Fonts/Warnock Pro/WarnockPro-BoldItSubh.otf<br />
warnockproboldsubh WarnockPro-BoldSubh E:/Fonts/Warnock Pro/WarnockPro-BoldSubh.otf<br />
...<br />
<br />
You can query the database against a particular pattern. For instance,<br />
mtxrun --script fonts --list --pattern=Delicious*<br />
will return<br />
deliciousbold Delicious-Bold /usr/local/share/fonts/d/delicious_bold.otf<br />
deliciousbolditalic Delicious-BoldItalic /usr/local/share/fonts/d/delicious_bolditalic.otf<br />
deliciousheavy Delicious-Heavy /usr/local/share/fonts/d/delicious_heavy.otf<br />
deliciousitalic Delicious-Italic /usr/local/share/fonts/d/delicious_italic.otf<br />
deliciousroman Delicious-Roman /usr/local/share/fonts/d/delicious_roman.otf<br />
delicioussmallcaps Delicious-SmallCaps /usr/local/share/fonts/d/delicious_smallcaps.otf<br />
<br />
You can get useful informations about your fonts by using the <code>--info</code> option. For instance,<br />
mtxrun --script fonts --list --info --pattern=Delicious*Roman<br />
will return<br />
MTXrun | fontname: deliciousroman<br />
MTXrun | fullname: Delicious-Roman<br />
MTXrun | filename: /usr/local/share/fonts/d/delicious_roman.otf<br />
MTXrun |<br />
MTXrun | gpos features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | kern latn dflt<br />
MTXrun |<br />
MTXrun | gsub features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | tlig all all<br />
MTXrun | trep all all<br />
<br />
== Installing new fonts ==<br />
<br />
After installing new fonts, the font database must be rebuilt for LuaTeX to access them.<br />
<br />
In current versions of Mark IV (earlier than July 2008) this is automatically done whenever a named font cannot be found.<br />
<br />
You only have to do the reload manually when you have installed updates to already installed fonts that cause the font and/or file names to change. <br />
This normally only happens for fonts that are still in development like [[TeX Gyre]] and [[Latin Modern]].<br />
<br />
You can rebuild the database manually, using the already-mentioned command<br />
mtxrun --script fonts --reload<br />
<br />
Alternatively, you can turn off the automatic rebuild of the database, by setting either of<br />
MTX.FONTS.AUTOLOAD<br />
MTX_FONTS_AUTOLOAD<br />
to "no".<br />
<br />
== References ==<br />
<br />
[http://context.aanhet.net/svn/contextman/context-reference/en/co-fonts.pdf The new manual chapter on fonts]<br />
<br />
= Using fonts =<br />
<br />
Handling fonts in LuaTeX can be done<br />
* in a simple but limited way, using the <code>simplefonts</code> module;<br />
* in the standard way, using [[TypeScripts]]<br />
<br />
== With the <code>simplefonts</code> module ==<br />
<br />
[http://www.ctan.org/tex-archive/macros/context/contrib/context-simplefonts simplefonts] is a third-party module written by Wolfgang Schuster.<br />
<br />
It simplifies the use of fonts in LuaTeX by<br />
* freeing the user from writing or using [[TypeScripts]];<br />
* offering an interface similar to the [http://www.ctan.org/tex-archive/macros/xetex/latex/fontspec/ fontspec package for XeTeX]<br />
<br />
For instance, assuming the [http://www.josbuivenga.demon.nl/delicious.html Delicious fonts] are properly installed and recognized by ConTeXt, you can simply write:<br />
<br />
<texcode><br />
\usemodule[simplefonts] % load the module<br />
\setmainfont[Delicious] % set Delicious as main (serif) font<br />
<br />
\starttext<br />
\rm\tf roman \it italic \bf bold \bi bolditalic \sc smallcaps<br />
\stoptext<br />
</texcode><br />
<br />
=== Installing <code>simplefonts</code> ===<br />
<br />
* If you're using LuaTeX along with TeXlive 2009, <code>simplefonts</code> is already installed<br />
* If you're running [[ConTeXt Minimals]], <code>simplefonts</code> can be installed like [http://wiki.contextgarden.net/ConTeXt_Minimals#Installing_third_party_modules any third-party module]:<br />
first-setup.sh --extras="t-simplefonts"<br />
<br />
== The standard way: Typescripts ==<br />
<br />
=== Installing typescripts ===<br />
<br />
Installing typescripts consists in the following:<br />
<br />
1. Copy the typescript files into either <br />
<texcode>$TEXMF/tex/texmf-fonts/tex/context/user<br />
$TEXMF/tex/texmf-project/tex/context/user</texcode><br />
2. Run <code>context --generate</code><br />
<br />
By convention, typescript files are named like <code>type-(fontname|foundry).tex</code>. <br />
<br />
It may happen that some <code>type-xx.tex</code> typescript file depends on mkiv-specific code located in a matching <code>type-xx.mkiv</code> file. In this case, both files need to be installed.<br />
<br />
=== Loading typescripts ===<br />
<br />
A typescript file named <code>type-xx.tex</code> should be loaded using<br />
\usetypescriptfile[type-xx]<br />
<br />
An alternative way is<br />
\usetypefile[xx]<br />
where ConTeXt prepends <code>type-</code> when it loads the file; but <br />
<cmd>usetypescriptfile</cmd> is the preferred command because it takes care of the<br />
<cmd>starttypescriptcollection</cmd>/<cmd>stoptypescriptcollection</cmd> environments.<br />
<br />
=== Where to find existing typescripts ===<br />
<br />
Each of the typescripts below defines a keyword to use with <cmd>setupbodyfont</cmd>. Usually this is the same as the name of the typescript, but there is one exception (<code>antykwa-torunska</code>)<br />
<br />
* Latin Modern (typescript name: <code>modern</code>; this is the default font set)<br />
* Latin Modern variant (ts name: <code>modernvariable</code>; LM variable typewriter for serif)<br />
* Postscript (ts name: <code>postscript</code>; Termes for serif, Heros for sans, Cursor for mono)<br />
* Antykwa Toruńska (ts name: <code>antykwa-torunska</code>; only serif; defines <tt>antykwa</tt> as keyword for <cmd>setupbodyfont</cmd>)<br />
* Iwona (ts name: <code>iwona</code>; only sans serif)<br />
* Iwona Light, Medium and Heavy (ts names: <code>iwona-light</code>, <code>iwona-medium</code>, <code>iwona-heavy</code>; only sans; the medium variant is a small bit heavier than a "regular" one)<br />
* Pagella (ts name: <code>palatino</code>; only serif)<br />
* Termes (ts name: <code>times</code>; only serif, Heros for sans)<br />
<br />
=== Usage example ===<br />
<br />
<texcode><br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,18pt]<br />
<br />
\starttext<br />
Hello world, I'm Pagella!<br />
\stoptext<br />
</texcode><br />
<br />
The first line seems to order ConTeXt to "install" (for the current file) the given typescript (it accepts what I have earlier called a "typescript name"). The last one starts using it (you may omit the size if you are satisfied with the default).<br />
<br />
=== Combining predefined fonts in your own typescripts ===<br />
<br />
It is also possible to combine fonts from the TeX Gyre collection in your own typescripts. The example below combines Bonum (Bookman) roman, Adventor (AvantGarde) for sans serif, Cursor (Courier) for teletype, and Euler for math. The <code>rscale=...</code> option ensures that all fonts have the same x-height. (You can lookup the relative x-heigt of a font using fontforge.)<br />
<br />
<texcode><br />
\starttypescript [Bonum]<br />
\definetypeface [Bonum] [rm] [serif] [bonum] [default]<br />
\definetypeface [Bonum] [ss] [sans] [adventor] [default] [rscale=0.887]<br />
\definetypeface [Bonum] [tt] [mono] [cursor] [default] [rscale=1.163]<br />
\definetypeface [Bonum] [mm] [math] [euler] [default] [rscale=1.050]<br />
\stoptypescript<br />
<br />
\usetypescript[Bonum]<br />
\setupbodyfont[Bonum,12pt]<br />
<br />
\starttext<br />
Hello world, I'm Bonum!<br />
\stoptext<br />
</texcode><br />
<br />
= Old contents =<br />
<br />
* [[TrueType fonts in luaTeX]]<br />
<br />
==== Good ol' typescripts ====<br />
<br />
Of course, Mark IV allows you to use typescripts as you've always done; for example:<br />
<br />
<texcode><br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,12pt]<br />
effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
<br />
\sc effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
</texcode><br />
<br />
That's as simple as using a traditional ConTeXt typescript!<br />
<br />
But ... how is it any different, then? Well, the difference is that in Mark IV, we can use an Opentype font directly, so that what is done here: when we want to use Palatino, the [[TeX Gyre]] equivalent (“Pagella”) is called and we can use its Opentype “features”; read on.<br />
<br />
==== Opentype features ====<br />
<br />
A “feature”, in the Opentype jargon, is a set of rules describing changes in the appearance of the text. Hmm, that's not very precise. Let's show some examples. First of all, you have to know that features are referred to by 4-letter tags, and you will see this a lot. One of them is ‘smcp‘, for “small caps“. Let's consider the following Mark IV-only code:<br />
<br />
<texcode><br />
\definefontfeature[smallcaps][language=DFLT,script=latn,smcp=yes]<br />
\font\palasmallcaps=texgyrepagella-regular*smallcaps<br />
\palasmallcaps This is a text in small capitals.<br />
</texcode><br />
<br />
Here you basically define a (Mark IV) feature with the name ”smallcaps”, and associate it with the (Opentype) feature “smcp”. You have to specify which script you want to use it with; scripts in Opentype are also tagged with four letters, and “latn” is of course Latin.<br />
<br />
Then you define a TeX font with that feature.<br />
<br />
You can see what features are defined in a particular font with the following bit of code<br />
<br />
<texcode><br />
\ctxlua<br />
{<br />
fontname = 'texgyrepagella-regular.otf'<br />
<br />
--[[ First read the font data.<br />
This makes heavy use of some of the Mark IV code]]<br />
tfmdata = fonts.tfm.read_and_define("file:" .. fontname, 655360)<br />
font = tfmdata.shared.otfdata<br />
if font<br />
then<br />
gsubfeatures = fonts.otf.analyze_features(font.gsub)<br />
gposfeatures = fonts.otf.analyze_features(font.gpos)<br />
end<br />
<br />
if gsubfeatures then<br />
table.sort(gsubfeatures) % We want our list sorted alphabetically!<br />
tex.sprint("\\rm GSUB features: \\tt ") % Beware: you don't want \rm to be interpreted by lua (\rm would yield carriage return + letter m)!<br />
for _, feat in ipairs(gsubfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GSUB features")<br />
end<br />
tex.sprint("\\par")<br />
<br />
if gposfeatures then<br />
tex.sprint("\\rm GPOS features: \\tt ")<br />
table.sort(gposfeatures)<br />
for _, feat in ipairs(gposfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GPOS features")<br />
end<br />
}<br />
</texcode><br />
<br />
It prints the list on the page. You'll notice there are two sets of features, each one of them defined in a different table of the Opentype font: the <code>GSUB</code> table (for Glyph SUBstitution) gives rules for replacing glyphs in certains circumstances (think of ligatures: f + i -> fi); the <code>GPOS</code> table (Glyph POSititioning) gives rules for moving glyphs (think of kerning: A + V -> A <kerning> V).<br />
<br />
Incidentally, the above code gives some basic examples of LuaTeX programming, a mixture of both Lua and TeX programming with some special features (features in the general sense, not the Opentype one :-).<br />
<br />
==== A (Complete) Typescript Example ====<br />
<br />
<texcode><br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [FranklinBookRegular] [name:FranklinGothicBookITC-Regular] [features=default]<br />
\definefontsynonym [FranklinMediumRegular] [name:FranklinGothicMediumITC-Regular] [features=default]<br />
\definefontsynonym [FranklinDemiRegular] [name:FranklinGothicDemiITC-Regular] [features=default]<br />
\definefontsynonym [FranklinHeavyRegular] [name:FranklinGothicHeavyITC-Regular] [features=default]<br />
<br />
\definefontsynonym [FranklinBookItalic] [name:FranklinGothicBookITC-Italic] [features=default]<br />
\definefontsynonym [FranklinDemiItalic] [name:FranklinGothicMediumITC-Italic] [features=default]<br />
\definefontsynonym [FranklinHeavyItalic] [name:FranklinGothicDemiITC-Italic] [features=default]<br />
\definefontsynonym [FranklinMediumItalic] [name:FranklinGothicHeavyITC-Italic] [features=default]<br />
<br />
\stoptypescript<br />
<br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [Sans] [FranklinBookRegular] [features=default]<br />
\definefontsynonym [SansItalic] [FranklinBookItalic] [features=default]<br />
\definefontsynonym [SansBold] [FranklinDemiRegular] [features=default]<br />
\definefontsynonym [SansBoldItalic] [FranklinDemiItalic] [features=default]<br />
\definefontsynonym [SansSlanted] [SansItalic] [features=default]<br />
\definefontsynonym [SansBoldSlanted] [SansBoldItalic] [features=default]<br />
\definefontsynonym [SansCaps] [Sans] [features=smallcaps]<br />
<br />
\stoptypescript<br />
<br />
\definetypeface[franklin][rm][sans][franklin][default]<br />
\definetypeface[franklin][ss][sans][franklin][default]<br />
\definetypeface[franklin][tt][mono][modern] [default][rscale=1.12]<br />
\definetypeface[franklin][mm][math][iwona] [default][rscale=1.02]<br />
<br />
\setupbodyfont[franklin,ss,10pt]<br />
</texcode><br />
<br />
<br />
<br />
Just the simplest way to use an otf font — or any font that does appear in <tt>mtxrun --script font --list</tt> — in all the document.<br />
<br />
I’m stick here :<br />
<br />
\definefontfeature [myfontfeature] [method=node, kern=yes, OTHER_FEATURE_COMMA_SEPERATED]<br />
\definefontsynonym [MyFontRegular] [name:TheFontName-Regular][features=myfontfeature]<br />
\definedfont [MyFontRegular at 16pt]<br />
<br />
This doesn’t run for my title which use « \tfc », only for the body of the text.<br />
<br />
*\definefontfeature<br />
**[myfontfeature] : you can use the name you want. It will be use at the next line ;<br />
**the fonts feature can be found with <tt>otfinfo -f TheFontFile.otf</tt>.<br />
*\definefontsynonym :<br />
**[MyFontRegular] : you can use the name you want. It will be use at the next line ;<br />
**The name after <tt>name:</tt> is the name given by <tt>mtxrun --script font --list</tt><br />
**The « name: » part can be replaced by <tt>file:TheFontFile.otf</tt><br />
<br />
<br />
== Example ==<br />
<br />
<br />
Now to access, say the regular warnock font, the following are valid. And I ought to mention that Hans recommends the first http://article.gmane.org/gmane.comp.tex.context/43685.<br />
<br />
<texcode><br />
% Hans recommends this format;<br />
\definefontsynonym [WarnockPro-Regular] [name:warnockproregular] <br />
</texcode><br />
<br />
and<br />
<br />
<texcode><br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular]<br />
</texcode><br />
<br />
An entire typescript would be defined as;<br />
<br />
<texcode><br />
\definefontfeature[latin-smallcaps][smallcaps][script=latn]<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\setups[font:fallback:sans]<br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular] <br />
\definefontsynonym [WarnockPro-Bold] [name:WarnockPro-Bold] <br />
\definefontsynonym [WarnockPro-Italic] [name:WarnockPro-It] <br />
\definefontsynonym [WarnockPro-BoldItalic] [name:WarnockPro-BoldIt] <br />
\stoptypescript<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\definefontsynonym [Serif] [WarnockPro-Regular] [features=default]<br />
\definefontsynonym [SerifBold] [WarnockPro-Bold] [features=default]<br />
\definefontsynonym [SerifItalic] [WarnockPro-Italic] [features=default]<br />
\definefontsynonym [SerifBoldItalic] [WarnockPro-BoldItalic] [features=default]<br />
\definefontsynonym [SerifCaps] [Serif] [features=latin-smallcaps]<br />
\stoptypescript<br />
<br />
\definetypeface[adobe][rm][serif][warnockpro][default]<br />
\setupbodyfont[adobe,11pt]<br />
<br />
</texcode><br />
<br />
[[Category:Fonts]]<br />
[[Category:International]]</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Fonts_in_LuaTeX&diff=10261Fonts in LuaTeX2010-01-19T14:04:50Z<p>Nicolas Girard: /* With the simplefonts module */ Added link to simplefonts on CTAN</p>
<hr />
<div>{{note|This page is not finished yet}}<br />
<br />
'''Please, someone, fill this page !'''<br />
<br />
'''This page is beeing regorganized'''<br />
<br />
= Getting access to the system fonts =<br />
<br />
LuaTeX can use non-TeX fonts (in OpenType, TrueType or Type1 format) directly.<br />
<br />
The first time that you run<br />
<br />
context myfile.tex<br />
<br />
on a file that uses such non-traditional fonts (which is probably always), the actual fonts themselves have to be loaded in luatex's embedded section of fontforge to extract their metric information. This removes the need for tfm and vf files on your disk, but it is also a somewhat lengthy and often memory-hungry process.<br />
<br />
That is why the results of that internal preprocessing are also saved inside the texmf cache. Future runs using the same font (not just this file, but all files using that particular font) can then use the cached version of the metrics instead. <br />
<br />
== Building the font database ==<br />
<br />
You need to specify where the fonts should be looked for, by setting the <code>OSFONTDIR</code> environment variable. For instance,<br />
set OSFONTDIR=c:/windows/fonts/<br />
if the fonts should be found in <code>c:/windows/fonts/</code>; or<br />
export OSFONTDIR="/usr/local/share/fonts;$HOME/.fonts"<br />
if the fonts should be found in both <code>/usr/local/share/fonts</code> and <code>$HOME/.fonts</code>.<br />
<br />
The font database will then be automatically generated in the next run of <code>context</code><br />
<br />
You can also generate it manually by typing <br />
mtxrun --script font --reload<br />
or equally<br />
mtxrun --script fonts --reload<br />
<br />
The output should look like<br />
MTXrun | fontnames: identifying tree font files with suffix otf<br />
MTXrun | fontnames: identifying tree font files with suffix OTF<br />
MTXrun | fontnames: 331 tree files identified, 332 hash entries added, runtime 7.653 seconds<br />
MTXrun | fontnames: identifying tree font files with suffix ttf<br />
MTXrun | fontnames: identifying tree font files with suffix TTF<br />
MTXrun | fontnames: 17 tree files identified, 14 hash entries added, runtime 4.645 seconds<br />
...<br />
MTXrun | fontnames: 94 system files identified, 94 hash entries added, runtime 0.554 seconds<br />
MTXrun | fontnames: 3837 files read, 3342 normal and 49 extra entries added, 5 rejected, 3386 valid<br />
<br />
<br />
<br />
== Querying the font database ==<br />
<br />
The command<br />
mtxrun --script fonts --list<br />
will return the whole entries of the font database as a list, such as<br />
<br />
...<br />
warnockprobold WarnockPro-Bold E:/Fonts/Warnock Pro/WarnockPro-Bold.otf<br />
warnockproboldcapt WarnockPro-BoldCapt E:/Fonts/Warnock Pro/WarnockPro-BoldCapt.otf<br />
warnockprobolddisp WarnockPro-BoldDisp E:/Fonts/Warnock Pro/WarnockPro-BoldDisp.otf<br />
warnockproboldit WarnockPro-BoldIt E:/Fonts/Warnock Pro/WarnockPro-BoldIt.otf<br />
warnockprobolditcapt WarnockPro-BoldItCapt E:/Fonts/Warnock Pro/WarnockPro-BoldItCapt.otf<br />
warnockprobolditdisp WarnockPro-BoldItDisp E:/Fonts/Warnock Pro/WarnockPro-BoldItDisp.otf<br />
warnockprobolditsubh WarnockPro-BoldItSubh E:/Fonts/Warnock Pro/WarnockPro-BoldItSubh.otf<br />
warnockproboldsubh WarnockPro-BoldSubh E:/Fonts/Warnock Pro/WarnockPro-BoldSubh.otf<br />
...<br />
<br />
You can query the database against a particular pattern. For instance,<br />
mtxrun --script fonts --list --pattern=Delicious*<br />
will return<br />
deliciousbold Delicious-Bold /usr/local/share/fonts/d/delicious_bold.otf<br />
deliciousbolditalic Delicious-BoldItalic /usr/local/share/fonts/d/delicious_bolditalic.otf<br />
deliciousheavy Delicious-Heavy /usr/local/share/fonts/d/delicious_heavy.otf<br />
deliciousitalic Delicious-Italic /usr/local/share/fonts/d/delicious_italic.otf<br />
deliciousroman Delicious-Roman /usr/local/share/fonts/d/delicious_roman.otf<br />
delicioussmallcaps Delicious-SmallCaps /usr/local/share/fonts/d/delicious_smallcaps.otf<br />
<br />
You can get useful informations about your fonts by using the <code>--info</code> option. For instance,<br />
mtxrun --script fonts --list --info --pattern=Delicious*Roman<br />
will return<br />
MTXrun | fontname: deliciousroman<br />
MTXrun | fullname: Delicious-Roman<br />
MTXrun | filename: /usr/local/share/fonts/d/delicious_roman.otf<br />
MTXrun |<br />
MTXrun | gpos features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | kern latn dflt<br />
MTXrun |<br />
MTXrun | gsub features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | tlig all all<br />
MTXrun | trep all all<br />
<br />
== Installing new fonts ==<br />
<br />
After installing new fonts, the font database must be rebuilt for LuaTeX to access them.<br />
<br />
In current versions of Mark IV (earlier than July 2008) this is automatically done whenever a named font cannot be found.<br />
<br />
You only have to do the reload manually when you have installed updates to already installed fonts that cause the font and/or file names to change. <br />
This normally only happens for fonts that are still in development like [[TeX Gyre]] and [[Latin Modern]].<br />
<br />
You can rebuild the database manually, using the already-mentioned command<br />
mtxrun --script fonts --reload<br />
<br />
Alternatively, you can turn off the automatic rebuild of the database, by setting either of<br />
MTX.FONTS.AUTOLOAD<br />
MTX_FONTS_AUTOLOAD<br />
to "no".<br />
<br />
== References ==<br />
<br />
[http://context.aanhet.net/svn/contextman/context-reference/en/co-fonts.pdf The new manual chapter on fonts]<br />
<br />
= Using fonts =<br />
<br />
Handling fonts in LuaTeX can be done<br />
* in a simple but limited way, using the <code>simplefonts</code> module;<br />
* in the standard way, using [[TypeScripts]]<br />
<br />
== With the <code>simplefonts</code> module ==<br />
<br />
[http://www.ctan.org/tex-archive/macros/context/contrib/context-simplefonts simplefonts] is a third-party module written by Wolfgang Schuster.<br />
<br />
It simplifies the use of fonts in LuaTeX by<br />
* freeing the user from writing or using [[TypeScripts]];<br />
* offering an interface similar to the [http://www.ctan.org/tex-archive/macros/xetex/latex/fontspec/ fontspec package for XeTeX]<br />
<br />
For instance, assuming the [http://www.josbuivenga.demon.nl/delicious.html Delicious fonts] are properly installed and recognized by ConTeXt, you can simply write:<br />
<br />
<texcode><br />
\usemodule[simplefonts] % load the module<br />
\setmainfont[Delicious] % set Delicious as main (serif) font<br />
<br />
\starttext<br />
\rm\tf roman \it italic \bf bold \bi bolditalic \sc smallcaps<br />
\stoptext<br />
</texcode><br />
<br />
== The standard way: Typescripts ==<br />
<br />
=== Installing typescripts ===<br />
<br />
Installing typescripts consists in the following:<br />
<br />
1. Copy the typescript files into either <br />
<texcode>$TEXMF/tex/texmf-fonts/tex/context/user<br />
$TEXMF/tex/texmf-project/tex/context/user</texcode><br />
2. Run <code>context --generate</code><br />
<br />
By convention, typescript files are named like <code>type-(fontname|foundry).tex</code>. <br />
<br />
It may happen that some <code>type-xx.tex</code> typescript file depends on mkiv-specific code located in a matching <code>type-xx.mkiv</code> file. In this case, both files need to be installed.<br />
<br />
=== Loading typescripts ===<br />
<br />
A typescript file named <code>type-xx.tex</code> should be loaded using<br />
\usetypescriptfile[type-xx]<br />
<br />
An alternative way is<br />
\usetypefile[xx]<br />
where ConTeXt prepends <code>type-</code> when it loads the file; but <br />
<cmd>usetypescriptfile</cmd> is the preferred command because it takes care of the<br />
<cmd>starttypescriptcollection</cmd>/<cmd>stoptypescriptcollection</cmd> environments.<br />
<br />
=== Where to find existing typescripts ===<br />
<br />
Each of the typescripts below defines a keyword to use with <cmd>setupbodyfont</cmd>. Usually this is the same as the name of the typescript, but there is one exception (<code>antykwa-torunska</code>)<br />
<br />
* Latin Modern (typescript name: <code>modern</code>; this is the default font set)<br />
* Latin Modern variant (ts name: <code>modernvariable</code>; LM variable typewriter for serif)<br />
* Postscript (ts name: <code>postscript</code>; Termes for serif, Heros for sans, Cursor for mono)<br />
* Antykwa Toruńska (ts name: <code>antykwa-torunska</code>; only serif; defines <tt>antykwa</tt> as keyword for <cmd>setupbodyfont</cmd>)<br />
* Iwona (ts name: <code>iwona</code>; only sans serif)<br />
* Iwona Light, Medium and Heavy (ts names: <code>iwona-light</code>, <code>iwona-medium</code>, <code>iwona-heavy</code>; only sans; the medium variant is a small bit heavier than a "regular" one)<br />
* Pagella (ts name: <code>palatino</code>; only serif)<br />
* Termes (ts name: <code>times</code>; only serif, Heros for sans)<br />
<br />
=== Usage example ===<br />
<br />
<texcode><br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,18pt]<br />
<br />
\starttext<br />
Hello world, I'm Pagella!<br />
\stoptext<br />
</texcode><br />
<br />
The first line seems to order ConTeXt to "install" (for the current file) the given typescript (it accepts what I have earlier called a "typescript name"). The last one starts using it (you may omit the size if you are satisfied with the default).<br />
<br />
=== Combining predefined fonts in your own typescripts ===<br />
<br />
It is also possible to combine fonts from the TeX Gyre collection in your own typescripts. The example below combines Bonum (Bookman) roman, Adventor (AvantGarde) for sans serif, Cursor (Courier) for teletype, and Euler for math. The <code>rscale=...</code> option ensures that all fonts have the same x-height. (You can lookup the relative x-heigt of a font using fontforge.)<br />
<br />
<texcode><br />
\starttypescript [Bonum]<br />
\definetypeface [Bonum] [rm] [serif] [bonum] [default]<br />
\definetypeface [Bonum] [ss] [sans] [adventor] [default] [rscale=0.887]<br />
\definetypeface [Bonum] [tt] [mono] [cursor] [default] [rscale=1.163]<br />
\definetypeface [Bonum] [mm] [math] [euler] [default] [rscale=1.050]<br />
\stoptypescript<br />
<br />
\usetypescript[Bonum]<br />
\setupbodyfont[Bonum,12pt]<br />
<br />
\starttext<br />
Hello world, I'm Bonum!<br />
\stoptext<br />
</texcode><br />
<br />
= Old contents =<br />
<br />
* [[TrueType fonts in luaTeX]]<br />
<br />
==== Good ol' typescripts ====<br />
<br />
Of course, Mark IV allows you to use typescripts as you've always done; for example:<br />
<br />
<texcode><br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,12pt]<br />
effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
<br />
\sc effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
</texcode><br />
<br />
That's as simple as using a traditional ConTeXt typescript!<br />
<br />
But ... how is it any different, then? Well, the difference is that in Mark IV, we can use an Opentype font directly, so that what is done here: when we want to use Palatino, the [[TeX Gyre]] equivalent (“Pagella”) is called and we can use its Opentype “features”; read on.<br />
<br />
==== Opentype features ====<br />
<br />
A “feature”, in the Opentype jargon, is a set of rules describing changes in the appearance of the text. Hmm, that's not very precise. Let's show some examples. First of all, you have to know that features are referred to by 4-letter tags, and you will see this a lot. One of them is ‘smcp‘, for “small caps“. Let's consider the following Mark IV-only code:<br />
<br />
<texcode><br />
\definefontfeature[smallcaps][language=DFLT,script=latn,smcp=yes]<br />
\font\palasmallcaps=texgyrepagella-regular*smallcaps<br />
\palasmallcaps This is a text in small capitals.<br />
</texcode><br />
<br />
Here you basically define a (Mark IV) feature with the name ”smallcaps”, and associate it with the (Opentype) feature “smcp”. You have to specify which script you want to use it with; scripts in Opentype are also tagged with four letters, and “latn” is of course Latin.<br />
<br />
Then you define a TeX font with that feature.<br />
<br />
You can see what features are defined in a particular font with the following bit of code<br />
<br />
<texcode><br />
\ctxlua<br />
{<br />
fontname = 'texgyrepagella-regular.otf'<br />
<br />
--[[ First read the font data.<br />
This makes heavy use of some of the Mark IV code]]<br />
tfmdata = fonts.tfm.read_and_define("file:" .. fontname, 655360)<br />
font = tfmdata.shared.otfdata<br />
if font<br />
then<br />
gsubfeatures = fonts.otf.analyze_features(font.gsub)<br />
gposfeatures = fonts.otf.analyze_features(font.gpos)<br />
end<br />
<br />
if gsubfeatures then<br />
table.sort(gsubfeatures) % We want our list sorted alphabetically!<br />
tex.sprint("\\rm GSUB features: \\tt ") % Beware: you don't want \rm to be interpreted by lua (\rm would yield carriage return + letter m)!<br />
for _, feat in ipairs(gsubfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GSUB features")<br />
end<br />
tex.sprint("\\par")<br />
<br />
if gposfeatures then<br />
tex.sprint("\\rm GPOS features: \\tt ")<br />
table.sort(gposfeatures)<br />
for _, feat in ipairs(gposfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GPOS features")<br />
end<br />
}<br />
</texcode><br />
<br />
It prints the list on the page. You'll notice there are two sets of features, each one of them defined in a different table of the Opentype font: the <code>GSUB</code> table (for Glyph SUBstitution) gives rules for replacing glyphs in certains circumstances (think of ligatures: f + i -> fi); the <code>GPOS</code> table (Glyph POSititioning) gives rules for moving glyphs (think of kerning: A + V -> A <kerning> V).<br />
<br />
Incidentally, the above code gives some basic examples of LuaTeX programming, a mixture of both Lua and TeX programming with some special features (features in the general sense, not the Opentype one :-).<br />
<br />
==== A (Complete) Typescript Example ====<br />
<br />
<texcode><br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [FranklinBookRegular] [name:FranklinGothicBookITC-Regular] [features=default]<br />
\definefontsynonym [FranklinMediumRegular] [name:FranklinGothicMediumITC-Regular] [features=default]<br />
\definefontsynonym [FranklinDemiRegular] [name:FranklinGothicDemiITC-Regular] [features=default]<br />
\definefontsynonym [FranklinHeavyRegular] [name:FranklinGothicHeavyITC-Regular] [features=default]<br />
<br />
\definefontsynonym [FranklinBookItalic] [name:FranklinGothicBookITC-Italic] [features=default]<br />
\definefontsynonym [FranklinDemiItalic] [name:FranklinGothicMediumITC-Italic] [features=default]<br />
\definefontsynonym [FranklinHeavyItalic] [name:FranklinGothicDemiITC-Italic] [features=default]<br />
\definefontsynonym [FranklinMediumItalic] [name:FranklinGothicHeavyITC-Italic] [features=default]<br />
<br />
\stoptypescript<br />
<br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [Sans] [FranklinBookRegular] [features=default]<br />
\definefontsynonym [SansItalic] [FranklinBookItalic] [features=default]<br />
\definefontsynonym [SansBold] [FranklinDemiRegular] [features=default]<br />
\definefontsynonym [SansBoldItalic] [FranklinDemiItalic] [features=default]<br />
\definefontsynonym [SansSlanted] [SansItalic] [features=default]<br />
\definefontsynonym [SansBoldSlanted] [SansBoldItalic] [features=default]<br />
\definefontsynonym [SansCaps] [Sans] [features=smallcaps]<br />
<br />
\stoptypescript<br />
<br />
\definetypeface[franklin][rm][sans][franklin][default]<br />
\definetypeface[franklin][ss][sans][franklin][default]<br />
\definetypeface[franklin][tt][mono][modern] [default][rscale=1.12]<br />
\definetypeface[franklin][mm][math][iwona] [default][rscale=1.02]<br />
<br />
\setupbodyfont[franklin,ss,10pt]<br />
</texcode><br />
<br />
<br />
<br />
Just the simplest way to use an otf font — or any font that does appear in <tt>mtxrun --script font --list</tt> — in all the document.<br />
<br />
I’m stick here :<br />
<br />
\definefontfeature [myfontfeature] [method=node, kern=yes, OTHER_FEATURE_COMMA_SEPERATED]<br />
\definefontsynonym [MyFontRegular] [name:TheFontName-Regular][features=myfontfeature]<br />
\definedfont [MyFontRegular at 16pt]<br />
<br />
This doesn’t run for my title which use « \tfc », only for the body of the text.<br />
<br />
*\definefontfeature<br />
**[myfontfeature] : you can use the name you want. It will be use at the next line ;<br />
**the fonts feature can be found with <tt>otfinfo -f TheFontFile.otf</tt>.<br />
*\definefontsynonym :<br />
**[MyFontRegular] : you can use the name you want. It will be use at the next line ;<br />
**The name after <tt>name:</tt> is the name given by <tt>mtxrun --script font --list</tt><br />
**The « name: » part can be replaced by <tt>file:TheFontFile.otf</tt><br />
<br />
<br />
== Example ==<br />
<br />
<br />
Now to access, say the regular warnock font, the following are valid. And I ought to mention that Hans recommends the first http://article.gmane.org/gmane.comp.tex.context/43685.<br />
<br />
<texcode><br />
% Hans recommends this format;<br />
\definefontsynonym [WarnockPro-Regular] [name:warnockproregular] <br />
</texcode><br />
<br />
and<br />
<br />
<texcode><br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular]<br />
</texcode><br />
<br />
An entire typescript would be defined as;<br />
<br />
<texcode><br />
\definefontfeature[latin-smallcaps][smallcaps][script=latn]<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\setups[font:fallback:sans]<br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular] <br />
\definefontsynonym [WarnockPro-Bold] [name:WarnockPro-Bold] <br />
\definefontsynonym [WarnockPro-Italic] [name:WarnockPro-It] <br />
\definefontsynonym [WarnockPro-BoldItalic] [name:WarnockPro-BoldIt] <br />
\stoptypescript<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\definefontsynonym [Serif] [WarnockPro-Regular] [features=default]<br />
\definefontsynonym [SerifBold] [WarnockPro-Bold] [features=default]<br />
\definefontsynonym [SerifItalic] [WarnockPro-Italic] [features=default]<br />
\definefontsynonym [SerifBoldItalic] [WarnockPro-BoldItalic] [features=default]<br />
\definefontsynonym [SerifCaps] [Serif] [features=latin-smallcaps]<br />
\stoptypescript<br />
<br />
\definetypeface[adobe][rm][serif][warnockpro][default]<br />
\setupbodyfont[adobe,11pt]<br />
<br />
</texcode><br />
<br />
[[Category:Fonts]]<br />
[[Category:International]]</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Fonts_in_LuaTeX&diff=10260Fonts in LuaTeX2010-01-19T13:45:32Z<p>Nicolas Girard: /* Combining predefined fonts in your own typescripts */ Corrected section level</p>
<hr />
<div>{{note|This page is not finished yet}}<br />
<br />
'''Please, someone, fill this page !'''<br />
<br />
'''This page is beeing regorganized'''<br />
<br />
= Getting access to the system fonts =<br />
<br />
LuaTeX can use non-TeX fonts (in OpenType, TrueType or Type1 format) directly.<br />
<br />
The first time that you run<br />
<br />
context myfile.tex<br />
<br />
on a file that uses such non-traditional fonts (which is probably always), the actual fonts themselves have to be loaded in luatex's embedded section of fontforge to extract their metric information. This removes the need for tfm and vf files on your disk, but it is also a somewhat lengthy and often memory-hungry process.<br />
<br />
That is why the results of that internal preprocessing are also saved inside the texmf cache. Future runs using the same font (not just this file, but all files using that particular font) can then use the cached version of the metrics instead. <br />
<br />
== Building the font database ==<br />
<br />
You need to specify where the fonts should be looked for, by setting the <code>OSFONTDIR</code> environment variable. For instance,<br />
set OSFONTDIR=c:/windows/fonts/<br />
if the fonts should be found in <code>c:/windows/fonts/</code>; or<br />
export OSFONTDIR="/usr/local/share/fonts;$HOME/.fonts"<br />
if the fonts should be found in both <code>/usr/local/share/fonts</code> and <code>$HOME/.fonts</code>.<br />
<br />
The font database will then be automatically generated in the next run of <code>context</code><br />
<br />
You can also generate it manually by typing <br />
mtxrun --script font --reload<br />
or equally<br />
mtxrun --script fonts --reload<br />
<br />
The output should look like<br />
MTXrun | fontnames: identifying tree font files with suffix otf<br />
MTXrun | fontnames: identifying tree font files with suffix OTF<br />
MTXrun | fontnames: 331 tree files identified, 332 hash entries added, runtime 7.653 seconds<br />
MTXrun | fontnames: identifying tree font files with suffix ttf<br />
MTXrun | fontnames: identifying tree font files with suffix TTF<br />
MTXrun | fontnames: 17 tree files identified, 14 hash entries added, runtime 4.645 seconds<br />
...<br />
MTXrun | fontnames: 94 system files identified, 94 hash entries added, runtime 0.554 seconds<br />
MTXrun | fontnames: 3837 files read, 3342 normal and 49 extra entries added, 5 rejected, 3386 valid<br />
<br />
<br />
<br />
== Querying the font database ==<br />
<br />
The command<br />
mtxrun --script fonts --list<br />
will return the whole entries of the font database as a list, such as<br />
<br />
...<br />
warnockprobold WarnockPro-Bold E:/Fonts/Warnock Pro/WarnockPro-Bold.otf<br />
warnockproboldcapt WarnockPro-BoldCapt E:/Fonts/Warnock Pro/WarnockPro-BoldCapt.otf<br />
warnockprobolddisp WarnockPro-BoldDisp E:/Fonts/Warnock Pro/WarnockPro-BoldDisp.otf<br />
warnockproboldit WarnockPro-BoldIt E:/Fonts/Warnock Pro/WarnockPro-BoldIt.otf<br />
warnockprobolditcapt WarnockPro-BoldItCapt E:/Fonts/Warnock Pro/WarnockPro-BoldItCapt.otf<br />
warnockprobolditdisp WarnockPro-BoldItDisp E:/Fonts/Warnock Pro/WarnockPro-BoldItDisp.otf<br />
warnockprobolditsubh WarnockPro-BoldItSubh E:/Fonts/Warnock Pro/WarnockPro-BoldItSubh.otf<br />
warnockproboldsubh WarnockPro-BoldSubh E:/Fonts/Warnock Pro/WarnockPro-BoldSubh.otf<br />
...<br />
<br />
You can query the database against a particular pattern. For instance,<br />
mtxrun --script fonts --list --pattern=Delicious*<br />
will return<br />
deliciousbold Delicious-Bold /usr/local/share/fonts/d/delicious_bold.otf<br />
deliciousbolditalic Delicious-BoldItalic /usr/local/share/fonts/d/delicious_bolditalic.otf<br />
deliciousheavy Delicious-Heavy /usr/local/share/fonts/d/delicious_heavy.otf<br />
deliciousitalic Delicious-Italic /usr/local/share/fonts/d/delicious_italic.otf<br />
deliciousroman Delicious-Roman /usr/local/share/fonts/d/delicious_roman.otf<br />
delicioussmallcaps Delicious-SmallCaps /usr/local/share/fonts/d/delicious_smallcaps.otf<br />
<br />
You can get useful informations about your fonts by using the <code>--info</code> option. For instance,<br />
mtxrun --script fonts --list --info --pattern=Delicious*Roman<br />
will return<br />
MTXrun | fontname: deliciousroman<br />
MTXrun | fullname: Delicious-Roman<br />
MTXrun | filename: /usr/local/share/fonts/d/delicious_roman.otf<br />
MTXrun |<br />
MTXrun | gpos features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | kern latn dflt<br />
MTXrun |<br />
MTXrun | gsub features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | tlig all all<br />
MTXrun | trep all all<br />
<br />
== Installing new fonts ==<br />
<br />
After installing new fonts, the font database must be rebuilt for LuaTeX to access them.<br />
<br />
In current versions of Mark IV (earlier than July 2008) this is automatically done whenever a named font cannot be found.<br />
<br />
You only have to do the reload manually when you have installed updates to already installed fonts that cause the font and/or file names to change. <br />
This normally only happens for fonts that are still in development like [[TeX Gyre]] and [[Latin Modern]].<br />
<br />
You can rebuild the database manually, using the already-mentioned command<br />
mtxrun --script fonts --reload<br />
<br />
Alternatively, you can turn off the automatic rebuild of the database, by setting either of<br />
MTX.FONTS.AUTOLOAD<br />
MTX_FONTS_AUTOLOAD<br />
to "no".<br />
<br />
== References ==<br />
<br />
[http://context.aanhet.net/svn/contextman/context-reference/en/co-fonts.pdf The new manual chapter on fonts]<br />
<br />
= Using fonts =<br />
<br />
Handling fonts in LuaTeX can be done<br />
* in a simple but limited way, using the <code>simplefonts</code> module;<br />
* in the standard way, using [[TypeScripts]]<br />
<br />
== With the <code>simplefonts</code> module ==<br />
<br />
<code>simplefonts</code> is a third-party module written by Wolfgang Schuster.<br />
<br />
It simplifies the use of fonts in LuaTeX by<br />
* freeing the user from writing or using [[TypeScripts]];<br />
* offering an interface similar to the [http://www.ctan.org/tex-archive/macros/xetex/latex/fontspec/ fontspec package for XeTeX]<br />
<br />
For instance, assuming the [http://www.josbuivenga.demon.nl/delicious.html Delicious fonts] are properly installed and recognized by ConTeXt, you can simply write:<br />
<br />
<texcode><br />
\usemodule[simplefonts] % load the module<br />
\setmainfont[Delicious] % set Delicious as main (serif) font<br />
<br />
\starttext<br />
\rm\tf roman \it italic \bf bold \bi bolditalic \sc smallcaps<br />
\stoptext<br />
</texcode><br />
<br />
== The standard way: Typescripts ==<br />
<br />
=== Installing typescripts ===<br />
<br />
Installing typescripts consists in the following:<br />
<br />
1. Copy the typescript files into either <br />
<texcode>$TEXMF/tex/texmf-fonts/tex/context/user<br />
$TEXMF/tex/texmf-project/tex/context/user</texcode><br />
2. Run <code>context --generate</code><br />
<br />
By convention, typescript files are named like <code>type-(fontname|foundry).tex</code>. <br />
<br />
It may happen that some <code>type-xx.tex</code> typescript file depends on mkiv-specific code located in a matching <code>type-xx.mkiv</code> file. In this case, both files need to be installed.<br />
<br />
=== Loading typescripts ===<br />
<br />
A typescript file named <code>type-xx.tex</code> should be loaded using<br />
\usetypescriptfile[type-xx]<br />
<br />
An alternative way is<br />
\usetypefile[xx]<br />
where ConTeXt prepends <code>type-</code> when it loads the file; but <br />
<cmd>usetypescriptfile</cmd> is the preferred command because it takes care of the<br />
<cmd>starttypescriptcollection</cmd>/<cmd>stoptypescriptcollection</cmd> environments.<br />
<br />
=== Where to find existing typescripts ===<br />
<br />
Each of the typescripts below defines a keyword to use with <cmd>setupbodyfont</cmd>. Usually this is the same as the name of the typescript, but there is one exception (<code>antykwa-torunska</code>)<br />
<br />
* Latin Modern (typescript name: <code>modern</code>; this is the default font set)<br />
* Latin Modern variant (ts name: <code>modernvariable</code>; LM variable typewriter for serif)<br />
* Postscript (ts name: <code>postscript</code>; Termes for serif, Heros for sans, Cursor for mono)<br />
* Antykwa Toruńska (ts name: <code>antykwa-torunska</code>; only serif; defines <tt>antykwa</tt> as keyword for <cmd>setupbodyfont</cmd>)<br />
* Iwona (ts name: <code>iwona</code>; only sans serif)<br />
* Iwona Light, Medium and Heavy (ts names: <code>iwona-light</code>, <code>iwona-medium</code>, <code>iwona-heavy</code>; only sans; the medium variant is a small bit heavier than a "regular" one)<br />
* Pagella (ts name: <code>palatino</code>; only serif)<br />
* Termes (ts name: <code>times</code>; only serif, Heros for sans)<br />
<br />
=== Usage example ===<br />
<br />
<texcode><br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,18pt]<br />
<br />
\starttext<br />
Hello world, I'm Pagella!<br />
\stoptext<br />
</texcode><br />
<br />
The first line seems to order ConTeXt to "install" (for the current file) the given typescript (it accepts what I have earlier called a "typescript name"). The last one starts using it (you may omit the size if you are satisfied with the default).<br />
<br />
=== Combining predefined fonts in your own typescripts ===<br />
<br />
It is also possible to combine fonts from the TeX Gyre collection in your own typescripts. The example below combines Bonum (Bookman) roman, Adventor (AvantGarde) for sans serif, Cursor (Courier) for teletype, and Euler for math. The <code>rscale=...</code> option ensures that all fonts have the same x-height. (You can lookup the relative x-heigt of a font using fontforge.)<br />
<br />
<texcode><br />
\starttypescript [Bonum]<br />
\definetypeface [Bonum] [rm] [serif] [bonum] [default]<br />
\definetypeface [Bonum] [ss] [sans] [adventor] [default] [rscale=0.887]<br />
\definetypeface [Bonum] [tt] [mono] [cursor] [default] [rscale=1.163]<br />
\definetypeface [Bonum] [mm] [math] [euler] [default] [rscale=1.050]<br />
\stoptypescript<br />
<br />
\usetypescript[Bonum]<br />
\setupbodyfont[Bonum,12pt]<br />
<br />
\starttext<br />
Hello world, I'm Bonum!<br />
\stoptext<br />
</texcode><br />
<br />
= Old contents =<br />
<br />
* [[TrueType fonts in luaTeX]]<br />
<br />
==== Good ol' typescripts ====<br />
<br />
Of course, Mark IV allows you to use typescripts as you've always done; for example:<br />
<br />
<texcode><br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,12pt]<br />
effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
<br />
\sc effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
</texcode><br />
<br />
That's as simple as using a traditional ConTeXt typescript!<br />
<br />
But ... how is it any different, then? Well, the difference is that in Mark IV, we can use an Opentype font directly, so that what is done here: when we want to use Palatino, the [[TeX Gyre]] equivalent (“Pagella”) is called and we can use its Opentype “features”; read on.<br />
<br />
==== Opentype features ====<br />
<br />
A “feature”, in the Opentype jargon, is a set of rules describing changes in the appearance of the text. Hmm, that's not very precise. Let's show some examples. First of all, you have to know that features are referred to by 4-letter tags, and you will see this a lot. One of them is ‘smcp‘, for “small caps“. Let's consider the following Mark IV-only code:<br />
<br />
<texcode><br />
\definefontfeature[smallcaps][language=DFLT,script=latn,smcp=yes]<br />
\font\palasmallcaps=texgyrepagella-regular*smallcaps<br />
\palasmallcaps This is a text in small capitals.<br />
</texcode><br />
<br />
Here you basically define a (Mark IV) feature with the name ”smallcaps”, and associate it with the (Opentype) feature “smcp”. You have to specify which script you want to use it with; scripts in Opentype are also tagged with four letters, and “latn” is of course Latin.<br />
<br />
Then you define a TeX font with that feature.<br />
<br />
You can see what features are defined in a particular font with the following bit of code<br />
<br />
<texcode><br />
\ctxlua<br />
{<br />
fontname = 'texgyrepagella-regular.otf'<br />
<br />
--[[ First read the font data.<br />
This makes heavy use of some of the Mark IV code]]<br />
tfmdata = fonts.tfm.read_and_define("file:" .. fontname, 655360)<br />
font = tfmdata.shared.otfdata<br />
if font<br />
then<br />
gsubfeatures = fonts.otf.analyze_features(font.gsub)<br />
gposfeatures = fonts.otf.analyze_features(font.gpos)<br />
end<br />
<br />
if gsubfeatures then<br />
table.sort(gsubfeatures) % We want our list sorted alphabetically!<br />
tex.sprint("\\rm GSUB features: \\tt ") % Beware: you don't want \rm to be interpreted by lua (\rm would yield carriage return + letter m)!<br />
for _, feat in ipairs(gsubfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GSUB features")<br />
end<br />
tex.sprint("\\par")<br />
<br />
if gposfeatures then<br />
tex.sprint("\\rm GPOS features: \\tt ")<br />
table.sort(gposfeatures)<br />
for _, feat in ipairs(gposfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GPOS features")<br />
end<br />
}<br />
</texcode><br />
<br />
It prints the list on the page. You'll notice there are two sets of features, each one of them defined in a different table of the Opentype font: the <code>GSUB</code> table (for Glyph SUBstitution) gives rules for replacing glyphs in certains circumstances (think of ligatures: f + i -> fi); the <code>GPOS</code> table (Glyph POSititioning) gives rules for moving glyphs (think of kerning: A + V -> A <kerning> V).<br />
<br />
Incidentally, the above code gives some basic examples of LuaTeX programming, a mixture of both Lua and TeX programming with some special features (features in the general sense, not the Opentype one :-).<br />
<br />
==== A (Complete) Typescript Example ====<br />
<br />
<texcode><br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [FranklinBookRegular] [name:FranklinGothicBookITC-Regular] [features=default]<br />
\definefontsynonym [FranklinMediumRegular] [name:FranklinGothicMediumITC-Regular] [features=default]<br />
\definefontsynonym [FranklinDemiRegular] [name:FranklinGothicDemiITC-Regular] [features=default]<br />
\definefontsynonym [FranklinHeavyRegular] [name:FranklinGothicHeavyITC-Regular] [features=default]<br />
<br />
\definefontsynonym [FranklinBookItalic] [name:FranklinGothicBookITC-Italic] [features=default]<br />
\definefontsynonym [FranklinDemiItalic] [name:FranklinGothicMediumITC-Italic] [features=default]<br />
\definefontsynonym [FranklinHeavyItalic] [name:FranklinGothicDemiITC-Italic] [features=default]<br />
\definefontsynonym [FranklinMediumItalic] [name:FranklinGothicHeavyITC-Italic] [features=default]<br />
<br />
\stoptypescript<br />
<br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [Sans] [FranklinBookRegular] [features=default]<br />
\definefontsynonym [SansItalic] [FranklinBookItalic] [features=default]<br />
\definefontsynonym [SansBold] [FranklinDemiRegular] [features=default]<br />
\definefontsynonym [SansBoldItalic] [FranklinDemiItalic] [features=default]<br />
\definefontsynonym [SansSlanted] [SansItalic] [features=default]<br />
\definefontsynonym [SansBoldSlanted] [SansBoldItalic] [features=default]<br />
\definefontsynonym [SansCaps] [Sans] [features=smallcaps]<br />
<br />
\stoptypescript<br />
<br />
\definetypeface[franklin][rm][sans][franklin][default]<br />
\definetypeface[franklin][ss][sans][franklin][default]<br />
\definetypeface[franklin][tt][mono][modern] [default][rscale=1.12]<br />
\definetypeface[franklin][mm][math][iwona] [default][rscale=1.02]<br />
<br />
\setupbodyfont[franklin,ss,10pt]<br />
</texcode><br />
<br />
<br />
<br />
Just the simplest way to use an otf font — or any font that does appear in <tt>mtxrun --script font --list</tt> — in all the document.<br />
<br />
I’m stick here :<br />
<br />
\definefontfeature [myfontfeature] [method=node, kern=yes, OTHER_FEATURE_COMMA_SEPERATED]<br />
\definefontsynonym [MyFontRegular] [name:TheFontName-Regular][features=myfontfeature]<br />
\definedfont [MyFontRegular at 16pt]<br />
<br />
This doesn’t run for my title which use « \tfc », only for the body of the text.<br />
<br />
*\definefontfeature<br />
**[myfontfeature] : you can use the name you want. It will be use at the next line ;<br />
**the fonts feature can be found with <tt>otfinfo -f TheFontFile.otf</tt>.<br />
*\definefontsynonym :<br />
**[MyFontRegular] : you can use the name you want. It will be use at the next line ;<br />
**The name after <tt>name:</tt> is the name given by <tt>mtxrun --script font --list</tt><br />
**The « name: » part can be replaced by <tt>file:TheFontFile.otf</tt><br />
<br />
<br />
== Example ==<br />
<br />
<br />
Now to access, say the regular warnock font, the following are valid. And I ought to mention that Hans recommends the first http://article.gmane.org/gmane.comp.tex.context/43685.<br />
<br />
<texcode><br />
% Hans recommends this format;<br />
\definefontsynonym [WarnockPro-Regular] [name:warnockproregular] <br />
</texcode><br />
<br />
and<br />
<br />
<texcode><br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular]<br />
</texcode><br />
<br />
An entire typescript would be defined as;<br />
<br />
<texcode><br />
\definefontfeature[latin-smallcaps][smallcaps][script=latn]<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\setups[font:fallback:sans]<br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular] <br />
\definefontsynonym [WarnockPro-Bold] [name:WarnockPro-Bold] <br />
\definefontsynonym [WarnockPro-Italic] [name:WarnockPro-It] <br />
\definefontsynonym [WarnockPro-BoldItalic] [name:WarnockPro-BoldIt] <br />
\stoptypescript<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\definefontsynonym [Serif] [WarnockPro-Regular] [features=default]<br />
\definefontsynonym [SerifBold] [WarnockPro-Bold] [features=default]<br />
\definefontsynonym [SerifItalic] [WarnockPro-Italic] [features=default]<br />
\definefontsynonym [SerifBoldItalic] [WarnockPro-BoldItalic] [features=default]<br />
\definefontsynonym [SerifCaps] [Serif] [features=latin-smallcaps]<br />
\stoptypescript<br />
<br />
\definetypeface[adobe][rm][serif][warnockpro][default]<br />
\setupbodyfont[adobe,11pt]<br />
<br />
</texcode><br />
<br />
[[Category:Fonts]]<br />
[[Category:International]]</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Fonts_in_LuaTeX&diff=10259Fonts in LuaTeX2010-01-19T13:44:44Z<p>Nicolas Girard: /* Using fonts */ Corrected section level</p>
<hr />
<div>{{note|This page is not finished yet}}<br />
<br />
'''Please, someone, fill this page !'''<br />
<br />
'''This page is beeing regorganized'''<br />
<br />
= Getting access to the system fonts =<br />
<br />
LuaTeX can use non-TeX fonts (in OpenType, TrueType or Type1 format) directly.<br />
<br />
The first time that you run<br />
<br />
context myfile.tex<br />
<br />
on a file that uses such non-traditional fonts (which is probably always), the actual fonts themselves have to be loaded in luatex's embedded section of fontforge to extract their metric information. This removes the need for tfm and vf files on your disk, but it is also a somewhat lengthy and often memory-hungry process.<br />
<br />
That is why the results of that internal preprocessing are also saved inside the texmf cache. Future runs using the same font (not just this file, but all files using that particular font) can then use the cached version of the metrics instead. <br />
<br />
== Building the font database ==<br />
<br />
You need to specify where the fonts should be looked for, by setting the <code>OSFONTDIR</code> environment variable. For instance,<br />
set OSFONTDIR=c:/windows/fonts/<br />
if the fonts should be found in <code>c:/windows/fonts/</code>; or<br />
export OSFONTDIR="/usr/local/share/fonts;$HOME/.fonts"<br />
if the fonts should be found in both <code>/usr/local/share/fonts</code> and <code>$HOME/.fonts</code>.<br />
<br />
The font database will then be automatically generated in the next run of <code>context</code><br />
<br />
You can also generate it manually by typing <br />
mtxrun --script font --reload<br />
or equally<br />
mtxrun --script fonts --reload<br />
<br />
The output should look like<br />
MTXrun | fontnames: identifying tree font files with suffix otf<br />
MTXrun | fontnames: identifying tree font files with suffix OTF<br />
MTXrun | fontnames: 331 tree files identified, 332 hash entries added, runtime 7.653 seconds<br />
MTXrun | fontnames: identifying tree font files with suffix ttf<br />
MTXrun | fontnames: identifying tree font files with suffix TTF<br />
MTXrun | fontnames: 17 tree files identified, 14 hash entries added, runtime 4.645 seconds<br />
...<br />
MTXrun | fontnames: 94 system files identified, 94 hash entries added, runtime 0.554 seconds<br />
MTXrun | fontnames: 3837 files read, 3342 normal and 49 extra entries added, 5 rejected, 3386 valid<br />
<br />
<br />
<br />
== Querying the font database ==<br />
<br />
The command<br />
mtxrun --script fonts --list<br />
will return the whole entries of the font database as a list, such as<br />
<br />
...<br />
warnockprobold WarnockPro-Bold E:/Fonts/Warnock Pro/WarnockPro-Bold.otf<br />
warnockproboldcapt WarnockPro-BoldCapt E:/Fonts/Warnock Pro/WarnockPro-BoldCapt.otf<br />
warnockprobolddisp WarnockPro-BoldDisp E:/Fonts/Warnock Pro/WarnockPro-BoldDisp.otf<br />
warnockproboldit WarnockPro-BoldIt E:/Fonts/Warnock Pro/WarnockPro-BoldIt.otf<br />
warnockprobolditcapt WarnockPro-BoldItCapt E:/Fonts/Warnock Pro/WarnockPro-BoldItCapt.otf<br />
warnockprobolditdisp WarnockPro-BoldItDisp E:/Fonts/Warnock Pro/WarnockPro-BoldItDisp.otf<br />
warnockprobolditsubh WarnockPro-BoldItSubh E:/Fonts/Warnock Pro/WarnockPro-BoldItSubh.otf<br />
warnockproboldsubh WarnockPro-BoldSubh E:/Fonts/Warnock Pro/WarnockPro-BoldSubh.otf<br />
...<br />
<br />
You can query the database against a particular pattern. For instance,<br />
mtxrun --script fonts --list --pattern=Delicious*<br />
will return<br />
deliciousbold Delicious-Bold /usr/local/share/fonts/d/delicious_bold.otf<br />
deliciousbolditalic Delicious-BoldItalic /usr/local/share/fonts/d/delicious_bolditalic.otf<br />
deliciousheavy Delicious-Heavy /usr/local/share/fonts/d/delicious_heavy.otf<br />
deliciousitalic Delicious-Italic /usr/local/share/fonts/d/delicious_italic.otf<br />
deliciousroman Delicious-Roman /usr/local/share/fonts/d/delicious_roman.otf<br />
delicioussmallcaps Delicious-SmallCaps /usr/local/share/fonts/d/delicious_smallcaps.otf<br />
<br />
You can get useful informations about your fonts by using the <code>--info</code> option. For instance,<br />
mtxrun --script fonts --list --info --pattern=Delicious*Roman<br />
will return<br />
MTXrun | fontname: deliciousroman<br />
MTXrun | fullname: Delicious-Roman<br />
MTXrun | filename: /usr/local/share/fonts/d/delicious_roman.otf<br />
MTXrun |<br />
MTXrun | gpos features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | kern latn dflt<br />
MTXrun |<br />
MTXrun | gsub features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | tlig all all<br />
MTXrun | trep all all<br />
<br />
== Installing new fonts ==<br />
<br />
After installing new fonts, the font database must be rebuilt for LuaTeX to access them.<br />
<br />
In current versions of Mark IV (earlier than July 2008) this is automatically done whenever a named font cannot be found.<br />
<br />
You only have to do the reload manually when you have installed updates to already installed fonts that cause the font and/or file names to change. <br />
This normally only happens for fonts that are still in development like [[TeX Gyre]] and [[Latin Modern]].<br />
<br />
You can rebuild the database manually, using the already-mentioned command<br />
mtxrun --script fonts --reload<br />
<br />
Alternatively, you can turn off the automatic rebuild of the database, by setting either of<br />
MTX.FONTS.AUTOLOAD<br />
MTX_FONTS_AUTOLOAD<br />
to "no".<br />
<br />
== References ==<br />
<br />
[http://context.aanhet.net/svn/contextman/context-reference/en/co-fonts.pdf The new manual chapter on fonts]<br />
<br />
= Using fonts =<br />
<br />
Handling fonts in LuaTeX can be done<br />
* in a simple but limited way, using the <code>simplefonts</code> module;<br />
* in the standard way, using [[TypeScripts]]<br />
<br />
== With the <code>simplefonts</code> module ==<br />
<br />
<code>simplefonts</code> is a third-party module written by Wolfgang Schuster.<br />
<br />
It simplifies the use of fonts in LuaTeX by<br />
* freeing the user from writing or using [[TypeScripts]];<br />
* offering an interface similar to the [http://www.ctan.org/tex-archive/macros/xetex/latex/fontspec/ fontspec package for XeTeX]<br />
<br />
For instance, assuming the [http://www.josbuivenga.demon.nl/delicious.html Delicious fonts] are properly installed and recognized by ConTeXt, you can simply write:<br />
<br />
<texcode><br />
\usemodule[simplefonts] % load the module<br />
\setmainfont[Delicious] % set Delicious as main (serif) font<br />
<br />
\starttext<br />
\rm\tf roman \it italic \bf bold \bi bolditalic \sc smallcaps<br />
\stoptext<br />
</texcode><br />
<br />
== The standard way: Typescripts ==<br />
<br />
=== Installing typescripts ===<br />
<br />
Installing typescripts consists in the following:<br />
<br />
1. Copy the typescript files into either <br />
<texcode>$TEXMF/tex/texmf-fonts/tex/context/user<br />
$TEXMF/tex/texmf-project/tex/context/user</texcode><br />
2. Run <code>context --generate</code><br />
<br />
By convention, typescript files are named like <code>type-(fontname|foundry).tex</code>. <br />
<br />
It may happen that some <code>type-xx.tex</code> typescript file depends on mkiv-specific code located in a matching <code>type-xx.mkiv</code> file. In this case, both files need to be installed.<br />
<br />
=== Loading typescripts ===<br />
<br />
A typescript file named <code>type-xx.tex</code> should be loaded using<br />
\usetypescriptfile[type-xx]<br />
<br />
An alternative way is<br />
\usetypefile[xx]<br />
where ConTeXt prepends <code>type-</code> when it loads the file; but <br />
<cmd>usetypescriptfile</cmd> is the preferred command because it takes care of the<br />
<cmd>starttypescriptcollection</cmd>/<cmd>stoptypescriptcollection</cmd> environments.<br />
<br />
=== Where to find existing typescripts ===<br />
<br />
Each of the typescripts below defines a keyword to use with <cmd>setupbodyfont</cmd>. Usually this is the same as the name of the typescript, but there is one exception (<code>antykwa-torunska</code>)<br />
<br />
* Latin Modern (typescript name: <code>modern</code>; this is the default font set)<br />
* Latin Modern variant (ts name: <code>modernvariable</code>; LM variable typewriter for serif)<br />
* Postscript (ts name: <code>postscript</code>; Termes for serif, Heros for sans, Cursor for mono)<br />
* Antykwa Toruńska (ts name: <code>antykwa-torunska</code>; only serif; defines <tt>antykwa</tt> as keyword for <cmd>setupbodyfont</cmd>)<br />
* Iwona (ts name: <code>iwona</code>; only sans serif)<br />
* Iwona Light, Medium and Heavy (ts names: <code>iwona-light</code>, <code>iwona-medium</code>, <code>iwona-heavy</code>; only sans; the medium variant is a small bit heavier than a "regular" one)<br />
* Pagella (ts name: <code>palatino</code>; only serif)<br />
* Termes (ts name: <code>times</code>; only serif, Heros for sans)<br />
<br />
=== Usage example ===<br />
<br />
<texcode><br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,18pt]<br />
<br />
\starttext<br />
Hello world, I'm Pagella!<br />
\stoptext<br />
</texcode><br />
<br />
The first line seems to order ConTeXt to "install" (for the current file) the given typescript (it accepts what I have earlier called a "typescript name"). The last one starts using it (you may omit the size if you are satisfied with the default).<br />
<br />
== Combining predefined fonts in your own typescripts ==<br />
<br />
It is also possible to combine fonts from the TeX Gyre collection in your own typescripts. The example below combines Bonum (Bookman) roman, Adventor (AvantGarde) for sans serif, Cursor (Courier) for teletype, and Euler for math. The <code>rscale=...</code> option ensures that all fonts have the same x-height. (You can lookup the relative x-heigt of a font using fontforge.)<br />
<br />
<texcode><br />
\starttypescript [Bonum]<br />
\definetypeface [Bonum] [rm] [serif] [bonum] [default]<br />
\definetypeface [Bonum] [ss] [sans] [adventor] [default] [rscale=0.887]<br />
\definetypeface [Bonum] [tt] [mono] [cursor] [default] [rscale=1.163]<br />
\definetypeface [Bonum] [mm] [math] [euler] [default] [rscale=1.050]<br />
\stoptypescript<br />
<br />
\usetypescript[Bonum]<br />
\setupbodyfont[Bonum,12pt]<br />
<br />
\starttext<br />
Hello world, I'm Bonum!<br />
\stoptext<br />
</texcode><br />
<br />
= Old contents =<br />
<br />
* [[TrueType fonts in luaTeX]]<br />
<br />
==== Good ol' typescripts ====<br />
<br />
Of course, Mark IV allows you to use typescripts as you've always done; for example:<br />
<br />
<texcode><br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,12pt]<br />
effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
<br />
\sc effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
</texcode><br />
<br />
That's as simple as using a traditional ConTeXt typescript!<br />
<br />
But ... how is it any different, then? Well, the difference is that in Mark IV, we can use an Opentype font directly, so that what is done here: when we want to use Palatino, the [[TeX Gyre]] equivalent (“Pagella”) is called and we can use its Opentype “features”; read on.<br />
<br />
==== Opentype features ====<br />
<br />
A “feature”, in the Opentype jargon, is a set of rules describing changes in the appearance of the text. Hmm, that's not very precise. Let's show some examples. First of all, you have to know that features are referred to by 4-letter tags, and you will see this a lot. One of them is ‘smcp‘, for “small caps“. Let's consider the following Mark IV-only code:<br />
<br />
<texcode><br />
\definefontfeature[smallcaps][language=DFLT,script=latn,smcp=yes]<br />
\font\palasmallcaps=texgyrepagella-regular*smallcaps<br />
\palasmallcaps This is a text in small capitals.<br />
</texcode><br />
<br />
Here you basically define a (Mark IV) feature with the name ”smallcaps”, and associate it with the (Opentype) feature “smcp”. You have to specify which script you want to use it with; scripts in Opentype are also tagged with four letters, and “latn” is of course Latin.<br />
<br />
Then you define a TeX font with that feature.<br />
<br />
You can see what features are defined in a particular font with the following bit of code<br />
<br />
<texcode><br />
\ctxlua<br />
{<br />
fontname = 'texgyrepagella-regular.otf'<br />
<br />
--[[ First read the font data.<br />
This makes heavy use of some of the Mark IV code]]<br />
tfmdata = fonts.tfm.read_and_define("file:" .. fontname, 655360)<br />
font = tfmdata.shared.otfdata<br />
if font<br />
then<br />
gsubfeatures = fonts.otf.analyze_features(font.gsub)<br />
gposfeatures = fonts.otf.analyze_features(font.gpos)<br />
end<br />
<br />
if gsubfeatures then<br />
table.sort(gsubfeatures) % We want our list sorted alphabetically!<br />
tex.sprint("\\rm GSUB features: \\tt ") % Beware: you don't want \rm to be interpreted by lua (\rm would yield carriage return + letter m)!<br />
for _, feat in ipairs(gsubfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GSUB features")<br />
end<br />
tex.sprint("\\par")<br />
<br />
if gposfeatures then<br />
tex.sprint("\\rm GPOS features: \\tt ")<br />
table.sort(gposfeatures)<br />
for _, feat in ipairs(gposfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GPOS features")<br />
end<br />
}<br />
</texcode><br />
<br />
It prints the list on the page. You'll notice there are two sets of features, each one of them defined in a different table of the Opentype font: the <code>GSUB</code> table (for Glyph SUBstitution) gives rules for replacing glyphs in certains circumstances (think of ligatures: f + i -> fi); the <code>GPOS</code> table (Glyph POSititioning) gives rules for moving glyphs (think of kerning: A + V -> A <kerning> V).<br />
<br />
Incidentally, the above code gives some basic examples of LuaTeX programming, a mixture of both Lua and TeX programming with some special features (features in the general sense, not the Opentype one :-).<br />
<br />
==== A (Complete) Typescript Example ====<br />
<br />
<texcode><br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [FranklinBookRegular] [name:FranklinGothicBookITC-Regular] [features=default]<br />
\definefontsynonym [FranklinMediumRegular] [name:FranklinGothicMediumITC-Regular] [features=default]<br />
\definefontsynonym [FranklinDemiRegular] [name:FranklinGothicDemiITC-Regular] [features=default]<br />
\definefontsynonym [FranklinHeavyRegular] [name:FranklinGothicHeavyITC-Regular] [features=default]<br />
<br />
\definefontsynonym [FranklinBookItalic] [name:FranklinGothicBookITC-Italic] [features=default]<br />
\definefontsynonym [FranklinDemiItalic] [name:FranklinGothicMediumITC-Italic] [features=default]<br />
\definefontsynonym [FranklinHeavyItalic] [name:FranklinGothicDemiITC-Italic] [features=default]<br />
\definefontsynonym [FranklinMediumItalic] [name:FranklinGothicHeavyITC-Italic] [features=default]<br />
<br />
\stoptypescript<br />
<br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [Sans] [FranklinBookRegular] [features=default]<br />
\definefontsynonym [SansItalic] [FranklinBookItalic] [features=default]<br />
\definefontsynonym [SansBold] [FranklinDemiRegular] [features=default]<br />
\definefontsynonym [SansBoldItalic] [FranklinDemiItalic] [features=default]<br />
\definefontsynonym [SansSlanted] [SansItalic] [features=default]<br />
\definefontsynonym [SansBoldSlanted] [SansBoldItalic] [features=default]<br />
\definefontsynonym [SansCaps] [Sans] [features=smallcaps]<br />
<br />
\stoptypescript<br />
<br />
\definetypeface[franklin][rm][sans][franklin][default]<br />
\definetypeface[franklin][ss][sans][franklin][default]<br />
\definetypeface[franklin][tt][mono][modern] [default][rscale=1.12]<br />
\definetypeface[franklin][mm][math][iwona] [default][rscale=1.02]<br />
<br />
\setupbodyfont[franklin,ss,10pt]<br />
</texcode><br />
<br />
<br />
<br />
Just the simplest way to use an otf font — or any font that does appear in <tt>mtxrun --script font --list</tt> — in all the document.<br />
<br />
I’m stick here :<br />
<br />
\definefontfeature [myfontfeature] [method=node, kern=yes, OTHER_FEATURE_COMMA_SEPERATED]<br />
\definefontsynonym [MyFontRegular] [name:TheFontName-Regular][features=myfontfeature]<br />
\definedfont [MyFontRegular at 16pt]<br />
<br />
This doesn’t run for my title which use « \tfc », only for the body of the text.<br />
<br />
*\definefontfeature<br />
**[myfontfeature] : you can use the name you want. It will be use at the next line ;<br />
**the fonts feature can be found with <tt>otfinfo -f TheFontFile.otf</tt>.<br />
*\definefontsynonym :<br />
**[MyFontRegular] : you can use the name you want. It will be use at the next line ;<br />
**The name after <tt>name:</tt> is the name given by <tt>mtxrun --script font --list</tt><br />
**The « name: » part can be replaced by <tt>file:TheFontFile.otf</tt><br />
<br />
<br />
== Example ==<br />
<br />
<br />
Now to access, say the regular warnock font, the following are valid. And I ought to mention that Hans recommends the first http://article.gmane.org/gmane.comp.tex.context/43685.<br />
<br />
<texcode><br />
% Hans recommends this format;<br />
\definefontsynonym [WarnockPro-Regular] [name:warnockproregular] <br />
</texcode><br />
<br />
and<br />
<br />
<texcode><br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular]<br />
</texcode><br />
<br />
An entire typescript would be defined as;<br />
<br />
<texcode><br />
\definefontfeature[latin-smallcaps][smallcaps][script=latn]<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\setups[font:fallback:sans]<br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular] <br />
\definefontsynonym [WarnockPro-Bold] [name:WarnockPro-Bold] <br />
\definefontsynonym [WarnockPro-Italic] [name:WarnockPro-It] <br />
\definefontsynonym [WarnockPro-BoldItalic] [name:WarnockPro-BoldIt] <br />
\stoptypescript<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\definefontsynonym [Serif] [WarnockPro-Regular] [features=default]<br />
\definefontsynonym [SerifBold] [WarnockPro-Bold] [features=default]<br />
\definefontsynonym [SerifItalic] [WarnockPro-Italic] [features=default]<br />
\definefontsynonym [SerifBoldItalic] [WarnockPro-BoldItalic] [features=default]<br />
\definefontsynonym [SerifCaps] [Serif] [features=latin-smallcaps]<br />
\stoptypescript<br />
<br />
\definetypeface[adobe][rm][serif][warnockpro][default]<br />
\setupbodyfont[adobe,11pt]<br />
<br />
</texcode><br />
<br />
[[Category:Fonts]]<br />
[[Category:International]]</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Imposition&diff=9820Imposition2009-06-07T09:02:34Z<p>Nicolas Girard: Added the imposition test document from Willi [http://meeting.contextgarden.net/2007/share/willi/]</p>
<hr />
<div>< [[Structurals]] | [[Visuals]] ><br />
<br />
==What is Imposition?==<br />
<br />
To impose means to order pages on a bigger sheet in a way, that you get a booklet (or something similar) with correct page order after folding.<br />
In the simplest case you impose four A5 pages on both sides of an A4 sheet.<br />
<br />
In a print shop it could be that you've to place 64 inner pages of a book on one printing sheet. For private use you could want to zigzag-fold an A4 sheet as a brochure that fits nicely in a business envelope. You could make two pages with three columns each, or you could make six pages and impose them.<br />
<br />
Another "style" of imposition is to place several identical templates on one sheet, e.g. labels.<br />
<br />
==Imposition schemas==<br />
<br />
===Default schemas===<br />
<br />
ConTeXt has some built-in imposition schemas (see "arranging pages" in the manual):<br />
<br />
* 2UP : 2 pages next to each other, n sheets arranged for a single booklet<br />
* 2DOWN : 2 pages above each other, n sheets arranged for a single booklet<br />
* 2SIDE : 2 pages per form, side by side in pagination order, single sided only (no real imposition, only paper saving)<br />
* 2TOP : 2 pages above each other, single sided only<br />
* 2TOPSIDE: 2 odd pages on one side, two even pages verso, above each other<br />
* 2*2 : section: one sheet 2 x 2 pages = 4 pages (2 pages per form, for single sheets with front and back)<br />
* 2**2 : section: one sheet 2 x 2 pages = 4 pages (2 pages per form, for book ordering)<br />
* 2*4 : section: one sheet 2 x 4 pages = 8 pages (4 pages per form, 2x2 pages head to head)<br />
* 2*8 : section: one sheet 2 x 8 pages = 16 pages<br />
* 2*16 : section: one sheet 2 x 16 pages = 32 pages<br />
* 2*4*2 : section of 16 pages: 2 sheets, 4 pages front and backside<br />
* 2*2*4 : section of 16 pages: 4 sheets, 2 pages front and backside<br />
* XY : one sheet with x rows and y columns, you can control the number with [[cmd:setuppaper|\setuppaper]][nx=...,ny=...,dx=...,dy=...]<br />
<br />
"form" means "one side of a sheet".<br />
<br />
You can access this feature via<br />
* <cmd>setuparranging</cmd><br />
* <tt>texexec --pdfarrange=...</tt><br />
* [http://www.ntg.nl:8061/impose.pdf online interface]<br />
<br />
{{todo|some graphical examples}}<br />
<br />
===Additional schemas===<br />
<br />
Hraban needed a "3SIDE" schema to fit three "filius" planner pages on one A4 sheet. Willi wrote it:<br />
<texcode><br />
\unprotect<br />
% New page imposition scheme 3SIDE by Willi Egger 2003-07-21<br />
<br />
\installpagearrangement 3SIDE<br />
{\dosetuparrangement{3}{1}{6}{4}{2}%<br />
\pusharrangedpageTHREESIDE\poparrangedpagesAB\relax}<br />
<br />
\def\pusharrangedpageTHREESIDE#1% Willi's approach<br />
{\doglobal\increment\arrangedpageN<br />
\reportarrangedpage\arrangedpageN<br />
\ifcase\arrangedpageN<br />
\or \handlearrangedpageXandY{#1}000\arrangedpageA % 1<br />
\or \handlearrangedpageXandY{#1}010\arrangedpageA % 2<br />
\or \handlearrangedpageXandY{#1}020\arrangedpageA % 3<br />
\or \handlearrangedpageXandY{#1}000\arrangedpageB % 4<br />
\or \handlearrangedpageXandY{#1}010\arrangedpageB % 5<br />
\or \handlearrangedpageXandY{#1}020\arrangedpageB % 6<br />
\poparrangedpages<br />
\fi}<br />
<br />
\protect<br />
</texcode><br />
You can use this code simply in your environment file. The other schemas are in <tt>page-imp.tex</tt>.<br />
<br />
Use it like this:<br />
<texcode><br />
\definepapersize [filius][width=92mm, height=172mm]<br />
\setuppapersize [filius][A4,landscape]<br />
\setuparranging [3SIDE]<br />
\setuplayout [location=middle,<br />
alternative=singlesided,<br />
grid=no, marking=on,<br />
leftmargin=10mm, leftmargindistance=0mm,<br />
topspace=2mm, header=4mm, footer=0mm,<br />
width=77mm, height=166mm]<br />
</texcode><br />
<br />
<br />
ConTeXt is also handy when you need to '''rearrange an existing pdf''' into a booklet. This is a trial-and-error solution by Mari for rearranging an A4 pdf file into 2*8 spreads on A3 sheet (-> A6 pages when printed and cut). The texexec.tex file that was created by the first tries with <tt>texexec --pdfarrange</tt> (which didn't seem to have enough options) was a great help while working towards this solution.<br />
Not sure about the margins on the final A6 pages (the original has equal left and right margins, some extra inside margin might be a good thing), but at least otherwise this seems to do the trick:<br />
<br />
<texcode><br />
\setuppapersize[A6][A3] %individual page A6 size, print size A3<br />
\setuparranging[2*8,rotated] %makes an 8 page gathering when folded (duplex printing!)<br />
\setupoutput[pdf]<br />
\setuplayout<br />
[backspace=0pt,<br />
topspace=0pt,<br />
width=middle,<br />
height=middle,<br />
location=middle,<br />
header=0pt,<br />
footer=0pt]<br />
\setuppagenumbering[alternative=doublesided]<br />
<br />
\starttext<br />
<br />
\insertpages<br />
[original_file.pdf][width=0pt]<br />
<br />
\stoptext<br />
<br />
</texcode><br />
<br />
===Testing schemas===<br />
<br />
Here's a convenient test file to help choose a schema or write a new one:<br />
<br />
<texcode><br />
\setupbodyfont[ss,10pt]<br />
\setuppapersize [A7][A4] <br />
\setuparranging [2*2*4,doublesided] %% the schema you want to test<br />
\setuppagenumbering [alternative=doublesided,location=footer]<br />
\setuplayout [margin=0pt,width=fit] <br />
\setupbackgrounds [text][text][background=screen,backgroundscreen=0.7] <br />
\setupcolors [state=start] <br />
\setuplayout [location=middle,marking=on]<br />
\setuptolerance [tolerant] <br />
<br />
\def\Style{[2*2*4,doublesided]}<br />
<br />
<br />
\startbuffer[Fakepage]<br />
\strut<br />
\blank<br />
\midaligned{\Style}<br />
\vfill<br />
\midaligned{This is page \recurselevel}<br />
\vfill<br />
\stopbuffer<br />
<br />
\setupheadertexts[\CONTEXT\ imposition test document]<br />
<br />
\starttext<br />
% \showframe<br />
\dorecurse{16}{\getbuffer[Fakepage]\page}<br />
<br />
\stoptext</texcode><br />
<br />
== Cut marks ==<br />
<br />
ConTeXt also allows to place cut marks. This can be controlled using the <tt>marking</tt> option of [[cmd:setuplayout|\setuplayout]]; possible values are:<br />
<br />
* '''on''' show cut marks and page number<br />
* '''screen''' ditto, but also print a grey-scale colour bar<br />
* '''colour''' ditto, but also print a colour bar<br />
* '''text''' print a text, defaults to `empty`<br />
<br />
The default settings are<br />
<br />
<texcode><br />
\def\pagecutmarksymbol {\the\realpageno}<br />
\def\pagecutmarklength {.5cm}<br />
\let\pagecutmarktoptext \empty<br />
\let\pagecutmarkbottomtext \empty<br />
</texcode><br />
<br />
To obtain register marks (or also called registration marks) you can use the small [http://archive.contextgarden.net/message/20070417.212628.76134ff7.en.html <tt>crop</tt> module] which was posted to the mailing list.<br />
<br />
== Caveat: common troubles ==<br />
<br />
Note that some features (e.g. table of content, internal references) are always disabled in imposition mode. So, they will not be included in the pdf if you ask for imposition.<br />
To get rid of this you can use the "arrange" key for texexec. <br />
<br />
<texcode><br />
texexec --arrange yourFilename<br />
</texcode><br />
<br />
This will run the document at first without page arrangement and impose the pages in a separate run after table of contents etc are created.<br />
<br />
In '''SciTe/WinConTeXt''' you can run this command by choosing ''Process and Arrange'' in the ''Tools'' menu in SciTe.<br />
<br />
== Getting the last page of a Booklet ==<br />
<br />
When you use imposition to print a booklet you want to put something on the very last page, the <code>quadruple</code> pagebreak did not always fill the remaining pages untill you get a quadruple number of pages.<br />
<br />
<texcode><br />
\unprotect<br />
<br />
\startvariables all<br />
nextquadruple: nextquadruple<br />
\stopvariables<br />
<br />
\installpagebreakhandler \v!nextquadruple<br />
{\ifdoublesided<br />
\!!counta\realpageno<br />
\!!countb\realpageno<br />
\advance\!!counta 4<br />
\divide\!!counta 4<br />
\multiply\!!counta 4<br />
\advance\!!countb 1<br />
\advance\!!counta-\!!countb<br />
\executepagebreakhandler\v!yes<br />
\dorecurse\!!counta{\executepagebreakhandler\v!empty}%<br />
\fi}<br />
<br />
\protect<br />
<br />
\setuppapersize[A5][A4]<br />
\setuparranging[2UP,rotated,doublesided]<br />
\setuppagenumbering[alternative=doublesided]<br />
<br />
\starttext<br />
<br />
\subject{Front Cover}<br />
<br />
\dorecurse{10}{\input tufte \par}<br />
<br />
\page[nextquadruple]<br />
<br />
Back Cover<br />
<br />
\stoptext<br />
</texcode><br />
<br />
== Getting to the Back Cover of a Booklet ==<br />
<br />
When using imposition to print an a5 booklet (a4 folded in half) John Devereux wanted to specify content for the back cover, independently of the actual number of pages in the booklet. Here is a way that worked (thanks to Wolfgang Schuster on the mailing list). \page[beforequadruple] gets to the inside back cover. Another \page gets to the outside back cover.<br />
<br />
<texcode><br />
\unprotect<br />
<br />
\startvariables all<br />
beforequadruple: beforequadruple<br />
\stopvariables<br />
<br />
\installpagebreakhandler \v!beforequadruple<br />
{\ifdoublesided<br />
\!!counta\realpageno<br />
\!!countb\realpageno<br />
\advance\!!counta 5<br />
\divide\!!counta 4<br />
\multiply\!!counta 4<br />
\advance\!!countb 2<br />
\advance\!!counta-\!!countb<br />
\executepagebreakhandler\v!yes<br />
\dorecurse\!!counta{\executepagebreakhandler\v!empty}%<br />
\fi}<br />
<br />
\protect<br />
<br />
\setuppapersize[A5][A4]<br />
\setuparranging[2UP,rotated,doublesided]<br />
\setuppagenumbering[alternative=doublesided]<br />
<br />
\starttext<br />
<br />
\subject Front Cover<br />
<br />
\dorecurse{10}{\input tufte \par}<br />
<br />
\page[beforequadruple]<br />
<br />
Imprint<br />
<br />
\page<br />
<br />
Back Cover<br />
<br />
\stoptext<br />
</texcode></div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Table&diff=9819Table2009-06-05T09:13:32Z<p>Nicolas Girard: /* Column Definition */ typo</p>
<hr />
<div>< [[Tables Overview]] | [[Tabulate]] | [[Tables]] ><br />
<br />
This is ConTeXts oldest table module. It uses the same formatting as [[Tabulate]] (see [[Tables Overview]]).<br />
<br />
This mode is based on Michael Wichura's TaBlE package for PlainTeX. The official manual for it is commercial (about 40 USD), see [http://www.pctex.com/books.html PCTeX] -- but note that the TaBlE manual only talks about the original syntax, which does not use <cmd>NC</cmd>, <cmd>HL</cmd> cum suis.<br />
<br />
The only ConTeXt docs are in [[manual:ms-cb-en.pdf|ConTeXt - an excursion]]. There is also two introductory articles in tugboat [http://tug.org/TUGboat/Articles/tb28-3/tb90mahajan.pdf ConTeXt basics for users: Table macros] [http://www.tug.org/TUGboat/Articles/tb29-1/tb91mahajan.pdf Table macros II] by Aditya Mahajan (2007 and 2008).<br />
<br />
<br />
== Basic Commands ==<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\starttable[|l|l|]<br />
\HL<br />
\NC Command \VL Meaning \SR % or \NC\AR<br />
\HL<br />
\NC \tex{NC} \VL next column \AR<br />
\NC \tex{HL} \VL horizontal line \AR<br />
\NC \tex{VL} \VL vertical line \AR<br />
\NC \tex{NR} \VL next row \LR<br />
\HL<br />
\NC \tex{SR} \VL single row \AR<br />
\NC \tex{FR} \VL first row \AR<br />
\NC \tex{MR} \VL middle row \AR<br />
\NC \tex{LR} \VL last row \LR % or \NC\AR<br />
\HL<br />
\NC \tex{AR} \VL automatic row \SR % or \NC\AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\switchtobodyfont[ss, 8pt]<br />
\starttable[|l|l|]<br />
\HL<br />
\NC Command \VL Meaning \SR % or \NC\AR<br />
\HL<br />
\NC \tex{NC} \VL next column \AR<br />
\NC \tex{HL} \VL horizontal line \AR<br />
\NC \tex{VL} \VL vertical line \AR<br />
\NC \tex{NR} \VL next row \LR<br />
\HL<br />
\NC \tex{SR} \VL single row \AR<br />
\NC \tex{FR} \VL first row \AR<br />
\NC \tex{MR} \VL middle row \AR<br />
\NC \tex{LR} \VL last row \LR % or \NC\AR<br />
\HL<br />
\NC \tex{AR} \VL automatic row \SR % or \NC\AR<br />
\HL<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
<br />
* You get vertical lines (rules), if you use <cmd>VL</cmd> instead of <cmd>NC</cmd>.<br />
* Better use <cmd>SR</cmd>, <cmd>FR</cmd>, <cmd>MR</cmd>, <cmd>LR</cmd> instead of <cmd>NR</cmd>.<br />
* You can also use <cmd>AR</cmd> instead of <cmd>SR</cmd>, <cmd>FR</cmd>, <cmd>MR</cmd> and <cmd>LR</cmd> (AR for automatic row).<br />
* You can leave out the <cmd>NC</cmd> before the "row" command, but not if you use <cmd>AR</cmd> in a last or single row (see example).<br />
* You can influence the table with <cmd>setuptables</cmd>.<br />
* There are also <cmd>BL</cmd> and <cmd>CL</cmd> for colored backgrounds, see below.<br />
<br />
==Column Definition==<br />
<br />
The table is defined by the template enclosed in square brackets after <cmd>starttable</cmd>. The template has the form<br />
<tt>|keys for the first column|keys for the second column|...|keys for the last column|</tt>. Please note that each column is surrounded by <tt>|</tt> signs. These are necessary. The formatting keys for each column can be a choice of<br />
<br />
<table width="100%" cols="2"><tr valign="top"><td><br />
<context><br />
\switchtobodyfont[ss, 8pt]<br />
\starttable[|l|lp(.5\textwidth)|]<br />
\HL<br />
\NC \bf Key \VL \bf Meaning \SR<br />
\HL<br />
\NC \NC Primitive Keys \SR<br />
\HL<br />
\NC \type{a{tokens}}\VL Adds \type{tokens} {\em after} the column content\AR<br />
\NC \type{b{tokens}}\VL Adds \type{tokens} '''before''' the column content\AR<br />
\NC {\tt \backslash\{ } \VL Enclose the column in braces (grouping)\AR<br />
\NC \type{*{n}{keys}}\VL Equivalent to repeating the formatting keys \type{keys} \type{n} times\NC\LR<br />
\HL<br />
\NC \NC Positioning Keys\SR<br />
\HL<br />
\NC \type{\LeftGlue} \VL Specifies the left glue to be used before the column\AR<br />
\NC \type{\RightGlue} \VL Specifies the right glue to be used after the column\AR<br />
\NC \type{l} \VL left-aligned column\AR<br />
\NC \type{c} \VL centered column\AR<br />
\NC \type{r} \VL right-aligned column\AR<br />
\NC \type{p(width)} \VL Set each cell as a paragraph\AR<br />
\NC \type{w} \VL Set minimum column width\AR<br />
\NC \type{k} \VL Insert a kern both left and right of the column\AR<br />
\NC \type{i} \VL Add a kern to the left of the column\AR<br />
\NC \type{j} \VL Add a kern to the right of the column\LR<br />
\HL<br />
\NC \NC Numeric and Math Item Keys \SR<br />
\HL<br />
\NC \type{n} \VL Numeric item not in math mode\AR<br />
\NC \type{N} \VL Numeric item in math mode\AR<br />
\NC \type{m} \VL Each cell is in (inline) math mode. Equivalent to \type{b$ a$}\AR<br />
\NC \type{M} \VL Each cell is in display math mode. Equivalent to \type{\{b{$\displaystyle}a$}} \AR<br />
\NC \type{\m} \VL Equivalent to \type{l b{{}}m}\AR<br />
\NC \type{\M} \VL Equivalent to \type{l b{{}}M}\LR<br />
\HL<br />
\NC \NC Style Keys \SR<br />
\HL<br />
\NC \type{f\command} \VL Set font according to following \tex{command}\AR<br />
\NC \type{B} \VL Bold. Equivalent to \type{f\bf}\AR<br />
\NC \type{I} \VL Italic. Equivalent to \type{f\it}\AR<br />
\NC \type{S} \VL Slanted. Equivalent to \type{f\sl}\AR<br />
\NC \type{R} \VL Roman. Equivalent to \type{f\rm}\AR<br />
\NC \type{T} \VL Teletype. Equivalent to \type{f\tt}\AR<br />
\NC \type{C} \VL Color. Use it in combination with \backslash\{ (e.g. \backslash\{C\{red\} )\LR<br />
\HL<br />
\NC \NC Tabskip Keys \SR<br />
\HL<br />
\NC \type{s} \VL Set the tabskip to the right of this column and of all following columns up to the next \type{s} or \type{o} key\AR<br />
\NC \type{o} \VL Set the tabskip to the right of this column only\LR<br />
\HL<br />
\stoptable<br />
</context><br />
</td><td><br />
===Examples===<br />
; <code>|l|</code> : a left aligned column, as wide as necessary<br />
; <code>|lw(2cm)|</code> : a left aligned column of at least 2 cm width<br />
; <code>|p(2cm)|</code> : a centered(!) paragraph of 2 cm width<br />
; <code>|lp(.5\textwidth)|</code> : a left aligned paragraph of specified width<br />
; <code>|rp(.5\textwidth)|</code> : a right aligned paragraph of specified width<br />
; <code>|cp(.5\textwidth)|</code> : a center aligned paragraph of specified width<br />
; <code>|xp(.5\textwidth)|</code> : a justified paragraph of specified width<br />
; <code>...</code> : Please add more<br />
; <code>...</code> : <br />
<br />
{{Todo|add more examples of column definitions}}<br />
</td></tr></table><br />
<br />
==Column Spans==<br />
<br />
It's possible to create columnspans (i.e. cells that span more than one column) with the command <cmd>use{<i>N</i>}</cmd> where ''N'' is the number of columns spanned by the cell. It's often necessary to use <cmd>ReFormat[<i>new keys</i>]{}</cmd> to reformat this specific cell according to the ''new keys''.<br />
<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\starttable[s(0pt)|ls(10pt)|rs(0pt)|]<br />
\HL<br />
\NC \use{2}\ReFormat[cB]{Spanning head} \SR<br />
\HL<br />
\NC \Use{2}[cB]{Spanning head} \SR % slightly shorted<br />
\HL<br />
\NC left column text \VL right column text \NC \AR<br />
\NC new row \VL new row \NC \AR<br />
\NC left column text \VL \ReFormat[l]{reformatted} \NC \AR<br />
\HL<br />
\NC \use{2}Spanning entry \SR <br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\starttable[s(0pt)|ls(10pt)|rs(0pt)|]<br />
\HL<br />
\NC \use{2}\ReFormat[cB]{Spanning head} \SR<br />
\HL<br />
\NC \Use{2}[cB]{Spanning head} \SR<br />
\HL<br />
\NC left column text \VL right column text \NC \AR<br />
\NC new row \VL new row \NC \AR<br />
\NC left column text \VL \ReFormat[l]{reformatted} \NC \AR<br />
\HL<br />
\NC \use{2}Spanning entry \SR <br />
\HL<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
<br />
<br />
(<cmd>ReFormat</cmd> can be abbreviated <cmd>REF</cmd> for brevity.)<br />
== Row Spans==<br />
<br />
It's also possible to create rowspans (i.e. cells that span more than one row) with the command <cmd>Raise(<i>dimen</i>){<i>content</i>}</cmd> or <cmd>Lower(<i>dimen</i>){</i>content</i>}</cmd> that raise or lower ''content'' by ''dimen''.<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\starttable[|c|c|]<br />
\HL<br />
\VL \Lower(.5\lineheight){a} \VL b \VL \AR<br />
\DC \DL \DR<br />
\VL \VL c \VL \AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\starttable[|c|c|]<br />
\HL<br />
\VL \Lower(.5\lineheight){a} \VL b \VL \AR<br />
\DC \DL \DR<br />
\VL \VL c \VL \AR<br />
\HL<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
<br />
(<cmd>Lower(.5\lineheight){a}</cmd> can be abbreviated <cmd>LOW{a}</cmd> for brevity.)<br />
<br />
An alternative means of spanning rows by a tall object makes use of a bit of TeX magic:<br />
<cmd>smash{tall objext}</cmd>:<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\starttable[|M|c|]<br />
\HL<br />
\VL \VL a \VL \AR<br />
\DC \DL \DR<br />
\VL \smash{\sum_0^N} \VL b \VL \AR<br />
\DC \DL \DR<br />
\VL \VL c \VL \AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\starttable[|M|c|]<br />
\HL<br />
\VL \VL a \VL \AR<br />
\DC \DL \DR<br />
\VL \smash{\sum_0^N} \VL b \VL \AR<br />
\DC \DL \DR<br />
\VL \VL c \VL \AR<br />
\HL<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
<br />
==Table as Floating Object==<br />
<br />
<texcode><br />
\placetable[here][tab:sample]{sample table}{<br />
\starttable ...<br />
\stoptable<br />
}<br />
</texcode><br />
<br />
* See [[Floating Objects]] in general.<br />
* If you need information about <cmd>placetable</cmd> look after <cmd>placefloat</cmd> in the manual or texshow!<br />
* If you'd like to leave out the table's caption (here: "sample table"), you can't simply leave the braces empty but must write <tt>none</tt>!<br />
<br />
==Background Colors==<br />
<br />
A very nice application in table are background colors for rows/cells (a feature that doesn't work in [[Tabulate]]):<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\setupcolors[state=start]<br />
\starttable[|l|l|]<br />
\HL<br />
\BL[1]\SR<br />
\NC Command \NC Meaning \NC\SR<br />
\HL<br />
\NC \tex{NC} \NC next column \NC\FR<br />
\NC \tex{NR} \NC next row \NC\LR<br />
\HL<br />
\CL[green]\SR<br />
\NC \tex{AR} \NC automatic row\NC\SR<br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\setupcolors[state=start]<br />
\starttable[|l|l|]<br />
\HL<br />
\BL[1]\SR<br />
\NC Command \NC Meaning \NC\SR<br />
\HL<br />
\NC \tex{NC} \NC next column \NC\FR<br />
\NC \tex{NR} \NC next row \NC\LR<br />
\HL<br />
\CL[green]\SR<br />
\NC \tex{AR} \NC automatic row\NC\SR<br />
\HL<br />
\stoptable<br />
</context><br />
</td><br />
</tr></table><br />
The commands work something like this: first, you say what background colour you want for the next row<br />
and then you typeset the row. Observe: the line with the colour-command and the row it is supposed<br />
to colour should end in the same command (i.e. both \SR, \LR, \FR, ...). If they don't, the background<br />
won't cover the whole cell.<br />
<br />
* <cmd>BL</cmd> makes a gray background: the optional argument tells BL how many cells it should color<br />
* <cmd>CL</cmd> makes a colored row<br />
<br />
==Fit Table Width==<br />
<br />
Hans posted a solution to the list for fitting a wide table (with paragraphs and vertical lines) to the page width. The key to his solution is the <code>.45\textwidth</code> settings when setting each cell as a paragraph.<br />
<br />
<texcode><br />
\SetTableToWidth{\textwidth}<br />
<br />
\starttable[|p(.45\textwidth)|p(.45\textwidth)|]<br />
\HL<br />
\VL foo foo foo foo foo foo \VL bar bar bar bar bar bar \VL\AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
<!-- It makes no sense to typeset this here. --><br />
<br />
== Booktabs ==<br />
<br />
Latex has an excellent package called booktabs for typesetting tables. The main features of that package is that you can have top, mid, and bottom rules of different thickness. It is possible to achieve similar effects using tables. For example, to match the default settings of booktabs (Well almost, this gives a top and bottom rules of 0.09em while booktabs sets it to 0.08em).<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\setuptables[rulethickness=0.03em]<br />
<br />
\starttable[s0|l|i2l|i2r|]<br />
\HL[3]<br />
\NC \Use2[c]{Item} \NC \NC \AR<br />
\DL[2] \DC \DR<br />
\NC Animal \NC Description \NC Price (\$) \NC \AR<br />
\HL[2]<br />
\NC Gnat \NC per gram \NC 13.65 \NC \AR<br />
\NC \NC each \NC 0.01 \NC \AR<br />
\NC Gnu \NC stuffed \NC 92.50 \NC \AR<br />
\NC Emu \NC stuffed \NC 33.33 \NC \AR<br />
\NC Armadillo \NC frozen \NC 8.99 \NC \AR<br />
\HL[3]<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\setuptables[rulethickness=0.03em]<br />
<br />
\starttable[s0|l|i2l|i2r|]<br />
\HL[3]<br />
\NC \Use2[c]{Item} \NC \NC \AR<br />
\DL[2] \DC \DR<br />
\NC Animal \NC Description \NC Price (\$) \NC \AR<br />
\HL[2]<br />
\NC Gnat \NC per gram \NC 13.65 \NC \AR<br />
\NC \NC each \NC 0.01 \NC \AR<br />
\NC Gnu \NC stuffed \NC 92.50 \NC \AR<br />
\NC Emu \NC stuffed \NC 33.33 \NC \AR<br />
\NC Armadillo \NC frozen \NC 8.99 \NC \AR<br />
\HL[3]<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
[[Category:Tables]]</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Fonts_in_LuaTeX&diff=9817Fonts in LuaTeX2009-06-04T17:09:27Z<p>Nicolas Girard: /* Using fonts */ +infos on installing/loading typescripts, according to the ongoing thread in the mailing-list</p>
<hr />
<div>{{note|This page is not finished yet}}<br />
<br />
'''Please, someone, fill this page !'''<br />
<br />
'''This page is beeing regorganized'''<br />
<br />
= Getting access to the system fonts =<br />
<br />
LuaTeX can use non-TeX fonts (in OpenType, TrueType or Type1 format) directly.<br />
<br />
The first time that you run<br />
<br />
context myfile.tex<br />
<br />
on a file that uses such non-traditional fonts (which is probably always), the actual fonts themselves have to be loaded in luatex's embedded section of fontforge to extract their metric information. This removes the need for tfm and vf files on your disk, but it is also a somewhat lengthy and often memory-hungry process.<br />
<br />
That is why the results of that internal preprocessing are also saved inside the texmf cache. Future runs using the same font (not just this file, but all files using that particular font) can then use the cached version of the metrics instead. <br />
<br />
== Building the font database ==<br />
<br />
You need to specify where the fonts should be looked for, by setting the <code>OSFONTDIR</code> environment variable. For instance,<br />
set OSFONTDIR=c:/windows/fonts/<br />
if the fonts should be found in <code>c:/windows/fonts/</code>; or<br />
export OSFONTDIR="/usr/local/share/fonts;$HOME/.fonts"<br />
if the fonts should be found in both <code>/usr/local/share/fonts</code> and <code>$HOME/.fonts</code>.<br />
<br />
The font database will then be automatically generated in the next run of <code>context</code><br />
<br />
You can also generate it manually by typing <br />
mtxrun --script font --reload<br />
or equally<br />
mtxrun --script fonts --reload<br />
<br />
The output should look like<br />
MTXrun | fontnames: identifying tree font files with suffix otf<br />
MTXrun | fontnames: identifying tree font files with suffix OTF<br />
MTXrun | fontnames: 331 tree files identified, 332 hash entries added, runtime 7.653 seconds<br />
MTXrun | fontnames: identifying tree font files with suffix ttf<br />
MTXrun | fontnames: identifying tree font files with suffix TTF<br />
MTXrun | fontnames: 17 tree files identified, 14 hash entries added, runtime 4.645 seconds<br />
...<br />
MTXrun | fontnames: 94 system files identified, 94 hash entries added, runtime 0.554 seconds<br />
MTXrun | fontnames: 3837 files read, 3342 normal and 49 extra entries added, 5 rejected, 3386 valid<br />
<br />
<br />
<br />
== Querying the font database ==<br />
<br />
The command<br />
mtxrun --script fonts --list<br />
will return the whole entries of the font database as a list, such as<br />
<br />
...<br />
warnockprobold WarnockPro-Bold E:/Fonts/Warnock Pro/WarnockPro-Bold.otf<br />
warnockproboldcapt WarnockPro-BoldCapt E:/Fonts/Warnock Pro/WarnockPro-BoldCapt.otf<br />
warnockprobolddisp WarnockPro-BoldDisp E:/Fonts/Warnock Pro/WarnockPro-BoldDisp.otf<br />
warnockproboldit WarnockPro-BoldIt E:/Fonts/Warnock Pro/WarnockPro-BoldIt.otf<br />
warnockprobolditcapt WarnockPro-BoldItCapt E:/Fonts/Warnock Pro/WarnockPro-BoldItCapt.otf<br />
warnockprobolditdisp WarnockPro-BoldItDisp E:/Fonts/Warnock Pro/WarnockPro-BoldItDisp.otf<br />
warnockprobolditsubh WarnockPro-BoldItSubh E:/Fonts/Warnock Pro/WarnockPro-BoldItSubh.otf<br />
warnockproboldsubh WarnockPro-BoldSubh E:/Fonts/Warnock Pro/WarnockPro-BoldSubh.otf<br />
...<br />
<br />
You can query the database against a particular pattern. For instance,<br />
mtxrun --script fonts --list --pattern=Delicious*<br />
will return<br />
deliciousbold Delicious-Bold /usr/local/share/fonts/d/delicious_bold.otf<br />
deliciousbolditalic Delicious-BoldItalic /usr/local/share/fonts/d/delicious_bolditalic.otf<br />
deliciousheavy Delicious-Heavy /usr/local/share/fonts/d/delicious_heavy.otf<br />
deliciousitalic Delicious-Italic /usr/local/share/fonts/d/delicious_italic.otf<br />
deliciousroman Delicious-Roman /usr/local/share/fonts/d/delicious_roman.otf<br />
delicioussmallcaps Delicious-SmallCaps /usr/local/share/fonts/d/delicious_smallcaps.otf<br />
<br />
You can get useful informations about your fonts by using the <code>--info</code> option. For instance,<br />
mtxrun --script fonts --list --info --pattern=Delicious*Roman<br />
will return<br />
MTXrun | fontname: deliciousroman<br />
MTXrun | fullname: Delicious-Roman<br />
MTXrun | filename: /usr/local/share/fonts/d/delicious_roman.otf<br />
MTXrun |<br />
MTXrun | gpos features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | kern latn dflt<br />
MTXrun |<br />
MTXrun | gsub features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | tlig all all<br />
MTXrun | trep all all<br />
<br />
== Installing new fonts ==<br />
<br />
After installing new fonts, the font database must be rebuilt for LuaTeX to access them.<br />
<br />
In current versions of Mark IV (earlier than July 2008) this is automatically done whenever a named font cannot be found.<br />
<br />
You only have to do the reload manually when you have installed updates to already installed fonts that cause the font and/or file names to change. <br />
This normally only happens for fonts that are still in development like [[TeX Gyre]] and [[Latin Modern]].<br />
<br />
You can rebuild the database manually, using the already-mentioned command<br />
mtxrun --script fonts --reload<br />
<br />
Alternatively, you can turn off the automatic rebuild of the database, by setting either of<br />
MTX.FONTS.AUTOLOAD<br />
MTX_FONTS_AUTOLOAD<br />
to "no".<br />
<br />
== References ==<br />
<br />
[http://context.aanhet.net/svn/contextman/context-reference/en/co-fonts.pdf The new manual chapter on fonts]<br />
<br />
= Using fonts =<br />
<br />
Handling fonts in LuaTeX can be done<br />
* in a simple but limited way, using the <code>simplefonts</code> module;<br />
* in the standard way, using [[TypeScripts]]<br />
<br />
== With the <code>simplefonts</code> module ==<br />
<br />
<code>simplefonts</code> is a third-party module written by Wolfgang Schuster.<br />
<br />
It simplifies the use of fonts in LuaTeX by<br />
* freeing the user from writing or using [[TypeScripts]];<br />
* offering an interface similar to the [http://www.ctan.org/tex-archive/macros/xetex/latex/fontspec/ fontspec package for XeTeX]<br />
<br />
For instance, assuming the [http://www.josbuivenga.demon.nl/delicious.html Delicious fonts] are properly installed and recognized by ConTeXt, you can simply write:<br />
<br />
<texcode><br />
\usemodule[simplefonts] % load the module<br />
\setmainfont[Delicious] % set Delicious as main (serif) font<br />
<br />
\starttext<br />
\rm\tf roman \it italic \bf bold \bi bolditalic \sc smallcaps<br />
\stoptext<br />
</texcode><br />
<br />
== The standard way: Typescripts ==<br />
<br />
=== Installing typescripts ===<br />
<br />
Installing typescripts consists in the following:<br />
<br />
1. Copy the typescript files into either <br />
<texcode>$TEXMF/tex/texmf-fonts/tex/context/user<br />
$TEXMF/tex/texmf-project/tex/context/user</texcode><br />
2. Run <code>context --generate<br />
<br />
By convention, typescript files are named like <code>type-(fontname|foundry).tex</code>. <br />
<br />
It may happen that some <code>type-xx.tex</code> typescript file depends on mkiv-specific code located in a matching <code>type-xx.mkiv</code> file. In this case, both files need to be installed.<br />
<br />
=== Loading typescripts ===<br />
<br />
A typescript file named <code>type-xx.tex</code> should be loaded using<br />
\usetypescriptfile[type-xx]<br />
<br />
An alternative way is<br />
\usetypefile[xx]<br />
where ConTeXt prepends <code>type-</code> when it loads the file; but <br />
<cmd>usetypescriptfile</cmd> is the preferred command because it takes care of the<br />
<cmd>starttypescriptcollection</cmd>/<cmd>stoptypescriptcollection</cmd> environments.<br />
<br />
=== Where to find existing typescripts ===<br />
<br />
Each of the typescripts below defines a keyword to use with <cmd>setupbodyfont</cmd>. Usually this is the same as the name of the typescript, but there is one exception (<code>antykwa-torunska</code>)<br />
<br />
* Latin Modern (typescript name: <code>modern</code>; this is the default font set)<br />
* Latin Modern variant (ts name: <code>modernvariable</code>; LM variable typewriter for serif)<br />
* Postscript (ts name: <code>postscript</code>; Termes for serif, Heros for sans, Cursor for mono)<br />
* Antykwa Toruńska (ts name: <code>antykwa-torunska</code>; only serif; defines <tt>antykwa</tt> as keyword for <cmd>setupbodyfont</cmd>)<br />
* Iwona (ts name: <code>iwona</code>; only sans serif)<br />
* Iwona Light, Medium and Heavy (ts names: <code>iwona-light</code>, <code>iwona-medium</code>, <code>iwona-heavy</code>; only sans; the medium variant is a small bit heavier than a "regular" one)<br />
* Pagella (ts name: <code>palatino</code>; only serif)<br />
* Termes (ts name: <code>times</code>; only serif, Heros for sans)<br />
<br />
== Usage example ==<br />
<br />
<texcode><br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,18pt]<br />
<br />
\starttext<br />
Hello world, I'm Pagella!<br />
\stoptext<br />
</texcode><br />
<br />
The first line seems to order ConTeXt to "install" (for the current file) the given typescript (it accepts what I have earlier called a "typescript name"). The last one starts using it (you may omit the size if you are satisfied with the default).<br />
<br />
== Combining predefined fonts in your own typescripts ==<br />
<br />
It is also possible to combine fonts from the TeX Gyre collection in your own typescripts. The example below combines Bonum (Bookman) roman, Adventor (AvantGarde) for sans serif, Cursor (Courier) for teletype, and Euler for math. The <code>rscale=...</code> option ensures that all fonts have the same x-height. (You can lookup the relative x-heigt of a font using fontforge.)<br />
<br />
<texcode><br />
\starttypescript [Bonum]<br />
\definetypeface [Bonum] [rm] [serif] [bonum] [default]<br />
\definetypeface [Bonum] [ss] [sans] [adventor] [default] [rscale=0.887]<br />
\definetypeface [Bonum] [tt] [mono] [cursor] [default] [rscale=1.163]<br />
\definetypeface [Bonum] [mm] [math] [euler] [default] [rscale=1.050]<br />
\stoptypescript<br />
<br />
\usetypescript[Bonum]<br />
\setupbodyfont[Bonum,12pt]<br />
<br />
\starttext<br />
Hello world, I'm Bonum!<br />
\stoptext<br />
</texcode><br />
<br />
= Old contents =<br />
<br />
* [[TrueType fonts in luaTeX]]<br />
<br />
==== Good ol' typescripts ====<br />
<br />
Of course, Mark IV allows you to use typescripts as you've always done; for example:<br />
<br />
<texcode><br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,12pt]<br />
effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
<br />
\sc effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
</texcode><br />
<br />
That's as simple as using a traditional ConTeXt typescript!<br />
<br />
But ... how is it any different, then? Well, the difference is that in Mark IV, we can use an Opentype font directly, so that what is done here: when we want to use Palatino, the [[TeX Gyre]] equivalent (“Pagella”) is called and we can use its Opentype “features”; read on.<br />
<br />
==== Opentype features ====<br />
<br />
A “feature”, in the Opentype jargon, is a set of rules describing changes in the appearance of the text. Hmm, that's not very precise. Let's show some examples. First of all, you have to know that features are referred to by 4-letter tags, and you will see this a lot. One of them is ‘smcp‘, for “small caps“. Let's consider the following Mark IV-only code:<br />
<br />
<texcode><br />
\definefontfeature[smallcaps][language=DFLT,script=latn,smcp=yes]<br />
\font\palasmallcaps=texgyrepagella-regular*smallcaps<br />
\palasmallcaps This is a text in small capitals.<br />
</texcode><br />
<br />
Here you basically define a (Mark IV) feature with the name ”smallcaps”, and associate it with the (Opentype) feature “smcp”. You have to specify which script you want to use it with; scripts in Opentype are also tagged with four letters, and “latn” is of course Latin.<br />
<br />
Then you define a TeX font with that feature.<br />
<br />
You can see what features are defined in a particular font with the following bit of code<br />
<br />
<texcode><br />
\ctxlua<br />
{<br />
fontname = 'texgyrepagella-regular.otf'<br />
<br />
--[[ First read the font data.<br />
This makes heavy use of some of the Mark IV code]]<br />
tfmdata = fonts.tfm.read_and_define("file:" .. fontname, 655360)<br />
font = tfmdata.shared.otfdata<br />
if font<br />
then<br />
gsubfeatures = fonts.otf.analyze_features(font.gsub)<br />
gposfeatures = fonts.otf.analyze_features(font.gpos)<br />
end<br />
<br />
if gsubfeatures then<br />
table.sort(gsubfeatures) % We want our list sorted alphabetically!<br />
tex.sprint("\\rm GSUB features: \\tt ") % Beware: you don't want \rm to be interpreted by lua (\rm would yield carriage return + letter m)!<br />
for _, feat in ipairs(gsubfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GSUB features")<br />
end<br />
tex.sprint("\\par")<br />
<br />
if gposfeatures then<br />
tex.sprint("\\rm GPOS features: \\tt ")<br />
table.sort(gposfeatures)<br />
for _, feat in ipairs(gposfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GPOS features")<br />
end<br />
}<br />
</texcode><br />
<br />
It prints the list on the page. You'll notice there are two sets of features, each one of them defined in a different table of the Opentype font: the <code>GSUB</code> table (for Glyph SUBstitution) gives rules for replacing glyphs in certains circumstances (think of ligatures: f + i -> fi); the <code>GPOS</code> table (Glyph POSititioning) gives rules for moving glyphs (think of kerning: A + V -> A <kerning> V).<br />
<br />
Incidentally, the above code gives some basic examples of LuaTeX programming, a mixture of both Lua and TeX programming with some special features (features in the general sense, not the Opentype one :-).<br />
<br />
==== A (Complete) Typescript Example ====<br />
<br />
<texcode><br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [FranklinBookRegular] [name:FranklinGothicBookITC-Regular] [features=default]<br />
\definefontsynonym [FranklinMediumRegular] [name:FranklinGothicMediumITC-Regular] [features=default]<br />
\definefontsynonym [FranklinDemiRegular] [name:FranklinGothicDemiITC-Regular] [features=default]<br />
\definefontsynonym [FranklinHeavyRegular] [name:FranklinGothicHeavyITC-Regular] [features=default]<br />
<br />
\definefontsynonym [FranklinBookItalic] [name:FranklinGothicBookITC-Italic] [features=default]<br />
\definefontsynonym [FranklinDemiItalic] [name:FranklinGothicMediumITC-Italic] [features=default]<br />
\definefontsynonym [FranklinHeavyItalic] [name:FranklinGothicDemiITC-Italic] [features=default]<br />
\definefontsynonym [FranklinMediumItalic] [name:FranklinGothicHeavyITC-Italic] [features=default]<br />
<br />
\stoptypescript<br />
<br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [Sans] [FranklinBookRegular] [features=default]<br />
\definefontsynonym [SansItalic] [FranklinBookItalic] [features=default]<br />
\definefontsynonym [SansBold] [FranklinDemiRegular] [features=default]<br />
\definefontsynonym [SansBoldItalic] [FranklinDemiItalic] [features=default]<br />
\definefontsynonym [SansSlanted] [SansItalic] [features=default]<br />
\definefontsynonym [SansBoldSlanted] [SansBoldItalic] [features=default]<br />
\definefontsynonym [SansCaps] [Sans] [features=smallcaps]<br />
<br />
\stoptypescript<br />
<br />
\definetypeface[franklin][rm][sans][franklin][default]<br />
\definetypeface[franklin][ss][sans][franklin][default]<br />
\definetypeface[franklin][tt][mono][modern] [default][rscale=1.12]<br />
\definetypeface[franklin][mm][math][iwona] [default][rscale=1.02]<br />
<br />
\setupbodyfont[franklin,ss,10pt]<br />
</texcode><br />
<br />
<br />
<br />
Just the simplest way to use an otf font — or any font that does appear in <tt>mtxrun --script font --list</tt> — in all the document.<br />
<br />
I’m stick here :<br />
<br />
\definefontfeature [myfontfeature] [method=node, kern=yes, OTHER_FEATURE_COMMA_SEPERATED]<br />
\definefontsynonym [MyFontRegular] [name:TheFontName-Regular][features=myfontfeature]<br />
\definedfont [MyFontRegular at 16pt]<br />
<br />
This doesn’t run for my title which use « \tfc », only for the body of the text.<br />
<br />
*\definefontfeature<br />
**[myfontfeature] : you can use the name you want. It will be use at the next line ;<br />
**the fonts feature can be found with <tt>otfinfo -f TheFontFile.otf</tt>.<br />
*\definefontsynonym :<br />
**[MyFontRegular] : you can use the name you want. It will be use at the next line ;<br />
**The name after <tt>name:</tt> is the name given by <tt>mtxrun --script font --list</tt><br />
**The « name: » part can be replaced by <tt>file:TheFontFile.otf</tt><br />
<br />
<br />
== Example ==<br />
<br />
<br />
Now to access, say the regular warnock font, the following are valid. And I ought to mention that Hans recommends the first http://article.gmane.org/gmane.comp.tex.context/43685.<br />
<br />
<texcode><br />
% Hans recommends this format;<br />
\definefontsynonym [WarnockPro-Regular] [name:warnockproregular] <br />
</texcode><br />
<br />
and<br />
<br />
<texcode><br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular]<br />
</texcode><br />
<br />
An entire typescript would be defined as;<br />
<br />
<texcode><br />
\definefontfeature[latin-smallcaps][smallcaps][script=latn]<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\setups[font:fallback:sans]<br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular] <br />
\definefontsynonym [WarnockPro-Bold] [name:WarnockPro-Bold] <br />
\definefontsynonym [WarnockPro-Italic] [name:WarnockPro-It] <br />
\definefontsynonym [WarnockPro-BoldItalic] [name:WarnockPro-BoldIt] <br />
\stoptypescript<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\definefontsynonym [Serif] [WarnockPro-Regular] [features=default]<br />
\definefontsynonym [SerifBold] [WarnockPro-Bold] [features=default]<br />
\definefontsynonym [SerifItalic] [WarnockPro-Italic] [features=default]<br />
\definefontsynonym [SerifBoldItalic] [WarnockPro-BoldItalic] [features=default]<br />
\definefontsynonym [SerifCaps] [Serif] [features=latin-smallcaps]<br />
\stoptypescript<br />
<br />
\definetypeface[adobe][rm][serif][warnockpro][default]<br />
\setupbodyfont[adobe,11pt]<br />
<br />
</texcode><br />
<br />
[[Category:Fonts]]<br />
[[Category:International]]</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Tabulate&diff=9816Tabulate2009-06-04T08:42:52Z<p>Nicolas Girard: /* Basic commands */ Slightly changed layout</p>
<hr />
<div>< [[Tables Overview]] | [[Table]] ><br />
<br />
== Basic commands ==<br />
<br />
Rather simple tabulating. You ''need'' the bars in the formatting field of <cmd>starttabulate</cmd>! '''If you want vertical lines, you need another table mode''' (see [[Tables]]).<br />
<br />
This is especially suited if you want to have paragraphs in one (or more) of the tabulate columns.<br />
<br />
The sample describes the formatting characters:<br />
{|<br />
! width="55%"|<br />
! width="10%"|<br />
! width="35%"|<br />
|-<br />
| <texcode><br />
\starttabulate[|l|l|]<br />
\HL<br />
\NC format \NC meaning \NC\NR<br />
\HL<br />
\NC c \NC centered \NC\NR<br />
\NC l \NC left aligned \NC\NR<br />
\NC r \NC right aligned \NC\NR<br />
\NC w(1cm) \NC one line, fixed width \NC\NR<br />
\NC p(2cm) \NC paragraph, lines broken to fixed width \NC\NR<br />
% You can leave out the \NC before \NR<br />
\HL<br />
\stoptabulate<br />
</texcode><br />
|<br />
|<context><br />
\starttabulate[|l|l|]<br />
\HL<br />
\NC format \NC meaning \NC\NR<br />
\HL<br />
\NC c \NC centered \NC\NR<br />
\NC l \NC left aligned \NC\NR<br />
\NC r \NC right aligned \NC\NR<br />
\NC w(1cm) \NC one line, fixed width \NC\NR<br />
\NC p(2cm) \NC paragraph, lines broken to fixed width \NC\NR<br />
% You can leave out the \NC before \NR<br />
\HL<br />
\stoptabulate<br />
</context><br />
|}<br />
<br />
* HL is horizontal line<br />
* NC is new column (or new cell)<br />
* NR is new row<br />
<br />
== Column Spans ==<br />
<br />
Tabulate has no support for column spans but you could add this function yourself.<br />
<br />
The code to do this depends on the tabulate setting and you have to know what<br />
content what column setting you need.<br />
<br />
=== Single row columns ===<br />
<br />
To span columns in cells with <code>l</code>, <code>r</code> or <code>c</code><br />
you could use <code>\span\omit\span\omit\span\omit</code> for each cell.<br />
<br />
You could prevent these values you could them in a macro and use it with<br />
<code>\use{2}</code> or <code>\TWO</code> in the tabulate environment.<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\def\tabulateuse#1%<br />
{\dorecurse{\numexpr2*#1-1\relax}{\span\omit}}<br />
<br />
\appendtoks<br />
\let\use\tabulateuse<br />
\defineTABLEshorthands<br />
\to \everytabulate<br />
<br />
\starttext<br />
<br />
\starttabulate[|l|Br|l|l|]<br />
\NC a \NC b \NC c \NC d \NR<br />
\NC 1 \NC 2 \TWO \NC 4 \NR<br />
\stoptabulate<br />
<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\def\tabulateuse#1%<br />
{\dorecurse{\numexpr2*#1-1\relax}{\span\omit}}<br />
<br />
\appendtoks<br />
\let\use\tabulateuse<br />
\defineTABLEshorthands<br />
\to \everytabulate<br />
<br />
\starttext<br />
<br />
\starttabulate[|l|Br|l|l|]<br />
\NC a \NC b \NC c \NC d \NR<br />
\NC 1 \NC 2 \TWO \NC 4 \NR<br />
\stoptabulate<br />
<br />
\stoptext<br />
</context><br />
|}<br />
<br />
=== Paragraph columns ===<br />
<br />
For spanned columns in cells with paragraphs you need a different implementation.<br />
<br />
To use this macro you have to take care about a few things:<br />
<br />
* You have to set a width for each cell<br />
* The format for the spanned column is fixed and you have to change it in the macro<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\def\tabulateuse#1%<br />
{\dorecurse{\numexpr2*#1-1\relax}{\span\omit}\raggedright\ignorespaces}<br />
<br />
\appendtoks<br />
\let\use\tabulateuse<br />
\defineTABLEshorthands<br />
\to \everytabulate<br />
<br />
\starttext<br />
<br />
\starttabulate[|p(2cm)|p(3cm)|p(4cm)|]<br />
\NC \dorecurse{10}{text } \NC \dorecurse{4}{Lorem Ipsum } \NC<br />
\dorecurse{18}{text } \NC\NR<br />
\NC \TWO Short text spanning two tabulate paragraphs. \NC<br />
\dorecurse{17}{text } \NC\NR<br />
\stoptabulate<br />
<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\def\tabulateuse#1%<br />
{\dorecurse{\numexpr2*#1-1\relax}{\span\omit}\raggedright\ignorespaces}<br />
<br />
\appendtoks<br />
\let\use\tabulateuse<br />
\defineTABLEshorthands<br />
\to \everytabulate<br />
<br />
\starttext<br />
\switchtobodyfont[8pt]<br />
<br />
\starttabulate[|p(2cm)|p(3cm)|p(4cm)|]<br />
\NC \dorecurse{10}{text } \NC \dorecurse{4}{Lorem Ipsum } \NC<br />
\dorecurse{18}{text } \NC\NR<br />
\NC \TWO Short text spanning two tabulate paragraphs. \NC<br />
\dorecurse{17}{text } \NC\NR<br />
\stoptabulate<br />
<br />
\stoptext<br />
</context><br />
|}<br />
[[Category:Tables]]</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=TypeScripts_-_Old_Content&diff=9815TypeScripts - Old Content2009-06-04T08:21:41Z<p>Nicolas Girard: /* Links */ Corrected link</p>
<hr />
<div>< [[Fonts]] ><br />
<br />
Typescripts are the ConTeXt way of using fonts and defining font families.<br />
<br />
Beware, the examples on this page work only with MkII / pdfTeX (i.e. neither XeTeX nor LuaTeX).<br />
<br />
==Basics==<br />
<br />
Sample typescript for the free text font [http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&item_id=Gentium Gentium]. Installation instructions are at [[Installing a TrueType font, step by step]].<br />
A typescript must live in your project folder or in another folder in your ConTeXt path (e.g., <tt>(texmf)/tex/context/user</tt>)<br />
<br />
<texcode><br />
% type-sil-gentium.tex<br />
% Typescript for serif family SIL Gentium<br />
<br />
% load mapfile<br />
\starttypescript [map] [gentium] [\defaultencoding]<br />
\loadmapfile [\defaultencoding-sil-gentium.map]<br />
\stoptypescript<br />
<br />
% mapping from PostScript name (or visible font name, if it's a TrueType font) to TFM file name<br />
% The second argument means that these names are loaded with either the 'gentium'<br />
% or 'gentium-alt' names.<br />
\starttypescript [serif] [gentium, gentium-alt] [\defaultencoding] % mapping is used by two "name" typescripts<br />
\definefontsynonym [GentiumAlt-Italic] [\defaultencoding-genai101][encoding=\defaultencoding]<br />
\definefontsynonym [GentiumAlt] [\defaultencoding-genar101][encoding=\defaultencoding]<br />
\definefontsynonym [Gentium-Italic] [\defaultencoding-geni101][encoding=\defaultencoding]<br />
\definefontsynonym [Gentium] [\defaultencoding-genr101][encoding=\defaultencoding]<br />
\stoptypescript<br />
<br />
% mapping from generic family name to PostScript name<br />
\starttypescript [serif] [gentium] [name]<br />
\definefontsynonym [Serif] [Gentium]<br />
\definefontsynonym [SerifItalic] [Gentium-Italic]<br />
\stoptypescript<br />
<br />
% additional mapping to alternate glyphs, not further used<br />
\starttypescript [serif] [gentium-alt] [name]<br />
\definefontsynonym [Serif] [GentiumAlt]<br />
\definefontsynonym [SerifItalic] [GentiumAlt-Italic]<br />
\stoptypescript<br />
<br />
% sample family definition<br />
% here we define only the serif (rm) version.<br />
\starttypescript [my] [sil-gentium]<br />
\definetypeface [sil-gentium] [rm] [serif] [gentium] [default][encoding=\defaultencoding]<br />
% \definetypeface [sil-gentium] [ss] [sans] [default] [default][encoding=\defaultencoding]<br />
% \definetypeface [sil-gentium] [tt] [mono] [default] [default][encoding=\defaultencoding]<br />
% \definetypeface [sil-gentium] [mm] [math] [default] [default][encoding=\defaultencoding]<br />
\stoptypescript<br />
</texcode><br />
<br />
The multiple mapping is not strictly needed, but increases flexibility.<br />
<br />
To use your new typescript, write the following in your environment file (or single TeX file):<br />
<br />
<texcode><br />
\setupencoding[default=ec] % defines \defaultencoding<br />
\usetypescriptfile[type-sil-gentium]<br />
\usetypescript[my][sil-gentium]<br />
\setupbodyfont [sil-gentium, rm, 12pt]<br />
<br />
\setupbodyfontenvironment[default] [em=italic] % slanted is default emphasize in ConTeXt<br />
</texcode><br />
<br />
The map file was written by [[texfont]] and lives in <tt>(texmf)/fonts/map/pdftex/context</tt>.<br />
It combines raw TFM (metrics), PostScript name, font file and encoding<br />
<texcode><br />
% ec-sil-gentium.map<br />
ec-raw-genai101 GentiumAlt-Italic 4 < genai101.pfb ec.enc<br />
ec-raw-genar101 GentiumAlt 4 < genar101.pfb ec.enc<br />
ec-raw-geni101 Gentium-Italic 4 < geni101.pfb ec.enc<br />
ec-raw-genr101 Gentium 4 < genr101.pfb ec.enc<br />
</texcode><br />
<br />
==The next step: making it more generic==<br />
<br />
If you'd like to write a typescript that handles many more encodings, somewhat more generically, here is one model to build upon:<br />
<texcode><br />
% type-sil-gentium.tex<br />
% Typescript for serif family SIL Gentium<br />
<br />
% This is the first change we need to make: we list all the encodings it can match,<br />
% and then use that data within the typescript:<br />
\starttypescript [map] [gentium] [ec,texnansi,8r,t5,t2a,t2b,qx]<br />
\loadmapfile [\typescriptthree-sil-gentium.map]<br />
\stoptypescript<br />
<br />
% We use the same technique. As the encoding variable shows up in the third<br />
% argument, we use \typescriptthree.<br />
\starttypescript [serif] [gentium] [ec,texnansi,8r,t5,t2a,t2b,qx]<br />
\definefontsynonym [GentiumAlt-Italic] [\typescriptthree-genai101][encoding=\typescriptthree]<br />
\definefontsynonym [GentiumAlt] [\typescriptthree-genar101][encoding=\typescriptthree]<br />
\definefontsynonym [Gentium-Italic] [\typescriptthree-geni101] [encoding=\typescriptthree]<br />
\definefontsynonym [Gentium] [\typescriptthree-genr101] [encoding=\typescriptthree]<br />
\stoptypescript<br />
<br />
% Getting fancy: occasionally you want to access alternates from the main font:<br />
\starttypescript [serif] [gentium] [name]<br />
\setups [font:fallback:serif] % We use the new (and fast loading) font fallbacks to cover bold markup.<br />
\definefontsynonym [Serif] [Gentium]<br />
\definefontsynonym [SerifItalic] [Gentium-Italic]<br />
% Gentium contains only two faces, so we map everything else on Italic<br />
\definefontsynonym [SerifSlanted] [SerifItalic]<br />
\definefontsynonym [SerifBoldItalic] [SerifItalic]<br />
\definefontsynonym [SerifCaps] [SerifItalic]<br />
\definefontsynonym [SerifBoldCaps] [SerifItalic]<br />
<br />
% markup of \Var[alt] results in a (subtle) font switch (Gentium's alternate glyphs change only some diacritics):<br />
\definefontvariant [Serif] [alt] [Alt]<br />
% unfortunately you need to define eight synonyms to handle the fallback cases:<br />
\definefontsynonym [SerifRegular] [Serif]<br />
\definefontsynonym [SerifRegularAlt] [GentiumAlt] % you must define "Regular" for every additional variant<br />
\definefontsynonym [SerifBoldAlt] [GentiumAlt]<br />
\definefontsynonym [SerifCapsAlt] [GentiumAlt]<br />
\definefontsynonym [SerifItalicAlt] [GentiumAlt-Italic]<br />
\definefontsynonym [SerifSlantedAlt] [GentiumAlt-Italic]<br />
\definefontsynonym [SerifBoldItalicAlt] [GentiumAlt-Italic]<br />
\definefontsynonym [SerifBoldSlantedAlt] [GentiumAlt-Italic]<br />
\stoptypescript<br />
<br />
% sample family definition<br />
% here we define only the serif (rm) version.<br />
\starttypescript [sil-gentium] [ec,texnansi,8r,t5,t2a,t2b,qx]<br />
\definetypeface [sil-gentium] [rm] [serif] [gentium] [default] [encoding=\typescripttwo]<br />
% \definetypeface [sil-gentium] [ss] [sans] [default] [default] [encoding=\typescripttwo]<br />
% \definetypeface [sil-gentium] [tt] [mono] [default] [default] [encoding=\typescripttwo]<br />
% \definetypeface [sil-gentium] [mm] [math] [default] [default] [encoding=\typescripttwo]<br />
\stoptypescript<br />
<br />
</texcode><br />
<br />
==Links==<br />
* [http://www.pragma-ade.com/general/manuals/showfont.pdf examples of using typescripts] by Pragma<br />
* [http://www.ramm.ch/fiee/texnique/?menu=0-1-4&amp;lang=en example typescripts] for free and commercial fonts, by Hraban (partly outdated)<br />
* Sample of [http://wiki.contextgarden.net/exljbris_typescript MkIV typescripts for exljbris fonts]<br />
* typescripts for some fonts from the FontSite500 CD on the [[Font Site]] page, by Holger Schöner<br />
* typescripts for lazy font combinations on the [[Flexi Face]] page<br />
* some pointers on extending typescripts to accommodate access to &ldquo;variants,&rdquo; like old-style figures, are on the [[Font Variants]] page<br />
* [[Fonts in XeTeX]] gives some details about the [[XeTeX]]-specific typescripts in <tt>type-xtx</tt><br />
<br />
[[Category:Fonts]]</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Tabulate&diff=9814Tabulate2009-06-03T21:29:45Z<p>Nicolas Girard: /* Single row columns */ Added ConTeXt output</p>
<hr />
<div>< [[Tables Overview]] | [[Table]] ><br />
<br />
== Basic commands ==<br />
<br />
Rather simple tabulating. You ''need'' the bars in the formatting field of <cmd>starttabulate</cmd>! '''If you want vertical lines, you need another table mode''' (see [[Tables]]).<br />
<br />
This is especially suited if you want to have paragraphs in one (or more) of the tabulate columns.<br />
<br />
The sample describes the formatting characters:<br />
<texcode><br />
\starttabulate[|l|l|]<br />
\HL<br />
\NC format \NC meaning \NC\NR<br />
\HL<br />
\NC c \NC centered \NC\NR<br />
\NC l \NC left aligned \NC\NR<br />
\NC r \NC right aligned \NC\NR<br />
\NC w(1cm) \NC one line, fixed width \NC\NR<br />
\NC p(2cm) \NC paragraph, lines broken to fixed width \NC\NR<br />
% You can leave out the \NC before \NR<br />
\HL<br />
\stoptabulate<br />
</texcode><br />
<br />
* HL is horizontal line<br />
* NC is new column (or new cell)<br />
* NR is new row<br />
<br />
The sample looks like this:<br />
<br />
<context><br />
\starttabulate[|l|l|]<br />
\HL<br />
\NC format \NC meaning \NC\NR<br />
\HL<br />
\NC c \NC centered \NC\NR<br />
\NC l \NC left aligned \NC\NR<br />
\NC r \NC right aligned \NC\NR<br />
\NC w(1cm) \NC one line, fixed width \NC\NR<br />
\NC p(2cm) \NC paragraph, lines broken to fixed width \NC\NR<br />
% You can leave out the \NC before \NR<br />
\HL<br />
\stoptabulate<br />
</context><br />
<br />
== Column Spans ==<br />
<br />
Tabulate has no support for column spans but you could add this function yourself.<br />
<br />
The code to do this depends on the tabulate setting and you have to know what<br />
content what column setting you need.<br />
<br />
=== Single row columns ===<br />
<br />
To span columns in cells with <code>l</code>, <code>r</code> or <code>c</code><br />
you could use <code>\span\omit\span\omit\span\omit</code> for each cell.<br />
<br />
You could prevent these values you could them in a macro and use it with<br />
<code>\use{2}</code> or <code>\TWO</code> in the tabulate environment.<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\def\tabulateuse#1%<br />
{\dorecurse{\numexpr2*#1-1\relax}{\span\omit}}<br />
<br />
\appendtoks<br />
\let\use\tabulateuse<br />
\defineTABLEshorthands<br />
\to \everytabulate<br />
<br />
\starttext<br />
<br />
\starttabulate[|l|Br|l|l|]<br />
\NC a \NC b \NC c \NC d \NR<br />
\NC 1 \NC 2 \TWO \NC 4 \NR<br />
\stoptabulate<br />
<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\def\tabulateuse#1%<br />
{\dorecurse{\numexpr2*#1-1\relax}{\span\omit}}<br />
<br />
\appendtoks<br />
\let\use\tabulateuse<br />
\defineTABLEshorthands<br />
\to \everytabulate<br />
<br />
\starttext<br />
<br />
\starttabulate[|l|Br|l|l|]<br />
\NC a \NC b \NC c \NC d \NR<br />
\NC 1 \NC 2 \TWO \NC 4 \NR<br />
\stoptabulate<br />
<br />
\stoptext<br />
</context><br />
|}<br />
<br />
=== Paragraph columns ===<br />
<br />
For spanned columns in cells with paragraphs you need a different implementation.<br />
<br />
To use this macro you have to take care about a few things:<br />
<br />
* You have to set a width for each cell<br />
* The format for the spanned column is fixed and you have to change it in the macro<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\def\tabulateuse#1%<br />
{\dorecurse{\numexpr2*#1-1\relax}{\span\omit}\raggedright\ignorespaces}<br />
<br />
\appendtoks<br />
\let\use\tabulateuse<br />
\defineTABLEshorthands<br />
\to \everytabulate<br />
<br />
\starttext<br />
<br />
\starttabulate[|p(2cm)|p(3cm)|p(4cm)|]<br />
\NC \dorecurse{10}{text } \NC \dorecurse{4}{Lorem Ipsum } \NC<br />
\dorecurse{18}{text } \NC\NR<br />
\NC \TWO Short text spanning two tabulate paragraphs. \NC<br />
\dorecurse{17}{text } \NC\NR<br />
\stoptabulate<br />
<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\def\tabulateuse#1%<br />
{\dorecurse{\numexpr2*#1-1\relax}{\span\omit}\raggedright\ignorespaces}<br />
<br />
\appendtoks<br />
\let\use\tabulateuse<br />
\defineTABLEshorthands<br />
\to \everytabulate<br />
<br />
\starttext<br />
\switchtobodyfont[8pt]<br />
<br />
\starttabulate[|p(2cm)|p(3cm)|p(4cm)|]<br />
\NC \dorecurse{10}{text } \NC \dorecurse{4}{Lorem Ipsum } \NC<br />
\dorecurse{18}{text } \NC\NR<br />
\NC \TWO Short text spanning two tabulate paragraphs. \NC<br />
\dorecurse{17}{text } \NC\NR<br />
\stoptabulate<br />
<br />
\stoptext<br />
</context><br />
|}<br />
[[Category:Tables]]</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Tabulate&diff=9813Tabulate2009-06-03T21:27:26Z<p>Nicolas Girard: /* Paragraph columns */ Added ConTeXt output</p>
<hr />
<div>< [[Tables Overview]] | [[Table]] ><br />
<br />
== Basic commands ==<br />
<br />
Rather simple tabulating. You ''need'' the bars in the formatting field of <cmd>starttabulate</cmd>! '''If you want vertical lines, you need another table mode''' (see [[Tables]]).<br />
<br />
This is especially suited if you want to have paragraphs in one (or more) of the tabulate columns.<br />
<br />
The sample describes the formatting characters:<br />
<texcode><br />
\starttabulate[|l|l|]<br />
\HL<br />
\NC format \NC meaning \NC\NR<br />
\HL<br />
\NC c \NC centered \NC\NR<br />
\NC l \NC left aligned \NC\NR<br />
\NC r \NC right aligned \NC\NR<br />
\NC w(1cm) \NC one line, fixed width \NC\NR<br />
\NC p(2cm) \NC paragraph, lines broken to fixed width \NC\NR<br />
% You can leave out the \NC before \NR<br />
\HL<br />
\stoptabulate<br />
</texcode><br />
<br />
* HL is horizontal line<br />
* NC is new column (or new cell)<br />
* NR is new row<br />
<br />
The sample looks like this:<br />
<br />
<context><br />
\starttabulate[|l|l|]<br />
\HL<br />
\NC format \NC meaning \NC\NR<br />
\HL<br />
\NC c \NC centered \NC\NR<br />
\NC l \NC left aligned \NC\NR<br />
\NC r \NC right aligned \NC\NR<br />
\NC w(1cm) \NC one line, fixed width \NC\NR<br />
\NC p(2cm) \NC paragraph, lines broken to fixed width \NC\NR<br />
% You can leave out the \NC before \NR<br />
\HL<br />
\stoptabulate<br />
</context><br />
<br />
== Column Spans ==<br />
<br />
Tabulate has no support for column spans but you could add this function yourself.<br />
<br />
The code to do this depends on the tabulate setting and you have to know what<br />
content what column setting you need.<br />
<br />
=== Single row columns ===<br />
<br />
To span columns in cells with <code>l</code>, <code>r</code> or <code>c</code><br />
you could use <code>\span\omit\span\omit\span\omit</code> for each cell.<br />
<br />
You could prevent these values you could them in a macro and use it with<br />
<code>\use{2}</code> or <code>\TWO</code> in the tabulate environment.<br />
<br />
<texcode><br />
\def\tabulateuse#1%<br />
{\dorecurse{\numexpr2*#1-1\relax}{\span\omit}}<br />
<br />
\appendtoks<br />
\let\use\tabulateuse<br />
\defineTABLEshorthands<br />
\to \everytabulate<br />
<br />
\starttext<br />
<br />
\starttabulate[|l|Br|l|l|]<br />
\NC a \NC b \NC c \NC d \NR<br />
\NC 1 \NC 2 \TWO \NC 4 \NR<br />
\stoptabulate<br />
<br />
\stoptext<br />
</texcode><br />
<br />
=== Paragraph columns ===<br />
<br />
For spanned columns in cells with paragraphs you need a different implementation.<br />
<br />
To use this macro you have to take care about a few things:<br />
<br />
* You have to set a width for each cell<br />
* The format for the spanned column is fixed and you have to change it in the macro<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\def\tabulateuse#1%<br />
{\dorecurse{\numexpr2*#1-1\relax}{\span\omit}\raggedright\ignorespaces}<br />
<br />
\appendtoks<br />
\let\use\tabulateuse<br />
\defineTABLEshorthands<br />
\to \everytabulate<br />
<br />
\starttext<br />
<br />
\starttabulate[|p(2cm)|p(3cm)|p(4cm)|]<br />
\NC \dorecurse{10}{text } \NC \dorecurse{4}{Lorem Ipsum } \NC<br />
\dorecurse{18}{text } \NC\NR<br />
\NC \TWO Short text spanning two tabulate paragraphs. \NC<br />
\dorecurse{17}{text } \NC\NR<br />
\stoptabulate<br />
<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\def\tabulateuse#1%<br />
{\dorecurse{\numexpr2*#1-1\relax}{\span\omit}\raggedright\ignorespaces}<br />
<br />
\appendtoks<br />
\let\use\tabulateuse<br />
\defineTABLEshorthands<br />
\to \everytabulate<br />
<br />
\starttext<br />
\switchtobodyfont[8pt]<br />
<br />
\starttabulate[|p(2cm)|p(3cm)|p(4cm)|]<br />
\NC \dorecurse{10}{text } \NC \dorecurse{4}{Lorem Ipsum } \NC<br />
\dorecurse{18}{text } \NC\NR<br />
\NC \TWO Short text spanning two tabulate paragraphs. \NC<br />
\dorecurse{17}{text } \NC\NR<br />
\stoptabulate<br />
<br />
\stoptext<br />
</context><br />
|}<br />
[[Category:Tables]]</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Color&diff=9812Color2009-06-03T15:09:58Z<p>Nicolas Girard: /* In TikZ */ Added context output of the example code</p>
<hr />
<div>< [[Visuals]] | [[Graphics]] ><br />
<br />
= Enabling colors =<br />
<br />
In current versions (earlier than 11.05.2009) of ConTeXt mkiv, colors are enabled by default.<br />
<br />
In older versions, colors must be enabled using<br />
<cmd>setupcolors</cmd><tt>[state=start]</tt><br />
<br />
=Defining Colors=<br />
<br />
Using colors with ConTeXt is easy:<br />
<br />
== Choosing a color model ==<br />
<br />
* RGB and CMYK are enabled by default. If you want only RGB or only CMYK color, use <tt>cmyk=no</tt> or <tt>rgb=no</tt>. Multitone colors see below. <br />
* For spot colors, say spot=yes. To eliminate everything except spot colours, leaving a clean file for professional printing, accompany this with rgb=no,cmyk=no. See spot colours below for more details.<br />
* Normally all colors are defined in RGB ''and'' CMYK and get converted if needed.<br />
<br />
== Using predefined colors: <cmd>setupcolor</cmd> ==<br />
<br />
You find lists of predefined colors in the files <tt>colo-xxx.tex</tt>, load them with <cmd>setupcolor</cmd><tt>[xxx]</tt>:<br />
* rgb: some simple colors, loaded by default (with translations for the different interface languages!)<br />
* xwi: X-Windows-colors<br />
* pra: PRAGMA ADE company colors<br />
* ema: Emacs colors<br />
<br />
* Try the magic <cmd>showcolor</cmd><tt>[xxx]</tt>!<br />
<br />
{|<br />
! width="25%"|<br />
! width="10%"|<br />
! width="65%"|<br />
|-<br />
| <texcode><br />
\showcolor[rgb]<br />
</texcode><br />
|<br />
| <context><br />
\setupcolors[state=start]<br />
\showcolor[rgb]<br />
</context><br />
|}<br />
<br />
== Defining colors: <cmd>definecolor</cmd> ==<br />
<br />
<cmd>definecolor</cmd><tt>[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]</tt> (definition for RGB, CMYK and Grey!)<br />
<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\definecolor[blablue][r=.25, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]<br />
<br />
Here's some \color[blablue]{blue text} inbetween!<br />
</texcode><br />
|<br />
| <context><br />
\setupcolors[state=start]<br />
\definecolor[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]<br />
<br />
Here's some \color[blablue]{blue text} inbetween!<br />
</context><br />
|}<br />
<br />
=== Colors with Hexadecimal Numbers ===<br />
<br />
You can also use hexadecimal numers to specify colors. You need to load the '''hex''' color module first:<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\setupcolor[hex]<br />
\definecolor[salmon][h=AB5757]<br />
<br />
Hey, \color[salmon]{look at that!}<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\setupcolor[hex]<br />
\definecolor[salmon][h=AB5757]<br />
<br />
Hey, \color[salmon]{look at that!}<br />
</context><br />
|}<br />
<br />
===Transparent Colors===<br />
<br />
You can define '''transparent''' colors through setting t, e.g. <tt>t=0.5</tt>. Beware, some PDF viewers and printshops can't handle PDF transparences!<br />
<br />
Hans Hagen posted the following sample code for transparent colors on the mailing list on 2005-07-13; the yellow blocks have been added to demonstrate the order in which the blocks are drawn on the page; the first yellow block is behind the transparent red and blue blocks, while the second is in front of them.<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\definecolor [transparentred] [r=1,t=.5,a=1]<br />
\definecolor [transparentblue] [b=1,t=.5,a=1]<br />
\definecolor [solidyellow] [y=1,t=1,a=1]<br />
<br />
\starttext<br />
<br />
\startTEXpage<br />
This is some sample text that goes behind the rectangles\hskip-8cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=transparentred]\hskip-0.67cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=transparentblue]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=solidyellow]\hskip2cm.<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\definecolor [transparentred] [r=1,t=.5,a=1]<br />
\definecolor [transparentblue] [b=1,t=.5,a=1]<br />
\definecolor [solidyellow] [y=1,t=1,a=1]<br />
<br />
\starttext<br />
<br />
\startTEXpage<br />
This is some sample text that goes behind the rectangles\hskip-8cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=transparentred]\hskip-0.67cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=transparentblue]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=solidyellow]\hskip2cm.<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</context><br />
|}<br />
<br />
== Defining color schemes: <cmd>definecolorgroup</cmd> and <cmd>definepalet</cmd>==<br />
<cmd>definecolorgroup</cmd><tt>[name][system][values]</tt><br />
<br />
<cmd>definepalet</cmd><tt>[palettename][colorname1=groupcolor:1, colorname2=groupcolor:2, ...]</tt><br />
<br />
Very interesting feature, to be described later... (see manual)<br />
<br />
=Choosing a color scheme=<br />
<br />
There are three basic strategies to select color combinations for a particular design<br />
<br />
# Create a color scheme by picking several colors found within the objects to be used (photographs, pictures, etc)<br />
# Create colors derived from those found in the objects to be used<br />
# Create a color scheme based on the message to convey / the psychological effects of color<br />
<br />
See for additional help & reference:<br />
* [http://colorschemedesigner.com/ colorschemedesigner.com] - Useful site to help choose a color scheme in rgb color space<br />
* Tina Sutton, Bride M Whelan: The Complete Color Harmony. Rockport Publishers (2004). ISBN 978-1592530311 (recommanded in the mailing list)<br />
<br />
<br />
=Using Colors=<br />
<br />
* Use the color name like <tt>[color=blablue]</tt> in some <tt>\setup...</tt> command.<br />
<br />
== With text ==<br />
<br />
Typeset single text elements with <cmd>color</cmd><tt>[colorname]{nice blue text}</tt>:<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
Three \color[red]{cool} cats<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\starttext<br />
Three \color[red]{cool} cats<br />
\stoptext<br />
</context><br />
|}<br />
<br />
Typeset longer sections with <cmd>startcolor</cmd><tt>[colorname] ...</tt> <cmd>stopcolor</cmd>:<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\starttext<br />
\startcolor[orange]<br />
\input tufte<br />
\stopcolor<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\starttext<br />
\startcolor[orange]<br />
\input tufte<br />
\stopcolor<br />
\stoptext<br />
</context><br />
|}<br />
<br />
== In titles ==<br />
<br />
See [[Titles#Using_colors_in_chapters_and_sections]]<br />
<br />
== With frames ==<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\framed[background=color, backgroundcolor=green]{bla}<br />
\framed[background=color, backgroundcolor=yellow, corner=00]{bla}<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
<br />
\starttext<br />
\framed[background=color, backgroundcolor=green]{bla}<br />
\framed[background=color, backgroundcolor=yellow, corner=00]{bla}<br />
</context><br />
|}<br />
<br />
== Background of the page ==<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\setupbackgrounds[page][background=color,backgroundcolor=blue]<br />
<br />
\starttext<br />
text<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
<br />
\setupbackgrounds[page][background=color,backgroundcolor=blue]<br />
<br />
\starttext<br />
text<br />
\stoptext<br />
</context><br />
|}<br />
<br />
== Background of cells in tables ==<br />
<br />
See<br />
* [[Table#Background Colors]]<br />
* [[TABLE#Round_corners]]<br />
<br />
== In Metapost ==<br />
<br />
Metapost in MkIV is different from MkII and all labels are typeset<br />
and colored in TeX, if you want a label use<br />
label(textext("\blue RED"),origin) ;<br />
<br />
== In TikZ ==<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\usemodule[tikz]<br />
\starttext<br />
\tikz\shade[ball color=red!40!yellow] (0,0) circle (.15cm);<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\usemodule[tikz]<br />
\starttext<br />
\tikz\shade[ball color=red!40!yellow] (0,0) circle (.15cm);<br />
\stoptext<br />
</context><br />
|}<br />
<br />
=Spot colours=<br />
<br />
To produce a file ready for a clean PDF separation process at your print house, start with:<br />
<br />
<cmd>setupcolors</cmd><tt>[rgb=no,cmyk=yes,spot=yes,state=start,overprint=yes]</tt><br />
<br />
which will set things up for spot colors with CMYK allowed. The last setting ensures that black overprinting your spot colour tints will not knock out the colour - this is important for some types of commercial printing.<br />
<br />
Then define your basic spot colour. Note that the name cannot contain spaces or numbers (but we come to that later):<br />
<br />
<cmd>definecolor</cmd><tt>[PantoneTwoNineFour][c=1,m=.56,y=0,k=.18]</tt><br />
<br />
Now you can define the tints of this ink that you are actually going to use in your document. Let's say you'll have a 100% for headings:<br />
<br />
<cmd>definespotcolor</cmd><tt>[MyBlue][PantoneTwoNineFour][p=1]</tt><br />
<br />
And then a 20% tint for nice display boxes:<br />
<br />
<cmd>definespotcolor</cmd><tt>[MyBlueTint][PantoneTwoNineFour][p=.2]</tt><br />
<br />
And now you can happily use these named colours:<br />
<br />
<texcode><br />
\starttext<br />
\color[MyBlue]{Interesting}<br />
\stoptext<br />
</texcode><br />
<br />
If you are including graphics made by an external program, you might want to match the colour name used in the graphic with the colour name in your '''ConTeXt''' set-up so that only one colour space is used in the final file. Unfortunately Pantone names and others tend to have spaces and numbers in them, so you need to do a low-level mapping trick from your base name to the name you want embedded in the file:<br />
<br />
<cmd>doregisterspotcolorname</cmd><tt>{PantoneTwoNineFour}{PANTONE 294 CV}</tt><br />
<br />
Now your output file should work beautifully with graphics embedded!<br />
<br />
==Using the 'e' key to \definecolor to specify a spot colour name with spaces==<br />
<br />
As an update to the above description on defining spot colours, you can now use the 'e' key when defining your spot colours in order to specify the precise colour names to be used by your ConTeXt set-up in the output file. For example:<br />
<br />
<texcode><br />
% Define spot colours using 'e=....' to specify colour names to use in output file<br />
\definecolor<br />
[PantoneThreeZeroEight]<br />
[c=1,m=.05,y=0,k=.47,e=PANTONE 308 CV]<br />
<br />
\definecolor<br />
[PantoneTwoNineEight]<br />
[c=.69,m=.07,y=0,k=0,e=PANTONE 298 CV]<br />
<br />
% Define tints of spot colours to be used in document for colouring text<br />
\definespotcolor<br />
[DarkBlue]<br />
[PantoneThreeZeroEight]<br />
[p=1]<br />
<br />
\definespotcolor<br />
[LightBlue]<br />
[PantoneTwoNineEight]<br />
[p=1]<br />
</texcode><br />
<br />
(Tested only on minimal Linux distribution dated 31 Aug 2005 - can others confirm this<br />
to be true across the board now?)<br />
<br />
Any text between a <cmd>startcolor[DarkBlue]</cmd> and <cmd>stopcolor</cmd> should now be assigned to the correct spot colour channel - Pantone 308 CV - on output. More importantly if you include an external figure containing areas of this colour then your text and those parts of the graphic which have the same colour should now appear together in the 'Pantone 308 CV' colour channel on colour separation. <br />
<br />
For example, if your original graphic is an EPS file containing the following lines:<br />
<br />
%%DocumentCustomColors: (PANTONE 298 CV)<br />
%%+ (PANTONE 308 CV)<br />
%%CMYKCustomColor: 0.69 0.07 0 0 (PANTONE 298 CV)<br />
%%+ 1 0.05 0 0.47 (PANTONE 308 CV)<br />
<br />
and you convert this to a PDF using <tt>ps2pdf</tt> for inclusion in your '''ConTeXt''' document your PDF graphic will then contain something like:<br />
<br />
<code><br />
8 0 obj<br />
[/Separation<br />
/PANTONE#20308#20CV<br />
/DeviceCMYK<br />
9 0 R]endobj<br />
10 0 obj<br />
[/Separation<br />
/PANTONE#20298#20CV<br />
/DeviceCMYK<br />
11 0 R]endobj<br />
</code><br />
<br />
Note how the space characters in the colour name are now encoded as '#20', but the colour names are essentially identical between the original EPS graphic, the new PDF graphic and your text.<br />
<br />
A good way of testing colour separation if you don't have access to expensive pre-flight PDF validation tools is to use the following GhostScript command:<br />
<br />
gs \<br />
-dBATCH \<br />
-dNOPAUSE \<br />
-sDEVICE=tiffsep \<br />
-dDOINTERPOLATE \<br />
-dTextAlphaBits=4 \<br />
-dGraphicsAlphaBits=4 \<br />
-sOutputFile=output.tif \<br />
-r120 \<br />
-MaxSeparations=8 \<br />
input.pdf<br />
<br />
This renders a PDF file <tt>input.pdf</tt> as a set of TIFF files:<br />
<br />
output.tif - Composite including CMYK approximations to spot colours<br />
output.tif.Black.tif - K channel<br />
output.tif.Cyan.tif - C channel<br />
output.tif.Magenta.tif - M channel<br />
output.tif.Yellow.tif - Y channel<br />
output.tif.s0.tif - Pantone 308 CV<br />
output.tif.s1.tif - Pantone 298 CV<br />
<br />
=Multitones=<br />
<br />
Hans wrote on the mailinglist on 2004-12-27 about handling of multitone colors:<br />
<br />
Currently it's done by pdftools.rb<br />
<br />
Once pdfxTeX becomes pdfeTeX out of a sudden your beta can do it as well.<br />
<br />
I still need to figure out a way to automatically reverse the graphic, but one of these days you can start using it.<br />
<br />
Actually, multitones for text already work out of the box:<br />
<texcode><br />
\setupcolors[state=start]<br />
<br />
\definecolor [blue] [c=1,m=.38,y=0,k=.64]<br />
\definecolor [yellow] [c=0,m=.28,y=1,k=.06]<br />
<br />
\definespotcolor [blue-100] [blue] [p=1]<br />
\definespotcolor [yellow-100] [yellow] [p=1]<br />
<br />
\definemultitonecolor [combicolor] [blue=.12,yellow=.28] [c=.1,m=.1,y=.3,k=.1]<br />
<br />
\starttext<br />
<br />
\startcolor[blue]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\startcolor[yellow]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\startcolor[combicolor]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\stoptext<br />
</texcode><br />
(The CMYK color spec is the fall back color used on screen; one can preview separations in full Acrobat 7.)<br />
<br />
<br />
<br />
=Colorizing Grayscale Pictures=<br />
<br />
Another sample by Hans (mailing list 2005-11-16) demonstrates a lot of different possibilities:<br />
<br />
<texcode><br />
\setuplayout[header=0pt,footer=0pt,width=middle,height=middle,backspace=1cm,topspace=1cm]<br />
\setupcolors[state=start]<br />
<br />
\startbuffer<br />
\definecolor [blue] [c=1, m=.38, y=0, k=.64]<br />
\definecolor [yellow] [c=0, m=.28, y=1, k=.06]<br />
<br />
\definespotcolor [blue-100] [blue] [p=1]<br />
\definespotcolor [yellow-100] [yellow] [p=1]<br />
<br />
\definemultitonecolor [combicolor] [blue=.12, yellow=.28] [c=.1, m=.1, y=.3, k=.1]<br />
<br />
\definemultitonecolor [combicolor-b] [blue=1] [c=1, m=.38, y=0, k=.64] % force multitone<br />
\definemultitonecolor [combicolor-y] [yellow=1] [c=0, m=.28, y=1, k=.06] % force multitone<br />
<br />
\useexternalfigure[demo-a][mill.png] [object=no, width=.2\textwidth]<br />
\useexternalfigure[demo-b][hacker-bw.jpg][object=no, width=.2\textwidth]<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-a]} {no color}<br />
{\externalfigure[demo-a][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-a][color=combicolor-b]} {spot color}<br />
{\externalfigure[demo-a][color=combicolor-y]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-b]} {no color}<br />
{\externalfigure[demo-b][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-b][color=combicolor-b]} {spot color}<br />
{\externalfigure[demo-b][color=combicolor-y]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-a]} {no color}<br />
{\externalfigure[demo-a][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-a][color=blue-100]} {spot color}<br />
{\externalfigure[demo-a][color=yellow-100]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-b]} {no color}<br />
{\externalfigure[demo-b][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-b][color=blue-100]} {spot color}<br />
{\externalfigure[demo-b][color=yellow-100]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
\stopbuffer<br />
<br />
\getbuffer \typebuffer<br />
<br />
\stoptext<br />
</texcode><br />
<br />
= References =<br />
<br />
See "Color and Background" in the manual</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Talk:Old:_A_Beginner%27s_Guide_to_Using_Fonts_in_Mark_IV&diff=9811Talk:Old: A Beginner's Guide to Using Fonts in Mark IV2009-06-03T14:36:33Z<p>Nicolas Girard: not now</p>
<hr />
<div>Nicolas: should it be deleted ''now''? or when you are done reorganizing? [[User:Taco|Taco]] 09:25, 1 June 2009 (UTC)<br />
Taco: not now, it's not urgent !</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Colorful_CD_Inlay&diff=9810Colorful CD Inlay2009-06-03T14:12:19Z<p>Nicolas Girard: Category:Sample documents</p>
<hr />
<div>Another sample from Hans. Download the [[Media:Fiona.pdf|pdf]] or the [[Media:Fiona.tex|tex]] file. This is what the result looks like: <br />
<br />
[[Image:Fiona.png]]<br />
<br />
<texcode><br />
\starttext<br />
<br />
\usetypescriptfile[type-ghz]<br />
\definetypeface[mainface][ss][sans][optima-nova][default][encoding=texnansi]<br />
\setupbodyfont[mainface]<br />
<br />
\setupcolors[state=start]<br />
<br />
\startuseMPgraphic{whatever}<br />
for i = .3 step .1 until .9 :<br />
fill fullsquare<br />
scaled 5cm<br />
shifted (i*10*5cm,0)<br />
withcolor transparent(1,.5,(i*red)) ;<br />
fill fullsquare<br />
scaled 5cm<br />
shifted (i*10*5cm,4cm)<br />
withcolor transparent(1,.5,(white-(i*red))) ;<br />
endfor ;<br />
addbackground withcolor .75white ;<br />
currentpicture := currentpicture xysized(OverlayWidth+.5pt,OverlayHeight+.5pt) ;<br />
\stopuseMPgraphic<br />
<br />
\startTEXpage<br />
<br />
\defineoverlay[whatever][\useMPgraphic{whatever}]<br />
\defineoverlay[origin] [\setups{origin}]<br />
<br />
\startsetups origin<br />
\vbox to \overlayheight {<br />
\vfill\tfxx\setstrut<br />
\hsize\overlaywidth<br />
\hfill Fiona Apple\enspace EM\enspace2005\quad\strut\endgraf<br />
\kern1ex<br />
}<br />
\stopsetups<br />
<br />
\framed<br />
[background={whatever,origin},height=8cm,frame=off]<br />
{\quad<br />
I don't understand about complementary colors\quad<br />
And what they say\quad<br />
Side by side they both get bright\quad<br />
Together they both get gray\quad}<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</texcode><br />
<br />
[[Category:Sample documents]]</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Verbatim_text&diff=9808Verbatim text2009-06-01T15:16:44Z<p>Nicolas Girard: +Colored background: example from B. Tommy Jensen on 2008-09-04 in the mailing list</p>
<hr />
<div>< [[Visuals]] | [[Verbatim with line breaks]] ><br />
<br />
=Displayed text=<br />
<cmd>starttyping</cmd>,<br />
<cmd>typebuffer</cmd><br />
<br />
Unlike LaTeX's <code>verbatim</code> environment, ConTeXt's <code>typing</code> environments have quite a range of built-in options for formatting the verbatim text, see below.<br />
<br />
=In-line text=<br />
<br />
<code>\startTEX ... \stopTEX</code> only works when typesetting the whole paragraph. If you need to type only a command or two as in-line text, you can use the following [[User:Taco|Taco's]] macro (hopefully this will land in the core once in the future):<br />
<br />
<texcode><br />
\def\typeTEX<br />
{\bgroup<br />
\def\processinlineverbatim##1%<br />
{\processingverbatimtrue<br />
\localcatcodestrue<br />
\def\endofverbatimcommand{\TEXendofcommand##1}%<br />
\bgroup<br />
\aftergroup\endofverbatimcommand<br />
\futurelet\next\doprocessinlineverbatim}%<br />
\initializetyping{TEX}%<br />
\startverbatimcolor<br />
\processinlineverbatim\egroup }<br />
</texcode><br />
<br />
Now you can say:<br />
<br />
<texcode><br />
\typeTEX+\typeTEX{\typeTEX is a wonderful macro}+, isn't it?<br />
</texcode><br />
<context><br />
\setupcolors[state=start]<br />
\def\typeTEX<br />
{\bgroup<br />
\def\processinlineverbatim##1%<br />
{\processingverbatimtrue<br />
\localcatcodestrue<br />
\def\endofverbatimcommand{\TEXendofcommand##1}%<br />
\bgroup<br />
\aftergroup\endofverbatimcommand<br />
\futurelet\next\doprocessinlineverbatim}%<br />
\initializetyping{TEX}%<br />
\startverbatimcolor<br />
\processinlineverbatim\egroup }<br />
<br />
\typeTEX+\typeTEX{\typeTEX is a wonderful macro}+, isn't it?<br />
</context><br />
<br />
Source: [http://archive.contextgarden.net/thread/20050907.093522.baf795f5.en.html]<br />
<br />
= Embedded formatting commands =<br />
<br />
The <tt>option=commands</tt> setting allows the usage of ConTeXt commands inside verbatim text, as in this example:<br />
<texcode><br />
\definetyping[C][option=commands]<br />
\startC<br />
#include &lt;stdio.h&gt;<br />
int main(){<br />
return 0;<br />
/BTEX{\em unreachedCode;}/ETEX<br />
}<br />
\stopC<br />
</texcode><br />
<br />
<context><br />
\definetyping[C][option=commands]<br />
\startC<br />
#include <stdio.h><br />
int main(){<br />
return 0;<br />
/BTEX{\em unreachedCode;}/ETEX<br />
}<br />
\stopC<br />
</context><br />
<br />
== Included Formatters ==<br />
<br />
There are already some formatters for several programming languages in the ConTeXt distribution:<br />
<br />
{|<br />
! Code !! Language<br />
|-<br />
| [[source:verb-c.tex|C]] || C<br />
|-<br />
| [[source:verb-eif.tex|EIF]] || Eiffel<br />
|-<br />
| [[source:verb-js.tex|JS]] || JavaScript<br />
|-<br />
| [[source:verb-jv.tex|JV]] || Java<br />
|-<br />
| [[source:verb-mp.tex|MP]] || MetaPost & MetaFont<br />
|-<br />
| [[source:verb-pas.tex|PAS]] || Pascal & Modula<br />
|-<br />
| [[source:verb-pl.tex|PL]] || Perl 5<br />
|-<br />
| [[source:verb-sql.tex|SQL]] || SQL<br />
|-<br />
| [[source:verb-tex.tex|TEX]] || TeX<br />
|-<br />
| [[source:verb-xml.tex|XML]] || XML<br />
|-<br />
|}<br />
<br />
== Your own formatter ==<br />
<br />
(from a ML answer by Taco, 2006-12-25, "Making a verbatim file for another language")<br />
<br />
You should start from the definition that is closest to the language you want to define (especially wrt comment and string syntax) and can probably have a go at making a version of this. Some <br />
questions occur:<br />
<br />
=== Where should i put my file? ===<br />
<br />
# Possibly the best place is: In the context distribution, but that depends a bit on what language it is, precisely (you can email me the completed file, in that case).<br />
# Second best place: http://modules.contextgarden.net, so it can be included in cont-ext.zip (third-party addons that are distributed by Pragma-Ade alongside the normal distribution).<br />
# Third best: The directory <$HOME/texmf/tex/context/base> (the place where your TeX installation finds local files).<br />
# Final option: Same directory as the file to be processed<br />
<br />
=== Do I have to do anything else to get ConTeXt to recognise and use it? ===<br />
<br />
Your file has to have a name like <tt>verb-xxxx.tex</tt>, with <tt>xxxx</tt> a lowercase short identifier (example: verb-php.tex), and then you have to use one or two commands to make ConTeXt use the file.<br />
<br />
First:<br />
<texcode><br />
\installprettytype [PHP] [PHP]<br />
</texcode><br />
This maps the command <code>\starttyping[option=PHP]</code> to <tt>verb-php.tex</tt>.<br />
<br />
The first argument is the option as passed to \starttyping, the second argument is an uppercase version of <tt>xxxx</tt> (thus allowing ConTeXt to find the file),<br />
<br />
And you probably also want:<br />
<texcode><br />
\definetyping[PHP] [option=PHP]<br />
</texcode><br />
Because that allows <code>\startPHP ... \stopPHP</code> as a shortcut to <tt>\setuptyping[option=PHP]</tt><br />
<br />
=== Wait for LuaTeX ===<br />
<br />
Unless you need that highlighting urgently, I would wait for LuaTeX and write it in lua then (which is certainly less painful than writing it in plain TeX). But it's up to you. I found those TeX definitions too complicated to even try to understand, I would never dare to try writing one by myself. -- Mojca<br />
<br />
= Tabbing =<br />
<br />
The tab character normally corresponds to one character, as can be seen above. That value can be adjusted, using the following code (available in the 2005.06.01 version and later):<br />
<texcode><br />
\definetyping[C][tab=3]<br />
% for older ConTeXt versions: \chardef\spacespertab=3<br />
\startC<br />
int func(int a){<br />
if(a > 4)<br />
return 0;<br />
else<br />
return 10;<br />
}<br />
\stopC<br />
</texcode><br />
<br />
<context><br />
\definetyping[C][tab=3]<br />
\startC<br />
int func(int a){<br />
if(a > 4)<br />
return 0;<br />
else<br />
return 10;<br />
}<br />
\stopC<br />
</context><br />
<br />
= Syntax highlighting in color =<br />
<br />
<texcode><br />
\setupcolors[state=start]<br />
\setuptyping[option=color]<br />
<br />
\starttext<br />
\startXML<br />
... your XML code ...<br />
\stopXML<br />
\stoptext<br />
</texcode><br />
<br />
:<context><br />
\setupbodyfont[8pt]<br />
\setupcolors[state=start]<br />
\setuptyping[option=color]<br />
<br />
\starttext<br />
\startXML<br />
<?xml version="1.0" encoding="utf-8"?><br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"<br />
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><br />
<html><br />
<head><br />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br />
<title>XML Code Highlighting in ConTeXt</title><br />
<br />
<style type="text/css"><br />
h1 {<br />
text-align: center;<br />
color: blue;<br />
font-family: verdana,sans-serif;<br />
}<br />
</style><br />
</head><br />
<br />
<body><br />
<h1>XML Code Highlighting in ConTeXt</h1><br />
<br />
<!-- To be written ... --><br />
</body><br />
</html><br />
\stopXML<br />
\stoptext<br />
</context><br />
<br />
== Defining your own set of colors ==<br />
<br />
Sometimes you may be not quite satisfied with the default colors used in the built-in syntax highlighting. [[User:Taco|Taco]] posted this solution in the discussion on the [http://archive.contextgarden.net/message/20050825.112308.db696b94.en.html mailing list]:<br />
<br />
<texcode><br />
\setupcolors[state=start]<br />
\setuptyping[option=color]<br />
<br />
% define the colors to fit your document style<br />
\definecolor[MYcolorone] [r=.8,g=.5,b=.5]<br />
\definecolor[MYcolortwo] [r=.8,g=.5,b=.2]<br />
\definecolor[MYcolorthree][r=.8,g=.5,b=.8]<br />
\definecolor[MYcolorfour] [r=.8,g=.2,b=.5]<br />
<br />
% define a palete using these four colors<br />
\definepalet[MYcolors]<br />
[prettyone=MYcolorone,<br />
prettytwo=MYcolortwo,<br />
prettythree=MYcolorthree,<br />
prettyfour=MYcolorfour]<br />
<br />
% XML code will be typeset with the palette you just defined<br />
\definepalet[XMLcolorpretty] [MYcolors] % the name is magic !<br />
<br />
\starttext<br />
\startXML<br />
... your XML code ...<br />
\stopXML<br />
\stoptext<br />
</texcode><br />
<br />
This results in:<br />
<br />
:<context><br />
\setupbodyfont[8pt]<br />
\definecolor[MYcolorone] [r=.8,g=.5,b=.5]<br />
\definecolor[MYcolortwo] [r=.8,g=.5,b=.2]<br />
\definecolor[MYcolorthree][r=.8,g=.5,b=.8]<br />
\definecolor[MYcolorfour] [r=.8,g=.2,b=.5]<br />
<br />
\definepalet[MYcolors]<br />
[prettyone=MYcolorone,<br />
prettytwo=MYcolortwo,<br />
prettythree=MYcolorthree,<br />
prettyfour=MYcolorfour]<br />
<br />
\definepalet[XMLcolorpretty] [MYcolors] % the name is magic !<br />
<br />
\setupcolors[state=start]<br />
\setuptyping[option=color]<br />
<br />
\starttext<br />
\startXML<br />
<?xml version="1.0" encoding="utf-8"?><br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"<br />
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><br />
<html><br />
<head><br />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br />
<title>XML Code Highlighting in ConTeXt</title><br />
<br />
<style type="text/css"><br />
h1 {<br />
text-align: center;<br />
color: blue;<br />
font-family: verdana,sans-serif;<br />
}<br />
</style><br />
</head><br />
<br />
<body><br />
<h1>XML Code Highlighting in ConTeXt</h1><br />
<br />
<!-- To be written ... --><br />
</body><br />
</html><br />
\stopXML<br />
\stoptext<br />
</context><br />
<br />
= Colored background =<br />
<br />
<texcode><br />
\setupcolors[state=start]<br />
<br />
\definetextbackground[verbatim]<br />
[background=color,<br />
backgroundcolor=yellow,<br />
backgroundoffset=0cm,<br />
offset=0.5cm,<br />
frame=on,<br />
framecolor=black,<br />
location=paragraph,<br />
color=black]<br />
<br />
% Setup verbatim<br />
\setuptyping[typing][margin=1cm,bodyfont=8.0pt,<br />
before={\starttextbackground[verbatim]},<br />
after={\stoptextbackground}]<br />
<br />
\starttext<br />
\starttyping<br />
This is the first line.<br />
This is the second line.<br />
\stoptyping<br />
\stoptext<br />
</texcode><br />
<br />
= Line numbering =<br />
<br />
In technical documents it can be required to display some code listings with the line numbers. You can do this with ConTeXt, and even more. All the features shown here are also available when displaying external files with <cmd>typefile</cmd>.<br />
<br />
== Preliminary setting ==<br />
Let's define our own typing style, named "code". The typing is put in a framedtext, to demonstrate the wrapping feature in a next section.<br />
<br />
<texcode><br />
\defineframedtext<br />
[framedcode]<br />
[strut=yes,<br />
offset=2mm,<br />
width=7cm,<br />
align=right]<br />
<br />
\definetyping[code][numbering=line,<br />
bodyfont=small,<br />
before={\startframedcode},<br />
after={\stopframedcode}]<br />
</texcode><br />
<br />
== Default line numbering ==<br />
With the defined typing, every line is numbered, and the number goes in the margin. The option to have the line numbers displayed is <tt>numbering=line</tt>.<br />
<br />
<texcode><br />
\startcode<br />
This is the first line<br />
This is a rather long line that is wrapped, so look how the line numbering is done<br />
Another line<br />
<br />
Last line after an empty line<br />
\stopcode<br />
</texcode><br />
<br />
It is rendered as:<br />
<br />
<context><br />
\defineframedtext<br />
[framedcode]<br />
[strut=yes,<br />
offset=2mm,<br />
width=7cm,<br />
align=right]<br />
<br />
\definetyping[code][numbering=line,<br />
bodyfont=small,<br />
before={\startframedcode},<br />
after={\stopframedcode}]<br />
<br />
\startcode<br />
This is the first line<br />
This is a rather long line that is wrapped, so look how the line numbering is done<br />
Another line<br />
<br />
Last line after an empty line<br />
\stopcode<br />
</context><br />
<br />
== Line numbers in the text ==<br />
To have the line numbers in the text, change the linenumbering setup like this:<br />
<br />
<texcode><br />
\setuplinenumbering[location=intext]<br />
\startcode<br />
This is the first line<br />
This is a rather long line that is wrapped, so look how the line numbering is done<br />
Another line<br />
<br />
Last line after an empty line<br />
\stopcode<br />
</texcode><br />
<br />
<context><br />
\defineframedtext<br />
[framedcode]<br />
[strut=yes,<br />
offset=2mm,<br />
width=7cm,<br />
align=right]<br />
<br />
\definetyping[code][numbering=line,<br />
bodyfont=small,<br />
before={\startframedcode},<br />
after={\stopframedcode}]<br />
<br />
\setuplinenumbering[location=intext]<br />
\startcode<br />
This is the first line<br />
This is a rather long line that is wrapped, so look how the line numbering is done<br />
Another line<br />
<br />
Last line after an empty line<br />
\stopcode<br />
</context><br />
<br />
== Continuing the numbering ==<br />
Another handy feature is the ability to continue the numbering from one portion of code to another. Use the option <tt>continue</tt> for this.<br />
<br />
<texcode><br />
\startcode<br />
This is the first line<br />
This is a rather long line that is wrapped, so look how the line numbering is done<br />
Another line<br />
<br />
Last line after an empty line<br />
\stopcode<br />
<br />
Some normal text to explain the first piece of code,<br />
and introduce the following lines.<br />
<br />
\startcode[continue]<br />
This is the first continuing line<br />
This is a rather long line that is wrapped, so look how the line numbering is done<br />
Another line<br />
Last line<br />
\stopcode<br />
</texcode><br />
<br />
<context><br />
\defineframedtext<br />
[framedcode]<br />
[strut=yes,<br />
offset=2mm,<br />
width=7cm,<br />
align=right]<br />
<br />
\definetyping[code][numbering=line,<br />
bodyfont=small,<br />
before={\startframedcode},<br />
after={\stopframedcode}]<br />
<br />
\startcode<br />
This is the first line<br />
This is a rather long line that is wrapped, so look how the line numbering is done<br />
Another line<br />
<br />
Last line after an empty line<br />
\stopcode<br />
<br />
Some normal text to explain the first piece of code, and introduce the following lines.<br />
<br />
\startcode[continue]<br />
This is the first continuing line<br />
This is a rather long line that is wrapped, so look how the line numbering is done<br />
Another line<br />
Last line<br />
\stopcode<br />
</context><br />
<br />
== Arbitrary starting line number ==<br />
You can also decide what the starting line number is. Use the option <tt>start=number</tt> for this.<br />
<br />
<texcode><br />
\startcode[start=200]<br />
This is the first line<br />
This is a rather long line that is wrapped, so look how the line numbering is done<br />
Another line<br />
Last line<br />
\stopcode<br />
</texcode><br />
<br />
<context><br />
\defineframedtext<br />
[framedcode]<br />
[strut=yes,<br />
offset=2mm,<br />
width=7cm,<br />
align=right]<br />
<br />
\definetyping[code][numbering=line,<br />
bodyfont=small,<br />
before={\startframedcode},<br />
after={\stopframedcode}]<br />
<br />
\startcode[start=200]<br />
This is the first line<br />
This is a rather long line that is wrapped, so look how the line numbering is done<br />
Another line<br />
Last line<br />
\stopcode<br />
</context><br />
<br />
== Line number steps ==<br />
You want to print a number every two lines? Ok, just use the option <tt>step=number</tt> for this.<br />
<br />
<texcode><br />
\startcode[start=200,step=2]<br />
This is the first line<br />
This is a rather long line that is wrapped, so look how the line numbering is done<br />
Another line<br />
Last line<br />
\stopcode<br />
</texcode><br />
<br />
<context><br />
\defineframedtext<br />
[framedcode]<br />
[strut=yes,<br />
offset=2mm,<br />
width=7cm,<br />
align=right]<br />
<br />
\definetyping[code][numbering=line,<br />
bodyfont=small,<br />
before={\startframedcode},<br />
after={\stopframedcode}]<br />
<br />
\startcode[start=200,step=2]<br />
This is the first line<br />
This is a rather long line that is wrapped, so look how the line numbering is done<br />
Another line<br />
Last line<br />
\stopcode<br />
</context><br />
<br />
<br />
= A different approach to formatting and code colorization =<br />
<br />
Supposing that: <br />
<br />
a) you are much more fluent in another programming language than TeX <br />
<br />
b) you have a large project involving many code snippets to be inserted and colorized<br />
<br />
you can go for another, less elegant, way to format your verbatim text, which can include all the discussed ConTeXt benefits. <br />
<br />
== Writing a parser/formatter ==<br />
<br />
It is fairly simple to write a little parser which takes as its input your source file and gives in output a .tex file containing the code plus the opportune commands for colorization. You can then include the resulting .tex file in the global ConTeXt document file.<br />
As an example, [http://www.cirma.unito.it/andrea/sw/sc/scToConTeXt.py this] is a Python script for the SuperCollider language, which has a strict Smalltalk-like syntax.<br />
<br />
Fed with the following source code contained in e.g. example.sc file:<br />
<br />
<br />
<context><br />
\tfx<br />
\starttyping<br />
// an example starting with a comment<br />
"this is a string".postln ;<br />
<br />
\aSymbol ;<br />
<br />
ThisClassDoesNotExist ;<br />
\stoptyping<br />
</context><br />
<br />
<br />
the script outputs this tex code, which is written into a file contained in the same folder of the source file (named example.tex):<br />
<br />
<texcode><br />
\startSC<br />
/BTEX{\color[SCred] //// an example starting with a comment}/ETEX<br />
/BTEX{\color[SCgrey] "this is a string"}/ETEX .postln ;<br />
<br />
/BTEX{\color[SCgreen] \letterbackslash aSymbol}/ETEX ;<br />
<br />
/BTEX{\color[SCblue] ThisClassDoesNotExists}/ETEX ;<br />
\stopSC<br />
</texcode><br />
<br />
Basically, the idea is to envelope each item to be colorized inside a /BTEX /ETEX block. <br />
Note that inside the block the text is no more verbatim, so you have to define some string replacements for special characters (e.g. _, %, $, \, etc). <br />
As an example, the problem of the backslash (\) is solved here by replacing it with \letterbackslash. <br />
<br />
You can then insert example.tex in your ConTeXt file with<br />
<br />
<texcode><br />
\input example<br />
</texcode><br />
<br />
<br />
The example.tex file uses some definitions (explained in the previous sections) which have to be put in the ConTeXt file. <br />
<br />
<texcode><br />
\defineframedtext<br />
[framedSC]<br />
[framecolor=cirmaBlue,<br />
strut=yes,<br />
offset=2mm,<br />
width=local,<br />
align=right]<br />
<br />
\definetyping[SC][option=commands, <br />
tab=2,numbering=line,<br />
before={\startframedSC},<br />
after={\stopframedSC}]<br />
</texcode><br />
<br />
Also, example.tex requires color definitions, which are created following SuperCollider colorization interpreter scheme and have to be inserted in the ConTeXt file too:<br />
<br />
<texcode><br />
%% SC colors %%<br />
\definecolor [SCwhite] [r=1.0, g=1.0, b=1.0] <br />
\definecolor [SCblack] [r=0.0, g=0.0, b=0.0] <br />
\definecolor [SCblue] [r=0.0, g=0.0, b=0.75] <br />
\definecolor [SCred] [r=0.75, g=0.0, b=0.0] <br />
\definecolor [SCgrey] [r=0.376, g=0.376, b=0.376] <br />
\definecolor [SCgreen] [r=0.0, g=0.45, b=0.0]<br />
<br />
\definecolor[cirmaBlue] [r=.0,g=.2,b=.6] % for frame<br />
</texcode><br />
<br />
The previous definitions will be used for all the code files inserted with \input.<br />
After compiling, this is the result of the discussed example:<br />
<br />
<br />
<context><br />
\setupcolors[state=start]<br />
\starttext<br />
%% SC colors %%<br />
\definecolor [SCwhite] [r=1.0, g=1.0, b=1.0] <br />
\definecolor [SCblack] [r=0.0, g=0.0, b=0.0] <br />
\definecolor [SCblue] [r=0.0, g=0.0, b=0.75] <br />
\definecolor [SCred] [r=0.75, g=0.0, b=0.0] <br />
<br />
\definecolor [SCgrey] [r=0.376, g=0.376, b=0.376] <br />
\definecolor [SCgreen] [r=0.0, g=0.45, b=0.0] <br />
\definecolor[cirmaBlue] [r=.0,g=.2,b=.6] <br />
<br />
\defineframedtext<br />
[framedSC]<br />
[framecolor=cirmaBlue,<br />
strut=yes,<br />
offset=2mm,<br />
width=local,<br />
align=right]<br />
<br />
\definetyping[SC][option=commands, <br />
tab=2,numbering=line,<br />
before={\startframedSC},<br />
after={\stopframedSC}]<br />
<br />
\startSC<br />
/BTEX{\color[SCred] //// an example starting with a comment}/ETEX<br />
/BTEX{\color[SCgrey] "this is a string"}/ETEX .postln ;<br />
<br />
/BTEX{\color[SCgreen] \letterbackslash aSymbol}/ETEX ;<br />
<br />
/BTEX{\color[SCblue] ThisClassDoesNotExists}/ETEX ;<br />
\stopSC<br />
<br />
\stoptext<br />
</context><br />
<br />
== Embedding the source code ==<br />
<br />
If your document is inteded to provide code examples to be tested by the readers, the presence of format signs (e.g. line numbers) can create some troubles while copying and pasting the code text from your document to the language environment. More generally, the copy and paste approach, being slow and possibly related to encodings, is not satisfying at all.<br />
You can include source files in the pdf with a couple of ConTeXt commands:<br />
<br />
<texcode><br />
\useattachment[ex][example.sc]<br />
\attachment[ex]<br />
</texcode><br />
<br />
<br />
So that you can have this structure for each code snippet:<br />
<br />
<texcode><br />
\input example<br />
<br />
\useattachment[ex][example.sc]<br />
\attachment[ex]<br />
</texcode><br />
<br />
<br />
The commands embed example.sc in the pdf, so that it is accessible by double-clicking on a generated icon. In this case the icon is placed after the colorized code frame.<br />
If you use Acrobat Reader (Preview.app in MacOSX does not provide support for the behaviour) example.sc will be open in the related application (e.g. SuperCollider.app in the discussed case).<br />
<br />
<br />
The discussed approach has been implemented [http://www.cirma.unito.it/andrea/sw/sc/prd_tSCIRMA.pdf here].<br />
<br />
(-a- --> [[User:Andrea]])</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Color&diff=9807Color2009-06-01T15:04:49Z<p>Nicolas Girard: /* Using Colors */ +In titles</p>
<hr />
<div>< [[Visuals]] | [[Graphics]] ><br />
<br />
= Enabling colors =<br />
<br />
In current versions (earlier than 11.05.2009) of ConTeXt mkiv, colors are enabled by default.<br />
<br />
In older versions, colors must be enabled using<br />
<cmd>setupcolors</cmd><tt>[state=start]</tt><br />
<br />
=Defining Colors=<br />
<br />
Using colors with ConTeXt is easy:<br />
<br />
== Choosing a color model ==<br />
<br />
* RGB and CMYK are enabled by default. If you want only RGB or only CMYK color, use <tt>cmyk=no</tt> or <tt>rgb=no</tt>. Multitone colors see below. <br />
* For spot colors, say spot=yes. To eliminate everything except spot colours, leaving a clean file for professional printing, accompany this with rgb=no,cmyk=no. See spot colours below for more details.<br />
* Normally all colors are defined in RGB ''and'' CMYK and get converted if needed.<br />
<br />
== Using predefined colors: <cmd>setupcolor</cmd> ==<br />
<br />
You find lists of predefined colors in the files <tt>colo-xxx.tex</tt>, load them with <cmd>setupcolor</cmd><tt>[xxx]</tt>:<br />
* rgb: some simple colors, loaded by default (with translations for the different interface languages!)<br />
* xwi: X-Windows-colors<br />
* pra: PRAGMA ADE company colors<br />
* ema: Emacs colors<br />
<br />
* Try the magic <cmd>showcolor</cmd><tt>[xxx]</tt>!<br />
<br />
{|<br />
! width="25%"|<br />
! width="10%"|<br />
! width="65%"|<br />
|-<br />
| <texcode><br />
\showcolor[rgb]<br />
</texcode><br />
|<br />
| <context><br />
\setupcolors[state=start]<br />
\showcolor[rgb]<br />
</context><br />
|}<br />
<br />
== Defining colors: <cmd>definecolor</cmd> ==<br />
<br />
<cmd>definecolor</cmd><tt>[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]</tt> (definition for RGB, CMYK and Grey!)<br />
<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\definecolor[blablue][r=.25, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]<br />
<br />
Here's some \color[blablue]{blue text} inbetween!<br />
</texcode><br />
|<br />
| <context><br />
\setupcolors[state=start]<br />
\definecolor[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]<br />
<br />
Here's some \color[blablue]{blue text} inbetween!<br />
</context><br />
|}<br />
<br />
=== Colors with Hexadecimal Numbers ===<br />
<br />
You can also use hexadecimal numers to specify colors. You need to load the '''hex''' color module first:<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\setupcolor[hex]<br />
\definecolor[salmon][h=AB5757]<br />
<br />
Hey, \color[salmon]{look at that!}<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\setupcolor[hex]<br />
\definecolor[salmon][h=AB5757]<br />
<br />
Hey, \color[salmon]{look at that!}<br />
</context><br />
|}<br />
<br />
===Transparent Colors===<br />
<br />
You can define '''transparent''' colors through setting t, e.g. <tt>t=0.5</tt>. Beware, some PDF viewers and printshops can't handle PDF transparences!<br />
<br />
Hans Hagen posted the following sample code for transparent colors on the mailing list on 2005-07-13; the yellow blocks have been added to demonstrate the order in which the blocks are drawn on the page; the first yellow block is behind the transparent red and blue blocks, while the second is in front of them.<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\definecolor [transparentred] [r=1,t=.5,a=1]<br />
\definecolor [transparentblue] [b=1,t=.5,a=1]<br />
\definecolor [solidyellow] [y=1,t=1,a=1]<br />
<br />
\starttext<br />
<br />
\startTEXpage<br />
This is some sample text that goes behind the rectangles\hskip-8cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=transparentred]\hskip-0.67cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=transparentblue]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=solidyellow]\hskip2cm.<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\definecolor [transparentred] [r=1,t=.5,a=1]<br />
\definecolor [transparentblue] [b=1,t=.5,a=1]<br />
\definecolor [solidyellow] [y=1,t=1,a=1]<br />
<br />
\starttext<br />
<br />
\startTEXpage<br />
This is some sample text that goes behind the rectangles\hskip-8cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=transparentred]\hskip-0.67cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=transparentblue]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=solidyellow]\hskip2cm.<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</context><br />
|}<br />
<br />
== Defining color schemes: <cmd>definecolorgroup</cmd> and <cmd>definepalet</cmd>==<br />
<cmd>definecolorgroup</cmd><tt>[name][system][values]</tt><br />
<br />
<cmd>definepalet</cmd><tt>[palettename][colorname1=groupcolor:1, colorname2=groupcolor:2, ...]</tt><br />
<br />
Very interesting feature, to be described later... (see manual)<br />
<br />
=Choosing a color scheme=<br />
<br />
There are three basic strategies to select color combinations for a particular design<br />
<br />
# Create a color scheme by picking several colors found within the objects to be used (photographs, pictures, etc)<br />
# Create colors derived from those found in the objects to be used<br />
# Create a color scheme based on the message to convey / the psychological effects of color<br />
<br />
See for additional help & reference:<br />
* [http://colorschemedesigner.com/ colorschemedesigner.com] - Useful site to help choose a color scheme in rgb color space<br />
* Tina Sutton, Bride M Whelan: The Complete Color Harmony. Rockport Publishers (2004). ISBN 978-1592530311 (recommanded in the mailing list)<br />
<br />
<br />
=Using Colors=<br />
<br />
* Use the color name like <tt>[color=blablue]</tt> in some <tt>\setup...</tt> command.<br />
<br />
== With text ==<br />
<br />
Typeset single text elements with <cmd>color</cmd><tt>[colorname]{nice blue text}</tt>:<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
Three \color[red]{cool} cats<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\starttext<br />
Three \color[red]{cool} cats<br />
\stoptext<br />
</context><br />
|}<br />
<br />
Typeset longer sections with <cmd>startcolor</cmd><tt>[colorname] ...</tt> <cmd>stopcolor</cmd>:<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\starttext<br />
\startcolor[orange]<br />
\input tufte<br />
\stopcolor<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\starttext<br />
\startcolor[orange]<br />
\input tufte<br />
\stopcolor<br />
\stoptext<br />
</context><br />
|}<br />
<br />
== In titles ==<br />
<br />
See [[Titles#Using_colors_in_chapters_and_sections]]<br />
<br />
== With frames ==<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\framed[background=color, backgroundcolor=green]{bla}<br />
\framed[background=color, backgroundcolor=yellow, corner=00]{bla}<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
<br />
\starttext<br />
\framed[background=color, backgroundcolor=green]{bla}<br />
\framed[background=color, backgroundcolor=yellow, corner=00]{bla}<br />
</context><br />
|}<br />
<br />
== Background of the page ==<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\setupbackgrounds[page][background=color,backgroundcolor=blue]<br />
<br />
\starttext<br />
text<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
<br />
\setupbackgrounds[page][background=color,backgroundcolor=blue]<br />
<br />
\starttext<br />
text<br />
\stoptext<br />
</context><br />
|}<br />
<br />
== Background of cells in tables ==<br />
<br />
See<br />
* [[Table#Background Colors]]<br />
* [[TABLE#Round_corners]]<br />
<br />
== In Metapost ==<br />
<br />
Metapost in MkIV is different from MkII and all labels are typeset<br />
and colored in TeX, if you want a label use<br />
label(textext("\blue RED"),origin) ;<br />
<br />
== In TikZ ==<br />
<br />
<texcode><br />
\usemodule[tikz]<br />
\starttext<br />
\tikz\shade[ball color=red!40!yellow] (0,0) circle (.15cm);<br />
\stoptext<br />
</texcode><br />
<br />
=Spot colours=<br />
<br />
To produce a file ready for a clean PDF separation process at your print house, start with:<br />
<br />
<cmd>setupcolors</cmd><tt>[rgb=no,cmyk=yes,spot=yes,state=start,overprint=yes]</tt><br />
<br />
which will set things up for spot colors with CMYK allowed. The last setting ensures that black overprinting your spot colour tints will not knock out the colour - this is important for some types of commercial printing.<br />
<br />
Then define your basic spot colour. Note that the name cannot contain spaces or numbers (but we come to that later):<br />
<br />
<cmd>definecolor</cmd><tt>[PantoneTwoNineFour][c=1,m=.56,y=0,k=.18]</tt><br />
<br />
Now you can define the tints of this ink that you are actually going to use in your document. Let's say you'll have a 100% for headings:<br />
<br />
<cmd>definespotcolor</cmd><tt>[MyBlue][PantoneTwoNineFour][p=1]</tt><br />
<br />
And then a 20% tint for nice display boxes:<br />
<br />
<cmd>definespotcolor</cmd><tt>[MyBlueTint][PantoneTwoNineFour][p=.2]</tt><br />
<br />
And now you can happily use these named colours:<br />
<br />
<texcode><br />
\starttext<br />
\color[MyBlue]{Interesting}<br />
\stoptext<br />
</texcode><br />
<br />
If you are including graphics made by an external program, you might want to match the colour name used in the graphic with the colour name in your '''ConTeXt''' set-up so that only one colour space is used in the final file. Unfortunately Pantone names and others tend to have spaces and numbers in them, so you need to do a low-level mapping trick from your base name to the name you want embedded in the file:<br />
<br />
<cmd>doregisterspotcolorname</cmd><tt>{PantoneTwoNineFour}{PANTONE 294 CV}</tt><br />
<br />
Now your output file should work beautifully with graphics embedded!<br />
<br />
==Using the 'e' key to \definecolor to specify a spot colour name with spaces==<br />
<br />
As an update to the above description on defining spot colours, you can now use the 'e' key when defining your spot colours in order to specify the precise colour names to be used by your ConTeXt set-up in the output file. For example:<br />
<br />
<texcode><br />
% Define spot colours using 'e=....' to specify colour names to use in output file<br />
\definecolor<br />
[PantoneThreeZeroEight]<br />
[c=1,m=.05,y=0,k=.47,e=PANTONE 308 CV]<br />
<br />
\definecolor<br />
[PantoneTwoNineEight]<br />
[c=.69,m=.07,y=0,k=0,e=PANTONE 298 CV]<br />
<br />
% Define tints of spot colours to be used in document for colouring text<br />
\definespotcolor<br />
[DarkBlue]<br />
[PantoneThreeZeroEight]<br />
[p=1]<br />
<br />
\definespotcolor<br />
[LightBlue]<br />
[PantoneTwoNineEight]<br />
[p=1]<br />
</texcode><br />
<br />
(Tested only on minimal Linux distribution dated 31 Aug 2005 - can others confirm this<br />
to be true across the board now?)<br />
<br />
Any text between a <cmd>startcolor[DarkBlue]</cmd> and <cmd>stopcolor</cmd> should now be assigned to the correct spot colour channel - Pantone 308 CV - on output. More importantly if you include an external figure containing areas of this colour then your text and those parts of the graphic which have the same colour should now appear together in the 'Pantone 308 CV' colour channel on colour separation. <br />
<br />
For example, if your original graphic is an EPS file containing the following lines:<br />
<br />
%%DocumentCustomColors: (PANTONE 298 CV)<br />
%%+ (PANTONE 308 CV)<br />
%%CMYKCustomColor: 0.69 0.07 0 0 (PANTONE 298 CV)<br />
%%+ 1 0.05 0 0.47 (PANTONE 308 CV)<br />
<br />
and you convert this to a PDF using <tt>ps2pdf</tt> for inclusion in your '''ConTeXt''' document your PDF graphic will then contain something like:<br />
<br />
<code><br />
8 0 obj<br />
[/Separation<br />
/PANTONE#20308#20CV<br />
/DeviceCMYK<br />
9 0 R]endobj<br />
10 0 obj<br />
[/Separation<br />
/PANTONE#20298#20CV<br />
/DeviceCMYK<br />
11 0 R]endobj<br />
</code><br />
<br />
Note how the space characters in the colour name are now encoded as '#20', but the colour names are essentially identical between the original EPS graphic, the new PDF graphic and your text.<br />
<br />
A good way of testing colour separation if you don't have access to expensive pre-flight PDF validation tools is to use the following GhostScript command:<br />
<br />
gs \<br />
-dBATCH \<br />
-dNOPAUSE \<br />
-sDEVICE=tiffsep \<br />
-dDOINTERPOLATE \<br />
-dTextAlphaBits=4 \<br />
-dGraphicsAlphaBits=4 \<br />
-sOutputFile=output.tif \<br />
-r120 \<br />
-MaxSeparations=8 \<br />
input.pdf<br />
<br />
This renders a PDF file <tt>input.pdf</tt> as a set of TIFF files:<br />
<br />
output.tif - Composite including CMYK approximations to spot colours<br />
output.tif.Black.tif - K channel<br />
output.tif.Cyan.tif - C channel<br />
output.tif.Magenta.tif - M channel<br />
output.tif.Yellow.tif - Y channel<br />
output.tif.s0.tif - Pantone 308 CV<br />
output.tif.s1.tif - Pantone 298 CV<br />
<br />
=Multitones=<br />
<br />
Hans wrote on the mailinglist on 2004-12-27 about handling of multitone colors:<br />
<br />
Currently it's done by pdftools.rb<br />
<br />
Once pdfxTeX becomes pdfeTeX out of a sudden your beta can do it as well.<br />
<br />
I still need to figure out a way to automatically reverse the graphic, but one of these days you can start using it.<br />
<br />
Actually, multitones for text already work out of the box:<br />
<texcode><br />
\setupcolors[state=start]<br />
<br />
\definecolor [blue] [c=1,m=.38,y=0,k=.64]<br />
\definecolor [yellow] [c=0,m=.28,y=1,k=.06]<br />
<br />
\definespotcolor [blue-100] [blue] [p=1]<br />
\definespotcolor [yellow-100] [yellow] [p=1]<br />
<br />
\definemultitonecolor [combicolor] [blue=.12,yellow=.28] [c=.1,m=.1,y=.3,k=.1]<br />
<br />
\starttext<br />
<br />
\startcolor[blue]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\startcolor[yellow]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\startcolor[combicolor]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\stoptext<br />
</texcode><br />
(The CMYK color spec is the fall back color used on screen; one can preview separations in full Acrobat 7.)<br />
<br />
<br />
<br />
=Colorizing Grayscale Pictures=<br />
<br />
Another sample by Hans (mailing list 2005-11-16) demonstrates a lot of different possibilities:<br />
<br />
<texcode><br />
\setuplayout[header=0pt,footer=0pt,width=middle,height=middle,backspace=1cm,topspace=1cm]<br />
\setupcolors[state=start]<br />
<br />
\startbuffer<br />
\definecolor [blue] [c=1, m=.38, y=0, k=.64]<br />
\definecolor [yellow] [c=0, m=.28, y=1, k=.06]<br />
<br />
\definespotcolor [blue-100] [blue] [p=1]<br />
\definespotcolor [yellow-100] [yellow] [p=1]<br />
<br />
\definemultitonecolor [combicolor] [blue=.12, yellow=.28] [c=.1, m=.1, y=.3, k=.1]<br />
<br />
\definemultitonecolor [combicolor-b] [blue=1] [c=1, m=.38, y=0, k=.64] % force multitone<br />
\definemultitonecolor [combicolor-y] [yellow=1] [c=0, m=.28, y=1, k=.06] % force multitone<br />
<br />
\useexternalfigure[demo-a][mill.png] [object=no, width=.2\textwidth]<br />
\useexternalfigure[demo-b][hacker-bw.jpg][object=no, width=.2\textwidth]<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-a]} {no color}<br />
{\externalfigure[demo-a][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-a][color=combicolor-b]} {spot color}<br />
{\externalfigure[demo-a][color=combicolor-y]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-b]} {no color}<br />
{\externalfigure[demo-b][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-b][color=combicolor-b]} {spot color}<br />
{\externalfigure[demo-b][color=combicolor-y]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-a]} {no color}<br />
{\externalfigure[demo-a][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-a][color=blue-100]} {spot color}<br />
{\externalfigure[demo-a][color=yellow-100]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-b]} {no color}<br />
{\externalfigure[demo-b][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-b][color=blue-100]} {spot color}<br />
{\externalfigure[demo-b][color=yellow-100]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
\stopbuffer<br />
<br />
\getbuffer \typebuffer<br />
<br />
\stoptext<br />
</texcode><br />
<br />
= References =<br />
<br />
See "Color and Background" in the manual</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Titles&diff=9806Titles2009-06-01T15:03:54Z<p>Nicolas Girard: /* Titling Alignment */ Corrected section level</p>
<hr />
<div>< [[Structurals]] | [[Visuals]] ><br />
<br />
==Default==<br />
<br />
Titles define the structure of your document. Decide yourself, how deep you want to nest them:<br />
<br />
<table><br />
<tr bgcolor="#CCCCCC"><br />
<th>numbered</th><br />
<th>unnumbered</th><br />
</tr><br />
<tr><br />
<td><cmd>part</cmd><br />
</td><td>&#151;</td><br />
</tr><br />
<tr><br />
<td><cmd>chapter</cmd></td><br />
<td><cmd>title</cmd></td><br />
</tr><br />
<tr><br />
<td><cmd>section</cmd></td><br />
<td><cmd>subject</cmd></td><br />
</tr><br />
<tr><br />
<td><cmd>subsection</cmd></td><br />
<td><cmd>subsubject</cmd></td><br />
</tr><br />
<tr><br />
<td><cmd>subsubsection</cmd></td><br />
<td><cmd>subsubsubject</cmd></td><br />
</tr><br />
<tr><br />
<td>...</td><br />
<td>...</td><br />
</tr><br />
</table><br />
<br />
The ''unnumbered'' versions don't appear in a table of contents! But you can<br />
switch off the numbering of the ''numbered'' versions with <cmd>setuphead</cmd><br />
to get unnumbered titles ''and'' a toc (confusing?).<br />
<br />
===Referencing Titles===<br />
<br />
Every heading command can take an optional parameter as reference:<br />
<br />
<texcode><br />
\title[hasselt-by-night]{Hasselt by night}<br />
</texcode><br />
<br />
The bracket pair is optional and used for internal [[References]]. If you want<br />
to refer to this header you type for example<br />
<br />
<texcode><br />
\at{page}[hasselt-by-night].<br />
<br />
(see <cmd>at</cmd>)<br />
</texcode><br />
<br />
==Titling Style==<br />
<br />
see <cmd>setuphead</cmd> and some enhanced samples below.<br />
<br />
A FAQ is how to get a line under the title:<br />
<br />
<texcode><br />
\setupbackgrounds[header][text][bottomframe=on]<br />
</texcode><br />
<br />
To make the section numbers appear as characters, do<br />
<br />
<texcode><br />
\setupsection[section-3][bodypartconversion=Character]<br />
</texcode><br />
<br />
The <code>section-3</code> corresponds to <code>section</code>. Similarly,<br />
<code>section-1</code> corresponds to <code>part</code>, <code>section-2</code><br />
corresponds to <code>chapter</code> and so on.<br />
<br />
==Titling Alignment==<br />
<br />
Titles should often be left aligned without hyphenation. Try this:<br />
<br />
<texcode><br />
\setuphead[chapter][align={flushleft, nothyphenated, verytolerant}] % "flushleft" is the same as "right"<br />
</texcode><br />
<br />
==Using colors in chapters and sections==<br />
<br />
If you want you may have colors on your document's chapters or sections.<br />
To do that you should use <cmd>setuphead</cmd>. Take a look at the following<br />
example:<br />
<br />
<texcode><br />
\setupcolors[state=start] % Important. You won't have colors without it.<br />
<br />
\setuphead[chapter][header=empty] % Chapter pages won't have headers<br />
<br />
\setupheadertexts[][chapter] % The header will be the chapter's name<br />
<br />
\starttext<br />
<br />
\completecontent<br />
<br />
\chapter{Black chapter 1}<br />
<br />
\setuphead[section][color=darkcyan] % This is how you change your chapter's color.<br />
<br />
\section{Dark cyan section 1.1}<br />
<br />
\page<br />
Test.<br />
<br />
\setuphead[chapter][color=darkgreen]<br />
<br />
\chapter{Dark green chapter}<br />
<br />
\page<br />
Test.<br />
<br />
\setuphead[chapter][color=red]<br />
<br />
\chapter{Red chapter}<br />
<br />
\page<br />
Test.<br />
<br />
\stoptext <br />
</texcode><br />
<br />
==Your Own Titling Levels==<br />
<br />
Of course you can define your own titling commands and probably must adapt the default settings.<br />
<br />
<texcode><br />
\definehead[myheader][section]<br />
<br />
\setuphead<br />
[myheader]<br />
[numberstyle=bold,<br />
textstyle=cap,<br />
before=\hairline\blank,<br />
after=\nowhitespace\hairline]<br />
<br />
\myheader[hasselt-ref]{Hasselt makes headlines}<br />
</texcode><br />
<br />
A new header <cmd>myheader</cmd> is defined and it inherits the properties<br />
of <cmd>section</cmd> (title, subject, whatever). You can ''define'' several<br />
headers at once!<br />
<br />
==Formatting Titles with <cmd>setuphead</cmd>==<br />
<br />
<cmd>setuphead</cmd> accepts a number of parameters which change the style of<br />
the heading. At least the following commands are available:<br />
<br />
<table><br />
<tr bgcolor="#CCCCCC"><br />
<th>text</th><br />
<th>number</th><br />
</tr><br />
<tr><br />
<td><tt>textstyle</tt></td><br />
<td><tt>numberstyle</tt></td><br />
</tr><br />
<tr><br />
<td><tt>textcommand</tt></td><br />
<td><tt>numbercommand</tt></td><br />
</tr><br />
<tr><br />
<td><tt>deeptextcommand</tt></td><br />
<td><tt>deepnumbercommand</tt></td><br />
</tr><br />
</table><br />
<br />
Quite obviously, the number-commands work on the chapter/section/etc. number,<br />
their text counterparts change the text itself. However, there are differences<br />
between <tt>style</tt>, <tt>command</tt> and <tt>deepcommand</tt>.<br />
<br />
The <tt>style</tt> variants accept a style (<tt>bold</tt>, <tt>cap</tt>, etc.)<br />
or a font switch (<cmd>em</cmd>, <cmd>tfx</cmd>, etc). <tt>texstyle</tt> prepends<br />
the text with the associated style. <tt>textcommand</tt> is a command name which<br />
is given the text (with all markup) as a parameter. <tt>deeptextcommand</tt> is<br />
similar to <tt>textcommand</tt> but it acts only on the text (not on the markup).<br />
<br />
So, if we have <cmd>title{A story}</cmd>, the different parameters have the following results:<br />
<br />
<table><br />
<tr><br />
<td><tt>textstyle=\em</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\em A story</tt></td><br />
</tr><br />
<tr><br />
<td><tt>textstyle=\em, textcommand=\uppercase</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\uppercase{\em A story}</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\em A STORY</tt></td><br />
</tr><br />
<tr><br />
<td><tt>textstyle=\em, deeptextcommand=\uppercase</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\em\uppercase{A story}</tt></td><br />
<td><tt>=></tt><br />
</td><td><tt>\em A STORY</tt></td><br />
</tr><br />
</table><br />
<br />
What is the difference between <tt>textcommand</tt> and <tt>deeptextcommand</tt>,<br />
then? With this example there is very little difference, as <tt>uppercase</tt><br />
knows how to handle markup. Sometimes this is not the case. For example, an almost<br />
similar command <tt>WORD</tt> is not compatible with <tt>textcommand</tt>, because<br />
it wreaks havoc with markup:<br />
<br />
<table><br />
<tr><br />
<td><tt>textstyle=\em, textcommand=\WORD</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\WORD{\em A story}</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\EM A STORY</tt></td><br />
</tr><br />
<tr><br />
<td><tt>textstyle=\em, deeptextcommand=\WORD</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\em\WORD{A story}</tt></td><br />
<td><tt>=></tt></td><br />
<td><tt>\em A STORY</tt></td><br />
</tr><br />
</table><br />
<br />
In this case using <tt>deeptextcommand</tt> is the correct solution for capitalizing<br />
headers. (Using <cmd>uppercase</cmd> works in this specific case, but only if you stick<br />
to Latin 1 or Anglo-Saxon characters. Other languages will suffer from lowercase accented<br />
characters, like CAFé.)<br />
<br />
=== Truly empty pagebreak before chapters ===<br />
<br />
Using <cmd>setuppagenumbering[alternative=doublesided]</cmd> makes the chapters start<br />
on the right page. However, the blank page is not truely empty, it contains headers and<br />
footers. To get truely empty pages, use the following<br />
<br />
<texcode><br />
\definepagebreak<br />
[mychapterpagebreak]<br />
[yes,header,right]<br />
%[yes,header,left]<br />
%[yes,header,footer,right]<br />
<br />
\setuphead<br />
[chapter]<br />
[page=mychapterpagebreak]<br />
%[page=Mychapterpagebreak,header=empty,footer=empty]<br />
<br />
%\setupsectionblock[frontpart][page=chapter]<br />
%\setupsectionblock[bodypart][page=chapter]<br />
%\setupsectionblock[backpart][page=chapter]<br />
%\setupsectionblock[appendix][page=chapter]<br />
<br />
\setuppagenumbering[alternative=doublesided,location={header,margin}]<br />
\setupheadertexts[{My special headertext}]<br />
\setupfootertexts[This is a text in the footer]<br />
%\setupbackgrounds[header][text][bottomframe=on]<br />
<br />
\starttext<br />
\chapter{testA} \dorecurse{10}{\input tufte }<br />
\chapter{testB} \dorecurse{10}{\input tufte }<br />
\chapter{testC} \dorecurse{10}{\input tufte }<br />
\stoptext<br />
</texcode><br />
<br />
Explaination (provided by Willi Egger on the mailing list)<br />
<br />
* You define a new pagebreak rule. It has the name <code>mychapterpagebreak</code>. The options set read as: <code>pagebreak=yes</code>, placeheader, use a right page.<br />
* You set options for the header of type chapter and use for the option page the before defined new pagebreak.<br />
* You might want to experiment with the commented lines and see what happens. For example, the <code>\setupsectionblock</code> commands will give a truly blank page (if needed) after the specified \stop*part command.<br />
<br />
== Independent Section Numbering ==<br />
<br />
If you want section numbering to be independent of chapter numbering, use<br />
<br />
<texcode><br />
\setuphead [chapter][resetnumber=no]<br />
\setupsection[section][previousnumber=no]<br />
</texcode><br />
<br />
==Unnumbered titles in table of contents==<br />
<br />
Some times one wants an unnumbered chapter, say introduction, the following might do that trick:<br />
<br />
<texcode><br />
\definehead [intro] [chapter]<br />
\setuphead [intro] [number=no]<br />
\definecombinedlist [content][intro,chapter,section]<br />
\setuplist [intro] [headnumber=no]<br />
<br />
\starttext<br />
\completecontent<br />
\startfrontmatter<br />
\intro{No number}<br />
\stopfrontmatter<br />
<br />
\startbodymatter<br />
\chapter{Has number}<br />
\stopbodymatter<br />
\stoptext<br />
</texcode><br />
<br />
<context><br />
\definehead [intro] [chapter]<br />
\setuphead [intro] [number=no]<br />
<br />
\definecombinedlist [content][intro,chapter,section]<br />
\setuplist [intro] [headnumber=no]<br />
<br />
\starttext<br />
\completecontent<br />
\startfrontmatter<br />
\intro{No number}<br />
\stopfrontmatter<br />
<br />
\startbodymatter<br />
\chapter{Has number}<br />
\stopbodymatter<br />
\stoptext<br />
</context><br />
<br />
<br />
<br />
==Your Own Title Styles==<br />
<br />
Sometimes the possibilities of <cmd>setuphead</cmd> aren't enough. You can define<br />
your own styling commands, as shown in the following examples.<br />
<br />
===Expanded chapter titles===<br />
<br />
This example illustrates expanded chapter titles.<br />
<br />
<texcode><br />
\def\MyChapterCommand#1#2% #1 is number, #2 is text<br />
{\framed[frame=off,bottomframe=on,topframe=on]<br />
{\vbox{\headtext{chapter} #1\blank#2}}} % \vbox is needed for \blank to work<br />
<br />
\setuphead[chapter][command=\MyChapterCommand, style={\ss\bfa}]<br />
<br />
\setupheadtext[chapter=Chapter] % used by \headtext<br />
</texcode><br />
<br />
so <tt>\chapter{My First Chapter}</tt> looks like:<br />
<br />
<context><br />
\def\MyChapterCommand#1#2%<br />
{\framed[frame=off,bottomframe=on,topframe=on]<br />
{\vbox{\headtext{chapter} #1\blank#2}}}<br />
<br />
\setuphead[chapter][command=\MyChapterCommand, style={\ss\bfa}]<br />
\setupheadtext[chapter=Chapter]<br />
<br />
\chapter{My First Chapter}<br />
</context><br />
<br />
===Exercise numbers===<br />
<br />
For a textbook, suppose that you collect the exercises in a section at the end<br />
of each chapter, with each exercise a subsection having a short title, and the<br />
exercises should be numbered only by the subsection (not 1.6.7 for example,<br />
just 7). The usage:<br />
<br />
<texcode><br />
\section{Exercises}<br />
<br />
\exercise{Batteries}<br />
What is the cost of energy from a 9V battery? From a wall socket (the mains)?<br />
</texcode><br />
<br />
The setup code:<br />
<texcode><br />
\definehead[exercise][subsection]<br />
<br />
\setuphead<br />
[exercise]<br />
[style=italic, <br />
numbercommand={\determineheadnumber[subsection]\currentheadnumber\gobbleoneargument}]<br />
</texcode><br />
<br />
===A complex graphical element under the chapter title===<br />
<br />
<texcode><br />
\setupcolors[state=start]<br />
\startuseMPgraphic{HeaderDeco}<br />
numeric w, h, repeats;<br />
path p[];<br />
w := OverlayWidth ; h := OverlayHeight ;<br />
repeats := abs(TextWidth/BodyFontSize);<br />
p[1] := unitsquare xscaled w yscaled h ;<br />
draw p[1] withcolor white;<br />
p[2] := fullcircle scaled BodyFontSize;<br />
p[3] := fullcircle scaled .25BodyFontSize;<br />
draw p[2] shifted (.5BodyFontSize,0);<br />
for i = 1 upto repeats:<br />
if odd i :<br />
filldraw p[3] shifted (i*BodyFontSize+.5BodyFontSize,0);<br />
else :<br />
draw p[2] shifted (i*BodyFontSize+.5BodyFontSize,0);<br />
fi;<br />
endfor;<br />
\stopuseMPgraphic<br />
<br />
\setuphead[chapter][command=\Myheader]<br />
\setupheadtext[chapter=Chapitre]<br />
\defineoverlay[HeaderDeco][\uniqueMPgraphic{HeaderDeco}]<br />
<br />
\def\Myheader#1#2{%<br />
\framedtext<br />
[width= \overlaywidth,<br />
height=6\bodyfontsize,<br />
background={foreground,HeaderDeco},<br />
offset=0pt,<br />
strut=no,<br />
frame=off,<br />
align=middle]{%<br />
\headtext{chapter} #1<br />
\blank[small]<br />
#2}}<br />
<br />
\starttext<br />
\chapter{Here we go!}<br />
\stoptext<br />
</texcode><br />
<br />
It looks like:<br />
<br />
<context><br />
\setupcolors[state=start]<br />
\startuseMPgraphic{HeaderDeco}<br />
numeric w, h, repeats;<br />
path p[];<br />
w := OverlayWidth ; h := OverlayHeight ;<br />
repeats := abs(TextWidth/BodyFontSize);<br />
p[1] := unitsquare xscaled w yscaled h ;<br />
draw p[1] withcolor white;<br />
p[2] := fullcircle scaled BodyFontSize;<br />
p[3] := fullcircle scaled .25BodyFontSize;<br />
draw p[2] shifted (.5BodyFontSize,0);<br />
for i = 1 upto repeats:<br />
if odd i :<br />
filldraw p[3] shifted (i*BodyFontSize+.5BodyFontSize,0);<br />
else :<br />
draw p[2] shifted (i*BodyFontSize+.5BodyFontSize,0);<br />
fi;<br />
endfor;<br />
\stopuseMPgraphic<br />
<br />
\setuphead[chapter][command=\Myheader]<br />
\setupheadtext<br />
[chapter=Chapitre]<br />
\defineoverlay[HeaderDeco][\uniqueMPgraphic{HeaderDeco}]<br />
<br />
\def\Myheader#1#2{%<br />
\framedtext<br />
[width= \overlaywidth,<br />
height=6\bodyfontsize,<br />
background={foreground,HeaderDeco},<br />
offset=0pt,<br />
strut=no,<br />
frame=off,<br />
align=middle]{%<br />
\headtext{chapter} #1<br />
\blank[small]<br />
#2}}<br />
<br />
\starttext<br />
\chapter{Here we go!}<br />
\stoptext<br />
</context><br />
<br />
===Titles in margin===<br />
<br />
It is sometimes wanted to place the title of a section/subject etc in the margin next to the section text (instead of above it).<br />
This is achieved by the following setup:<br />
<br />
<texcode><br />
\setuphead<br />
[subject]<br />
[alternative=text,distance=0pt,command=\MyHead]<br />
<br />
\def\MyHead#1#2{\inmargin{#1 #2}}<br />
</texcode><br />
<br />
This (with 'style=\sc' added in setuphead) gives:<br />
<br />
<context><br />
\setuphead<br />
[subject]<br />
[alternative=text,distance=0pt,command=\MyHead,style=\sc]<br />
<br />
\def\MyHead#1#2{\inmargin{#1 #2}}<br />
<br />
\starttext<br />
<br />
\subject{First Subject}<br />
This is the text in the first subject. This is the text in the first subject.<br />
This is the text in the first subject. This is the text in the first subject.<br />
This is the text in the first subject. This is the text in the first subject.<br />
This is the text in the first subject. This is the text in the first subject.<br />
<br />
\subject{Second Subject}<br />
This is the text in the second subject. This is the text in the second subject.<br />
This is the text in the second subject. This is the text in the second subject. <br />
This is the text in the second subject. This is the text in the second subject. <br />
This is the text in the second subject. This is the text in the second subject. <br />
<br />
\stoptext<br />
</context><br />
<br />
See the mailing list thread [[http://www.ntg.nl/pipermail/ntg-context/2003/002053.html]] for more on this.<br />
<br />
===Headings numbered independent of chapters or other headings===<br />
<br />
If you want a heading that gets numbered without resetting at new sections or chapters (for example, for problems whose numbers increment throughout a book), here is a solution due to Hans [http://archive.contextgarden.net/message/20030415.153451.374310d8.en.html on the mailing list]:<br />
<br />
<texcode><br />
% use a lower level head<br />
<br />
\definehead<br />
[Problem]<br />
[subsubsubsection]<br />
<br />
% cleaned up<br />
<br />
\setuphead<br />
[Problem]<br />
[style=\ss\bf,<br />
color=red,<br />
before=\blank]<br />
<br />
% use a label text<br />
<br />
\setuplabeltext<br />
[Problem=Problem ]<br />
<br />
% use your own numbers<br />
<br />
\setuphead<br />
[Problem]<br />
[ownnumber=yes]<br />
<br />
% increment and feed<br />
<br />
\newcounter\ProblemNumber<br />
<br />
\def\problem#1%<br />
{\doglobal\increment\ProblemNumber<br />
\Problem{\ProblemNumber}{#1}}<br />
<br />
% nicer here<br />
<br />
\setuplist<br />
[Problem]<br />
[alternative=c,<br />
criterium=all,<br />
width=2em,<br />
interaction=all]<br />
<br />
% the test<br />
<br />
\starttext<br />
<br />
List of Problems<br />
<br />
\blank[big] \placelist[Problem] \blank[big]<br />
<br />
\section{Tufte}<br />
<br />
\input tufte<br />
<br />
\problem{First problem}<br />
<br />
The first problem description.<br />
<br />
\section{Another Tufte}<br />
<br />
\input tufte<br />
<br />
\problem{Second problem}<br />
<br />
Second problem description.<br />
<br />
\stoptext<br />
</texcode><br />
<br />
===Chapter headers===<br />
<br />
Setup of headers like chapters.<br />
<br />
While reading Pixar docs about Renderman, I've found their headers nice and wanted to copy this style.<br />
I found a premise in Metafun manual, p.187 (Hello text), and Hans email me ([http://archive.contextgarden.net/message/20041020.100630.d531bb1d.en.html 20/10/2004 ]) on the context list a more simple solution than using metapost. The minimum is to put it here, for others who are like me, wandering for source code.<br />
Feel free to adapt code below to your langage specific settings, mine is french.<br />
<br />
<texcode><br />
\useencoding[ffr]<br />
\mainlanguage[fr]<br />
\enableregime[utf] %for UTF8<br />
<br />
% \enableregime[il1] %for ISO 8859-1 8859-15<br />
<br />
\usetypescript[palatino][texnansi]<br />
\setupbodyfont[palatino,rm,12pt]<br />
<br />
\setupcolors[state=start]<br />
<br />
\definefont[BigFontOne][Regular sa 3] %RegularSlanted sa 3(ori)%Sans sa 3:don't work (pb accents)<br />
\definefont[BigFontTwo][RegularBold sa 2] %%RegularSlanted<br />
<br />
\definecolor[BigColorOne][r=.86,g=.850,b=.54]<br />
\definecolor[BigColorTwo][r=.43,g=.425,b=.27]<br />
<br />
\setuphead<br />
[chapter]<br />
[textcommand=\MyChapterText,<br />
color=BigColorTwo,<br />
style=\BigFontTwo]<br />
<br />
\def\MyChapterText#1{\rlap{\BigFontOne\BigColorOne#1}\kern15pt#1}<br />
<br />
\starttext<br />
<br />
\chapter[chap:ques]{Question}<br />
\chapter[chap:answ]{Answer}<br />
\chapter[chap:answ]{Remarque}<br />
\chapter[chap:answ]{Cours}<br />
\chapter[chap:answ]{Exercice}<br />
\chapter[chap:answ]{Travail dirigé}<br />
\chapter[chap:answ]{Exposé}<br />
\stoptext<br />
</texcode><br />
<br />
I've tryed to change a bit Hans code, by putting \kern15pt, for moving backgroundtext to the left of \rlap alignment, and an unsuccess one to switch same backgroundtext in Sans font (no french accents).<br />
<br />
olivier<br />
<br />
<context><br />
\useencoding[ffr]<br />
\mainlanguage[fr]<br />
<br />
% fonts currently don't work this way,<br />
% I'll fix that soon. Patrick<br />
<br />
% \usetypescript[palatino][texnansi]<br />
% \setupbodyfont[palatino,rm,12pt]<br />
<br />
\setupcolors[state=start]<br />
<br />
\definefont[BigFontOne][Regular sa 3] %RegularSlanted sa 3(ori)%Sans sa 3:don't work (pb accents)<br />
\definefont[BigFontTwo][RegularBold sa 2] %%RegularSlanted<br />
<br />
\definecolor[BigColorOne][r=.86,g=.850,b=.54]<br />
\definecolor[BigColorTwo][r=.43,g=.425,b=.27]<br />
<br />
\setuphead<br />
[chapter]<br />
[textcommand=\MyChapterText,<br />
color=BigColorTwo,<br />
style=\BigFontTwo]<br />
<br />
\def\MyChapterText#1{\rlap{\BigFontOne\BigColorOne#1}\kern15pt#1}<br />
<br />
\starttext<br />
<br />
\chapter[chap:ques]{Question}<br />
<br />
% only one page please, since this is displayed inline. Patrick<br />
% \chapter[chap:answ]{Answer}<br />
% \chapter[chap:answ]{Remarque}<br />
% \chapter[chap:answ]{Cours}<br />
% \chapter[chap:answ]{Exercice}<br />
% \chapter[chap:answ]{Travail dirigé}<br />
% \chapter[chap:answ]{Exposé}<br />
\stoptext<br />
</context><br />
<br />
===Figures in Headings===<br />
<br />
This example shows how to completely replace the chapter text and number by an image:<br />
<br />
<context source="yes"><br />
\setupexternalfigures[location=default] % needed only for the wiki to the find the figure<br />
<br />
\useexternalfigure[chapter-1][cow.pdf]<br />
\useexternalfigure[chapter-2][hacker.jpg]<br />
<br />
\setuphead<br />
[chapter]<br />
[command=\MyChapterCommand]<br />
<br />
\def\MyChapterCommand#1#2%<br />
{\externalfigure[chapter-\currentheadnumber][height=5cm]}<br />
<br />
\starttext<br />
<br />
\chapter{One}<br />
\section{First section of Chapter One}<br />
<br />
\stoptext<br />
</context><br />
<br />
However, this "forgets" to put the chapter in the TOC. So you have to set<br />
the <tt>textcommand</tt> and <tt>numbercommand</tt> separately instead<br />
(thus retaining the command that puts the chapter in the TOC), rather than<br />
setting the overall <tt>command</tt>, if you need a complete TOC.<br />
<br />
<texcode><br />
\setuphead<br />
[chapter]<br />
[textcommand=\MyChapterTextCommand,<br />
numbercommand=\MyChapterNumberCommand]<br />
<br />
\def\MyChapterNumberCommand#1{} % hide chapter number<br />
<br />
\def\MyChapterTextCommand#1%<br />
{\externalfigure[chapter-\currentheadnumber][height=5cm]}<br />
</texcode><br />
<br />
[http://archive.contextgarden.net/message/20050519.215526.df7c5cd1.html]<br />
<br />
===Chapter head with absolute positioning of following text===<br />
<br />
<texcode><br />
\setuphead[chapter][before=\vbox to 4cm\bgroup,after=\vss\egroup]<br />
\starttext<br />
\chapter{test} \input tufte<br />
\stoptext<br />
</texcode><br />
<br />
No matter how many lines the chapter head runs to, the text will always start, e.g. 4cm below the top of the heading:<br />
<br />
<context><br />
\setuppapersize[A6][A6]<br />
\setuphead[chapter][before=\vbox to 4cm\bgroup,after=\vss\egroup]<br />
\setupbodyfont[8pt]<br />
\starttext<br />
\chapter{test} \input tufte<br />
\stoptext<br />
</context><br />
<br />
====Bug and proposed workaround====<br />
<br />
I tried this sample and <cmd>getmarking[chapter]</cmd>, used in my headers,<br />
stopped to work properly. Proposed workaround below.<br />
--[[User:Sebastian.rooks|SeR]] 00:52, 27 January 2006 (CET)<br />
<br />
<texcode><br />
\def\MyChapterCommand#1#2%<br />
{\vbox to 4cm\bgroup<br />
{#1\hskip.75em #2}<br />
\vss<br />
\egroup}<br />
<br />
\setuphead[chapter][header=nomarking,command=\MyChapterCommand]<br />
\starttext<br />
\chapter{test} \input tufte<br />
\stoptext<br />
</texcode><br />
<br />
<context><br />
\setuppapersize[A6][A6]<br />
\setupbodyfont[8pt]<br />
\def\MyChapterCommand#1#2%<br />
{\vbox to 4cm\bgroup<br />
{#1\hskip.75em #2}<br />
\vss<br />
\egroup}<br />
\setuphead[chapter][header=nomarking,command=\MyChapterCommand]<br />
\starttext<br />
\chapter{test} \input tufte<br />
\stoptext<br />
</context><br />
<br />
===Section head with underlining to width of last line===<br />
<br />
A style called for section headings to be followed by a rule which extends only the width of the text. More tricky was the need to make sure that if the text ran onto another line, it was the length of the ''last'' line that was to be followed. <br />
<br />
Hans came up with this cleverness, showing two alternate ways of doing it:<br />
<br />
<context source="yes" text="produces"><br />
\def\FirstSolution#1#2%<br />
{\vbox\bgroup<br />
\setbox0\hbox{#1}<br />
\hsize.4\textwidth<br />
\beginshapebox#2\endshapebox<br />
\gdef\SetLastLineWidth{\xdef\LastLineWidth{\the\wd\scratchbox}}%<br />
\reshapebox<br />
{\setbox\scratchbox\hbox{\unhbox\shapebox}%<br />
\SetLastLineWidth<br />
\globallet\SetLastLineWidth\relax<br />
\box\scratchbox}%<br />
\scratchdimen\dimexpr\wd0+.25em+\LastLineWidth\relax<br />
% \setbox2\ruledvbox {\innerflushshapebox} <br />
% why is correction needed<br />
\setbox2\vbox {\vskip-\lineskip\innerflushshapebox}<br />
\setbox0\vbox to \ht2{\box0}<br />
\hbox{\box0\hskip.25em\box2}<br />
\offinterlineskip<br />
\vskip.25ex<br />
\blackrule[width=\scratchdimen,height=1pt]<br />
\egroup}<br />
<br />
\doglobal\newcounter\NextLinePos<br />
<br />
\def\SecondSolution#1#2%<br />
{\vbox\bgroup<br />
\hsize.4\textwidth<br />
\doglobal\increment\NextLinePos<br />
\setbox\scratchbox\hbox{#1}<br />
\hbox{\vtop{\copy\scratchbox}\hskip.25em\vtop{#2}}%<br />
\offinterlineskip<br />
\scratchdimen\dimexpr\wd\scratchbox+.25em+<br />
\MPx{e:npl:\NextLinePos}-\MPx{b:npl:\NextLinePos}\relax<br />
\vskip.25ex<br />
\blackrule[width=\scratchdimen,height=1pt]<br />
\egroup}<br />
<br />
\def\DoSecondSolution#1%<br />
{\bpos{npl:\NextLinePos}#1\epos{npl:\NextLinePos}}<br />
<br />
% \showstruts<br />
<br />
\setuphead[section][command=\FirstSolution]<br />
<br />
\starttext<br />
<br />
\section{is this nice or not}<br />
<br />
\section{is this nice or not nice, that's the question}<br />
<br />
\setuphead[section][command=\SecondSolution,deeptextcommand=\DoSecondSolution]<br />
<br />
\section{is this nice or not}<br />
<br />
\section{is this nice or not nice, that's the question}<br />
<br />
\stoptext<br />
</context><br />
<br />
As if that wasn't enough, Taco pointed out that <cmd>lastlinewidth</cmd><br />
is the easy route to finding the width of the last line. Use something like:<br />
<br />
<code><br />
\optimizedisplayspacingtrue\setlastlinewidth % core-mat macro<br />
\global\advance\lastlinewidth-\hangindent\par % adjust<br />
\blackrule[width=\lastlinewidth,height=1pt]<br />
</code><br />
<br />
<br />
[[Category:Fonts]]<br />
[[Category:Graphics]]<br />
[[Category:Text elements]]</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Color&diff=9805Color2009-06-01T14:56:36Z<p>Nicolas Girard: /* Background of cells in tables */ +link to example</p>
<hr />
<div>< [[Visuals]] | [[Graphics]] ><br />
<br />
= Enabling colors =<br />
<br />
In current versions (earlier than 11.05.2009) of ConTeXt mkiv, colors are enabled by default.<br />
<br />
In older versions, colors must be enabled using<br />
<cmd>setupcolors</cmd><tt>[state=start]</tt><br />
<br />
=Defining Colors=<br />
<br />
Using colors with ConTeXt is easy:<br />
<br />
== Choosing a color model ==<br />
<br />
* RGB and CMYK are enabled by default. If you want only RGB or only CMYK color, use <tt>cmyk=no</tt> or <tt>rgb=no</tt>. Multitone colors see below. <br />
* For spot colors, say spot=yes. To eliminate everything except spot colours, leaving a clean file for professional printing, accompany this with rgb=no,cmyk=no. See spot colours below for more details.<br />
* Normally all colors are defined in RGB ''and'' CMYK and get converted if needed.<br />
<br />
== Using predefined colors: <cmd>setupcolor</cmd> ==<br />
<br />
You find lists of predefined colors in the files <tt>colo-xxx.tex</tt>, load them with <cmd>setupcolor</cmd><tt>[xxx]</tt>:<br />
* rgb: some simple colors, loaded by default (with translations for the different interface languages!)<br />
* xwi: X-Windows-colors<br />
* pra: PRAGMA ADE company colors<br />
* ema: Emacs colors<br />
<br />
* Try the magic <cmd>showcolor</cmd><tt>[xxx]</tt>!<br />
<br />
{|<br />
! width="25%"|<br />
! width="10%"|<br />
! width="65%"|<br />
|-<br />
| <texcode><br />
\showcolor[rgb]<br />
</texcode><br />
|<br />
| <context><br />
\setupcolors[state=start]<br />
\showcolor[rgb]<br />
</context><br />
|}<br />
<br />
== Defining colors: <cmd>definecolor</cmd> ==<br />
<br />
<cmd>definecolor</cmd><tt>[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]</tt> (definition for RGB, CMYK and Grey!)<br />
<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\definecolor[blablue][r=.25, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]<br />
<br />
Here's some \color[blablue]{blue text} inbetween!<br />
</texcode><br />
|<br />
| <context><br />
\setupcolors[state=start]<br />
\definecolor[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]<br />
<br />
Here's some \color[blablue]{blue text} inbetween!<br />
</context><br />
|}<br />
<br />
=== Colors with Hexadecimal Numbers ===<br />
<br />
You can also use hexadecimal numers to specify colors. You need to load the '''hex''' color module first:<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\setupcolor[hex]<br />
\definecolor[salmon][h=AB5757]<br />
<br />
Hey, \color[salmon]{look at that!}<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\setupcolor[hex]<br />
\definecolor[salmon][h=AB5757]<br />
<br />
Hey, \color[salmon]{look at that!}<br />
</context><br />
|}<br />
<br />
===Transparent Colors===<br />
<br />
You can define '''transparent''' colors through setting t, e.g. <tt>t=0.5</tt>. Beware, some PDF viewers and printshops can't handle PDF transparences!<br />
<br />
Hans Hagen posted the following sample code for transparent colors on the mailing list on 2005-07-13; the yellow blocks have been added to demonstrate the order in which the blocks are drawn on the page; the first yellow block is behind the transparent red and blue blocks, while the second is in front of them.<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\definecolor [transparentred] [r=1,t=.5,a=1]<br />
\definecolor [transparentblue] [b=1,t=.5,a=1]<br />
\definecolor [solidyellow] [y=1,t=1,a=1]<br />
<br />
\starttext<br />
<br />
\startTEXpage<br />
This is some sample text that goes behind the rectangles\hskip-8cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=transparentred]\hskip-0.67cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=transparentblue]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=solidyellow]\hskip2cm.<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\definecolor [transparentred] [r=1,t=.5,a=1]<br />
\definecolor [transparentblue] [b=1,t=.5,a=1]<br />
\definecolor [solidyellow] [y=1,t=1,a=1]<br />
<br />
\starttext<br />
<br />
\startTEXpage<br />
This is some sample text that goes behind the rectangles\hskip-8cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=transparentred]\hskip-0.67cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=transparentblue]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=solidyellow]\hskip2cm.<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</context><br />
|}<br />
<br />
== Defining color schemes: <cmd>definecolorgroup</cmd> and <cmd>definepalet</cmd>==<br />
<cmd>definecolorgroup</cmd><tt>[name][system][values]</tt><br />
<br />
<cmd>definepalet</cmd><tt>[palettename][colorname1=groupcolor:1, colorname2=groupcolor:2, ...]</tt><br />
<br />
Very interesting feature, to be described later... (see manual)<br />
<br />
=Choosing a color scheme=<br />
<br />
There are three basic strategies to select color combinations for a particular design<br />
<br />
# Create a color scheme by picking several colors found within the objects to be used (photographs, pictures, etc)<br />
# Create colors derived from those found in the objects to be used<br />
# Create a color scheme based on the message to convey / the psychological effects of color<br />
<br />
See for additional help & reference:<br />
* [http://colorschemedesigner.com/ colorschemedesigner.com] - Useful site to help choose a color scheme in rgb color space<br />
* Tina Sutton, Bride M Whelan: The Complete Color Harmony. Rockport Publishers (2004). ISBN 978-1592530311 (recommanded in the mailing list)<br />
<br />
<br />
=Using Colors=<br />
<br />
* Use the color name like <tt>[color=blablue]</tt> in some <tt>\setup...</tt> command.<br />
<br />
== With text ==<br />
<br />
Typeset single text elements with <cmd>color</cmd><tt>[colorname]{nice blue text}</tt>:<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
Three \color[red]{cool} cats<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\starttext<br />
Three \color[red]{cool} cats<br />
\stoptext<br />
</context><br />
|}<br />
<br />
Typeset longer sections with <cmd>startcolor</cmd><tt>[colorname] ...</tt> <cmd>stopcolor</cmd>:<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\starttext<br />
\startcolor[orange]<br />
\input tufte<br />
\stopcolor<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\starttext<br />
\startcolor[orange]<br />
\input tufte<br />
\stopcolor<br />
\stoptext<br />
</context><br />
|}<br />
<br />
== With frames ==<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\framed[background=color, backgroundcolor=green]{bla}<br />
\framed[background=color, backgroundcolor=yellow, corner=00]{bla}<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
<br />
\starttext<br />
\framed[background=color, backgroundcolor=green]{bla}<br />
\framed[background=color, backgroundcolor=yellow, corner=00]{bla}<br />
</context><br />
|}<br />
<br />
== Background of the page ==<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\setupbackgrounds[page][background=color,backgroundcolor=blue]<br />
<br />
\starttext<br />
text<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
<br />
\setupbackgrounds[page][background=color,backgroundcolor=blue]<br />
<br />
\starttext<br />
text<br />
\stoptext<br />
</context><br />
|}<br />
<br />
== Background of cells in tables ==<br />
<br />
See<br />
* [[Table#Background Colors]]<br />
* [[TABLE#Round_corners]]<br />
<br />
== In Metapost ==<br />
<br />
Metapost in MkIV is different from MkII and all labels are typeset<br />
and colored in TeX, if you want a label use<br />
label(textext("\blue RED"),origin) ;<br />
<br />
== In TikZ ==<br />
<br />
<texcode><br />
\usemodule[tikz]<br />
\starttext<br />
\tikz\shade[ball color=red!40!yellow] (0,0) circle (.15cm);<br />
\stoptext<br />
</texcode><br />
<br />
=Spot colours=<br />
<br />
To produce a file ready for a clean PDF separation process at your print house, start with:<br />
<br />
<cmd>setupcolors</cmd><tt>[rgb=no,cmyk=yes,spot=yes,state=start,overprint=yes]</tt><br />
<br />
which will set things up for spot colors with CMYK allowed. The last setting ensures that black overprinting your spot colour tints will not knock out the colour - this is important for some types of commercial printing.<br />
<br />
Then define your basic spot colour. Note that the name cannot contain spaces or numbers (but we come to that later):<br />
<br />
<cmd>definecolor</cmd><tt>[PantoneTwoNineFour][c=1,m=.56,y=0,k=.18]</tt><br />
<br />
Now you can define the tints of this ink that you are actually going to use in your document. Let's say you'll have a 100% for headings:<br />
<br />
<cmd>definespotcolor</cmd><tt>[MyBlue][PantoneTwoNineFour][p=1]</tt><br />
<br />
And then a 20% tint for nice display boxes:<br />
<br />
<cmd>definespotcolor</cmd><tt>[MyBlueTint][PantoneTwoNineFour][p=.2]</tt><br />
<br />
And now you can happily use these named colours:<br />
<br />
<texcode><br />
\starttext<br />
\color[MyBlue]{Interesting}<br />
\stoptext<br />
</texcode><br />
<br />
If you are including graphics made by an external program, you might want to match the colour name used in the graphic with the colour name in your '''ConTeXt''' set-up so that only one colour space is used in the final file. Unfortunately Pantone names and others tend to have spaces and numbers in them, so you need to do a low-level mapping trick from your base name to the name you want embedded in the file:<br />
<br />
<cmd>doregisterspotcolorname</cmd><tt>{PantoneTwoNineFour}{PANTONE 294 CV}</tt><br />
<br />
Now your output file should work beautifully with graphics embedded!<br />
<br />
==Using the 'e' key to \definecolor to specify a spot colour name with spaces==<br />
<br />
As an update to the above description on defining spot colours, you can now use the 'e' key when defining your spot colours in order to specify the precise colour names to be used by your ConTeXt set-up in the output file. For example:<br />
<br />
<texcode><br />
% Define spot colours using 'e=....' to specify colour names to use in output file<br />
\definecolor<br />
[PantoneThreeZeroEight]<br />
[c=1,m=.05,y=0,k=.47,e=PANTONE 308 CV]<br />
<br />
\definecolor<br />
[PantoneTwoNineEight]<br />
[c=.69,m=.07,y=0,k=0,e=PANTONE 298 CV]<br />
<br />
% Define tints of spot colours to be used in document for colouring text<br />
\definespotcolor<br />
[DarkBlue]<br />
[PantoneThreeZeroEight]<br />
[p=1]<br />
<br />
\definespotcolor<br />
[LightBlue]<br />
[PantoneTwoNineEight]<br />
[p=1]<br />
</texcode><br />
<br />
(Tested only on minimal Linux distribution dated 31 Aug 2005 - can others confirm this<br />
to be true across the board now?)<br />
<br />
Any text between a <cmd>startcolor[DarkBlue]</cmd> and <cmd>stopcolor</cmd> should now be assigned to the correct spot colour channel - Pantone 308 CV - on output. More importantly if you include an external figure containing areas of this colour then your text and those parts of the graphic which have the same colour should now appear together in the 'Pantone 308 CV' colour channel on colour separation. <br />
<br />
For example, if your original graphic is an EPS file containing the following lines:<br />
<br />
%%DocumentCustomColors: (PANTONE 298 CV)<br />
%%+ (PANTONE 308 CV)<br />
%%CMYKCustomColor: 0.69 0.07 0 0 (PANTONE 298 CV)<br />
%%+ 1 0.05 0 0.47 (PANTONE 308 CV)<br />
<br />
and you convert this to a PDF using <tt>ps2pdf</tt> for inclusion in your '''ConTeXt''' document your PDF graphic will then contain something like:<br />
<br />
<code><br />
8 0 obj<br />
[/Separation<br />
/PANTONE#20308#20CV<br />
/DeviceCMYK<br />
9 0 R]endobj<br />
10 0 obj<br />
[/Separation<br />
/PANTONE#20298#20CV<br />
/DeviceCMYK<br />
11 0 R]endobj<br />
</code><br />
<br />
Note how the space characters in the colour name are now encoded as '#20', but the colour names are essentially identical between the original EPS graphic, the new PDF graphic and your text.<br />
<br />
A good way of testing colour separation if you don't have access to expensive pre-flight PDF validation tools is to use the following GhostScript command:<br />
<br />
gs \<br />
-dBATCH \<br />
-dNOPAUSE \<br />
-sDEVICE=tiffsep \<br />
-dDOINTERPOLATE \<br />
-dTextAlphaBits=4 \<br />
-dGraphicsAlphaBits=4 \<br />
-sOutputFile=output.tif \<br />
-r120 \<br />
-MaxSeparations=8 \<br />
input.pdf<br />
<br />
This renders a PDF file <tt>input.pdf</tt> as a set of TIFF files:<br />
<br />
output.tif - Composite including CMYK approximations to spot colours<br />
output.tif.Black.tif - K channel<br />
output.tif.Cyan.tif - C channel<br />
output.tif.Magenta.tif - M channel<br />
output.tif.Yellow.tif - Y channel<br />
output.tif.s0.tif - Pantone 308 CV<br />
output.tif.s1.tif - Pantone 298 CV<br />
<br />
=Multitones=<br />
<br />
Hans wrote on the mailinglist on 2004-12-27 about handling of multitone colors:<br />
<br />
Currently it's done by pdftools.rb<br />
<br />
Once pdfxTeX becomes pdfeTeX out of a sudden your beta can do it as well.<br />
<br />
I still need to figure out a way to automatically reverse the graphic, but one of these days you can start using it.<br />
<br />
Actually, multitones for text already work out of the box:<br />
<texcode><br />
\setupcolors[state=start]<br />
<br />
\definecolor [blue] [c=1,m=.38,y=0,k=.64]<br />
\definecolor [yellow] [c=0,m=.28,y=1,k=.06]<br />
<br />
\definespotcolor [blue-100] [blue] [p=1]<br />
\definespotcolor [yellow-100] [yellow] [p=1]<br />
<br />
\definemultitonecolor [combicolor] [blue=.12,yellow=.28] [c=.1,m=.1,y=.3,k=.1]<br />
<br />
\starttext<br />
<br />
\startcolor[blue]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\startcolor[yellow]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\startcolor[combicolor]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\stoptext<br />
</texcode><br />
(The CMYK color spec is the fall back color used on screen; one can preview separations in full Acrobat 7.)<br />
<br />
<br />
<br />
=Colorizing Grayscale Pictures=<br />
<br />
Another sample by Hans (mailing list 2005-11-16) demonstrates a lot of different possibilities:<br />
<br />
<texcode><br />
\setuplayout[header=0pt,footer=0pt,width=middle,height=middle,backspace=1cm,topspace=1cm]<br />
\setupcolors[state=start]<br />
<br />
\startbuffer<br />
\definecolor [blue] [c=1, m=.38, y=0, k=.64]<br />
\definecolor [yellow] [c=0, m=.28, y=1, k=.06]<br />
<br />
\definespotcolor [blue-100] [blue] [p=1]<br />
\definespotcolor [yellow-100] [yellow] [p=1]<br />
<br />
\definemultitonecolor [combicolor] [blue=.12, yellow=.28] [c=.1, m=.1, y=.3, k=.1]<br />
<br />
\definemultitonecolor [combicolor-b] [blue=1] [c=1, m=.38, y=0, k=.64] % force multitone<br />
\definemultitonecolor [combicolor-y] [yellow=1] [c=0, m=.28, y=1, k=.06] % force multitone<br />
<br />
\useexternalfigure[demo-a][mill.png] [object=no, width=.2\textwidth]<br />
\useexternalfigure[demo-b][hacker-bw.jpg][object=no, width=.2\textwidth]<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-a]} {no color}<br />
{\externalfigure[demo-a][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-a][color=combicolor-b]} {spot color}<br />
{\externalfigure[demo-a][color=combicolor-y]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-b]} {no color}<br />
{\externalfigure[demo-b][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-b][color=combicolor-b]} {spot color}<br />
{\externalfigure[demo-b][color=combicolor-y]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-a]} {no color}<br />
{\externalfigure[demo-a][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-a][color=blue-100]} {spot color}<br />
{\externalfigure[demo-a][color=yellow-100]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-b]} {no color}<br />
{\externalfigure[demo-b][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-b][color=blue-100]} {spot color}<br />
{\externalfigure[demo-b][color=yellow-100]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
\stopbuffer<br />
<br />
\getbuffer \typebuffer<br />
<br />
\stoptext<br />
</texcode><br />
<br />
= References =<br />
<br />
See "Color and Background" in the manual</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Color&diff=9804Color2009-06-01T14:52:08Z<p>Nicolas Girard: /* Using Colors */ +With frames</p>
<hr />
<div>< [[Visuals]] | [[Graphics]] ><br />
<br />
= Enabling colors =<br />
<br />
In current versions (earlier than 11.05.2009) of ConTeXt mkiv, colors are enabled by default.<br />
<br />
In older versions, colors must be enabled using<br />
<cmd>setupcolors</cmd><tt>[state=start]</tt><br />
<br />
=Defining Colors=<br />
<br />
Using colors with ConTeXt is easy:<br />
<br />
== Choosing a color model ==<br />
<br />
* RGB and CMYK are enabled by default. If you want only RGB or only CMYK color, use <tt>cmyk=no</tt> or <tt>rgb=no</tt>. Multitone colors see below. <br />
* For spot colors, say spot=yes. To eliminate everything except spot colours, leaving a clean file for professional printing, accompany this with rgb=no,cmyk=no. See spot colours below for more details.<br />
* Normally all colors are defined in RGB ''and'' CMYK and get converted if needed.<br />
<br />
== Using predefined colors: <cmd>setupcolor</cmd> ==<br />
<br />
You find lists of predefined colors in the files <tt>colo-xxx.tex</tt>, load them with <cmd>setupcolor</cmd><tt>[xxx]</tt>:<br />
* rgb: some simple colors, loaded by default (with translations for the different interface languages!)<br />
* xwi: X-Windows-colors<br />
* pra: PRAGMA ADE company colors<br />
* ema: Emacs colors<br />
<br />
* Try the magic <cmd>showcolor</cmd><tt>[xxx]</tt>!<br />
<br />
{|<br />
! width="25%"|<br />
! width="10%"|<br />
! width="65%"|<br />
|-<br />
| <texcode><br />
\showcolor[rgb]<br />
</texcode><br />
|<br />
| <context><br />
\setupcolors[state=start]<br />
\showcolor[rgb]<br />
</context><br />
|}<br />
<br />
== Defining colors: <cmd>definecolor</cmd> ==<br />
<br />
<cmd>definecolor</cmd><tt>[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]</tt> (definition for RGB, CMYK and Grey!)<br />
<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\definecolor[blablue][r=.25, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]<br />
<br />
Here's some \color[blablue]{blue text} inbetween!<br />
</texcode><br />
|<br />
| <context><br />
\setupcolors[state=start]<br />
\definecolor[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]<br />
<br />
Here's some \color[blablue]{blue text} inbetween!<br />
</context><br />
|}<br />
<br />
=== Colors with Hexadecimal Numbers ===<br />
<br />
You can also use hexadecimal numers to specify colors. You need to load the '''hex''' color module first:<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\setupcolor[hex]<br />
\definecolor[salmon][h=AB5757]<br />
<br />
Hey, \color[salmon]{look at that!}<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\setupcolor[hex]<br />
\definecolor[salmon][h=AB5757]<br />
<br />
Hey, \color[salmon]{look at that!}<br />
</context><br />
|}<br />
<br />
===Transparent Colors===<br />
<br />
You can define '''transparent''' colors through setting t, e.g. <tt>t=0.5</tt>. Beware, some PDF viewers and printshops can't handle PDF transparences!<br />
<br />
Hans Hagen posted the following sample code for transparent colors on the mailing list on 2005-07-13; the yellow blocks have been added to demonstrate the order in which the blocks are drawn on the page; the first yellow block is behind the transparent red and blue blocks, while the second is in front of them.<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\definecolor [transparentred] [r=1,t=.5,a=1]<br />
\definecolor [transparentblue] [b=1,t=.5,a=1]<br />
\definecolor [solidyellow] [y=1,t=1,a=1]<br />
<br />
\starttext<br />
<br />
\startTEXpage<br />
This is some sample text that goes behind the rectangles\hskip-8cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=transparentred]\hskip-0.67cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=transparentblue]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=solidyellow]\hskip2cm.<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\definecolor [transparentred] [r=1,t=.5,a=1]<br />
\definecolor [transparentblue] [b=1,t=.5,a=1]<br />
\definecolor [solidyellow] [y=1,t=1,a=1]<br />
<br />
\starttext<br />
<br />
\startTEXpage<br />
This is some sample text that goes behind the rectangles\hskip-8cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=transparentred]\hskip-0.67cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=transparentblue]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=solidyellow]\hskip2cm.<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</context><br />
|}<br />
<br />
== Defining color schemes: <cmd>definecolorgroup</cmd> and <cmd>definepalet</cmd>==<br />
<cmd>definecolorgroup</cmd><tt>[name][system][values]</tt><br />
<br />
<cmd>definepalet</cmd><tt>[palettename][colorname1=groupcolor:1, colorname2=groupcolor:2, ...]</tt><br />
<br />
Very interesting feature, to be described later... (see manual)<br />
<br />
=Choosing a color scheme=<br />
<br />
There are three basic strategies to select color combinations for a particular design<br />
<br />
# Create a color scheme by picking several colors found within the objects to be used (photographs, pictures, etc)<br />
# Create colors derived from those found in the objects to be used<br />
# Create a color scheme based on the message to convey / the psychological effects of color<br />
<br />
See for additional help & reference:<br />
* [http://colorschemedesigner.com/ colorschemedesigner.com] - Useful site to help choose a color scheme in rgb color space<br />
* Tina Sutton, Bride M Whelan: The Complete Color Harmony. Rockport Publishers (2004). ISBN 978-1592530311 (recommanded in the mailing list)<br />
<br />
<br />
=Using Colors=<br />
<br />
* Use the color name like <tt>[color=blablue]</tt> in some <tt>\setup...</tt> command.<br />
<br />
== With text ==<br />
<br />
Typeset single text elements with <cmd>color</cmd><tt>[colorname]{nice blue text}</tt>:<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
Three \color[red]{cool} cats<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\starttext<br />
Three \color[red]{cool} cats<br />
\stoptext<br />
</context><br />
|}<br />
<br />
Typeset longer sections with <cmd>startcolor</cmd><tt>[colorname] ...</tt> <cmd>stopcolor</cmd>:<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\starttext<br />
\startcolor[orange]<br />
\input tufte<br />
\stopcolor<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\starttext<br />
\startcolor[orange]<br />
\input tufte<br />
\stopcolor<br />
\stoptext<br />
</context><br />
|}<br />
<br />
== With frames ==<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\framed[background=color, backgroundcolor=green]{bla}<br />
\framed[background=color, backgroundcolor=yellow, corner=00]{bla}<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
<br />
\starttext<br />
\framed[background=color, backgroundcolor=green]{bla}<br />
\framed[background=color, backgroundcolor=yellow, corner=00]{bla}<br />
</context><br />
|}<br />
<br />
== Background of the page ==<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\setupbackgrounds[page][background=color,backgroundcolor=blue]<br />
<br />
\starttext<br />
text<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
<br />
\setupbackgrounds[page][background=color,backgroundcolor=blue]<br />
<br />
\starttext<br />
text<br />
\stoptext<br />
</context><br />
|}<br />
<br />
== Background of cells in tables ==<br />
<br />
See [[Table#Background Colors]]<br />
<br />
== In Metapost ==<br />
<br />
Metapost in MkIV is different from MkII and all labels are typeset<br />
and colored in TeX, if you want a label use<br />
label(textext("\blue RED"),origin) ;<br />
<br />
== In TikZ ==<br />
<br />
<texcode><br />
\usemodule[tikz]<br />
\starttext<br />
\tikz\shade[ball color=red!40!yellow] (0,0) circle (.15cm);<br />
\stoptext<br />
</texcode><br />
<br />
=Spot colours=<br />
<br />
To produce a file ready for a clean PDF separation process at your print house, start with:<br />
<br />
<cmd>setupcolors</cmd><tt>[rgb=no,cmyk=yes,spot=yes,state=start,overprint=yes]</tt><br />
<br />
which will set things up for spot colors with CMYK allowed. The last setting ensures that black overprinting your spot colour tints will not knock out the colour - this is important for some types of commercial printing.<br />
<br />
Then define your basic spot colour. Note that the name cannot contain spaces or numbers (but we come to that later):<br />
<br />
<cmd>definecolor</cmd><tt>[PantoneTwoNineFour][c=1,m=.56,y=0,k=.18]</tt><br />
<br />
Now you can define the tints of this ink that you are actually going to use in your document. Let's say you'll have a 100% for headings:<br />
<br />
<cmd>definespotcolor</cmd><tt>[MyBlue][PantoneTwoNineFour][p=1]</tt><br />
<br />
And then a 20% tint for nice display boxes:<br />
<br />
<cmd>definespotcolor</cmd><tt>[MyBlueTint][PantoneTwoNineFour][p=.2]</tt><br />
<br />
And now you can happily use these named colours:<br />
<br />
<texcode><br />
\starttext<br />
\color[MyBlue]{Interesting}<br />
\stoptext<br />
</texcode><br />
<br />
If you are including graphics made by an external program, you might want to match the colour name used in the graphic with the colour name in your '''ConTeXt''' set-up so that only one colour space is used in the final file. Unfortunately Pantone names and others tend to have spaces and numbers in them, so you need to do a low-level mapping trick from your base name to the name you want embedded in the file:<br />
<br />
<cmd>doregisterspotcolorname</cmd><tt>{PantoneTwoNineFour}{PANTONE 294 CV}</tt><br />
<br />
Now your output file should work beautifully with graphics embedded!<br />
<br />
==Using the 'e' key to \definecolor to specify a spot colour name with spaces==<br />
<br />
As an update to the above description on defining spot colours, you can now use the 'e' key when defining your spot colours in order to specify the precise colour names to be used by your ConTeXt set-up in the output file. For example:<br />
<br />
<texcode><br />
% Define spot colours using 'e=....' to specify colour names to use in output file<br />
\definecolor<br />
[PantoneThreeZeroEight]<br />
[c=1,m=.05,y=0,k=.47,e=PANTONE 308 CV]<br />
<br />
\definecolor<br />
[PantoneTwoNineEight]<br />
[c=.69,m=.07,y=0,k=0,e=PANTONE 298 CV]<br />
<br />
% Define tints of spot colours to be used in document for colouring text<br />
\definespotcolor<br />
[DarkBlue]<br />
[PantoneThreeZeroEight]<br />
[p=1]<br />
<br />
\definespotcolor<br />
[LightBlue]<br />
[PantoneTwoNineEight]<br />
[p=1]<br />
</texcode><br />
<br />
(Tested only on minimal Linux distribution dated 31 Aug 2005 - can others confirm this<br />
to be true across the board now?)<br />
<br />
Any text between a <cmd>startcolor[DarkBlue]</cmd> and <cmd>stopcolor</cmd> should now be assigned to the correct spot colour channel - Pantone 308 CV - on output. More importantly if you include an external figure containing areas of this colour then your text and those parts of the graphic which have the same colour should now appear together in the 'Pantone 308 CV' colour channel on colour separation. <br />
<br />
For example, if your original graphic is an EPS file containing the following lines:<br />
<br />
%%DocumentCustomColors: (PANTONE 298 CV)<br />
%%+ (PANTONE 308 CV)<br />
%%CMYKCustomColor: 0.69 0.07 0 0 (PANTONE 298 CV)<br />
%%+ 1 0.05 0 0.47 (PANTONE 308 CV)<br />
<br />
and you convert this to a PDF using <tt>ps2pdf</tt> for inclusion in your '''ConTeXt''' document your PDF graphic will then contain something like:<br />
<br />
<code><br />
8 0 obj<br />
[/Separation<br />
/PANTONE#20308#20CV<br />
/DeviceCMYK<br />
9 0 R]endobj<br />
10 0 obj<br />
[/Separation<br />
/PANTONE#20298#20CV<br />
/DeviceCMYK<br />
11 0 R]endobj<br />
</code><br />
<br />
Note how the space characters in the colour name are now encoded as '#20', but the colour names are essentially identical between the original EPS graphic, the new PDF graphic and your text.<br />
<br />
A good way of testing colour separation if you don't have access to expensive pre-flight PDF validation tools is to use the following GhostScript command:<br />
<br />
gs \<br />
-dBATCH \<br />
-dNOPAUSE \<br />
-sDEVICE=tiffsep \<br />
-dDOINTERPOLATE \<br />
-dTextAlphaBits=4 \<br />
-dGraphicsAlphaBits=4 \<br />
-sOutputFile=output.tif \<br />
-r120 \<br />
-MaxSeparations=8 \<br />
input.pdf<br />
<br />
This renders a PDF file <tt>input.pdf</tt> as a set of TIFF files:<br />
<br />
output.tif - Composite including CMYK approximations to spot colours<br />
output.tif.Black.tif - K channel<br />
output.tif.Cyan.tif - C channel<br />
output.tif.Magenta.tif - M channel<br />
output.tif.Yellow.tif - Y channel<br />
output.tif.s0.tif - Pantone 308 CV<br />
output.tif.s1.tif - Pantone 298 CV<br />
<br />
=Multitones=<br />
<br />
Hans wrote on the mailinglist on 2004-12-27 about handling of multitone colors:<br />
<br />
Currently it's done by pdftools.rb<br />
<br />
Once pdfxTeX becomes pdfeTeX out of a sudden your beta can do it as well.<br />
<br />
I still need to figure out a way to automatically reverse the graphic, but one of these days you can start using it.<br />
<br />
Actually, multitones for text already work out of the box:<br />
<texcode><br />
\setupcolors[state=start]<br />
<br />
\definecolor [blue] [c=1,m=.38,y=0,k=.64]<br />
\definecolor [yellow] [c=0,m=.28,y=1,k=.06]<br />
<br />
\definespotcolor [blue-100] [blue] [p=1]<br />
\definespotcolor [yellow-100] [yellow] [p=1]<br />
<br />
\definemultitonecolor [combicolor] [blue=.12,yellow=.28] [c=.1,m=.1,y=.3,k=.1]<br />
<br />
\starttext<br />
<br />
\startcolor[blue]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\startcolor[yellow]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\startcolor[combicolor]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\stoptext<br />
</texcode><br />
(The CMYK color spec is the fall back color used on screen; one can preview separations in full Acrobat 7.)<br />
<br />
<br />
<br />
=Colorizing Grayscale Pictures=<br />
<br />
Another sample by Hans (mailing list 2005-11-16) demonstrates a lot of different possibilities:<br />
<br />
<texcode><br />
\setuplayout[header=0pt,footer=0pt,width=middle,height=middle,backspace=1cm,topspace=1cm]<br />
\setupcolors[state=start]<br />
<br />
\startbuffer<br />
\definecolor [blue] [c=1, m=.38, y=0, k=.64]<br />
\definecolor [yellow] [c=0, m=.28, y=1, k=.06]<br />
<br />
\definespotcolor [blue-100] [blue] [p=1]<br />
\definespotcolor [yellow-100] [yellow] [p=1]<br />
<br />
\definemultitonecolor [combicolor] [blue=.12, yellow=.28] [c=.1, m=.1, y=.3, k=.1]<br />
<br />
\definemultitonecolor [combicolor-b] [blue=1] [c=1, m=.38, y=0, k=.64] % force multitone<br />
\definemultitonecolor [combicolor-y] [yellow=1] [c=0, m=.28, y=1, k=.06] % force multitone<br />
<br />
\useexternalfigure[demo-a][mill.png] [object=no, width=.2\textwidth]<br />
\useexternalfigure[demo-b][hacker-bw.jpg][object=no, width=.2\textwidth]<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-a]} {no color}<br />
{\externalfigure[demo-a][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-a][color=combicolor-b]} {spot color}<br />
{\externalfigure[demo-a][color=combicolor-y]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-b]} {no color}<br />
{\externalfigure[demo-b][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-b][color=combicolor-b]} {spot color}<br />
{\externalfigure[demo-b][color=combicolor-y]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-a]} {no color}<br />
{\externalfigure[demo-a][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-a][color=blue-100]} {spot color}<br />
{\externalfigure[demo-a][color=yellow-100]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-b]} {no color}<br />
{\externalfigure[demo-b][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-b][color=blue-100]} {spot color}<br />
{\externalfigure[demo-b][color=yellow-100]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
\stopbuffer<br />
<br />
\getbuffer \typebuffer<br />
<br />
\stoptext<br />
</texcode><br />
<br />
= References =<br />
<br />
See "Color and Background" in the manual</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Color&diff=9803Color2009-06-01T14:44:03Z<p>Nicolas Girard: /* Using Colors */ +In TikZ</p>
<hr />
<div>< [[Visuals]] | [[Graphics]] ><br />
<br />
= Enabling colors =<br />
<br />
In current versions (earlier than 11.05.2009) of ConTeXt mkiv, colors are enabled by default.<br />
<br />
In older versions, colors must be enabled using<br />
<cmd>setupcolors</cmd><tt>[state=start]</tt><br />
<br />
=Defining Colors=<br />
<br />
Using colors with ConTeXt is easy:<br />
<br />
== Choosing a color model ==<br />
<br />
* RGB and CMYK are enabled by default. If you want only RGB or only CMYK color, use <tt>cmyk=no</tt> or <tt>rgb=no</tt>. Multitone colors see below. <br />
* For spot colors, say spot=yes. To eliminate everything except spot colours, leaving a clean file for professional printing, accompany this with rgb=no,cmyk=no. See spot colours below for more details.<br />
* Normally all colors are defined in RGB ''and'' CMYK and get converted if needed.<br />
<br />
== Using predefined colors: <cmd>setupcolor</cmd> ==<br />
<br />
You find lists of predefined colors in the files <tt>colo-xxx.tex</tt>, load them with <cmd>setupcolor</cmd><tt>[xxx]</tt>:<br />
* rgb: some simple colors, loaded by default (with translations for the different interface languages!)<br />
* xwi: X-Windows-colors<br />
* pra: PRAGMA ADE company colors<br />
* ema: Emacs colors<br />
<br />
* Try the magic <cmd>showcolor</cmd><tt>[xxx]</tt>!<br />
<br />
{|<br />
! width="25%"|<br />
! width="10%"|<br />
! width="65%"|<br />
|-<br />
| <texcode><br />
\showcolor[rgb]<br />
</texcode><br />
|<br />
| <context><br />
\setupcolors[state=start]<br />
\showcolor[rgb]<br />
</context><br />
|}<br />
<br />
== Defining colors: <cmd>definecolor</cmd> ==<br />
<br />
<cmd>definecolor</cmd><tt>[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]</tt> (definition for RGB, CMYK and Grey!)<br />
<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\definecolor[blablue][r=.25, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]<br />
<br />
Here's some \color[blablue]{blue text} inbetween!<br />
</texcode><br />
|<br />
| <context><br />
\setupcolors[state=start]<br />
\definecolor[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]<br />
<br />
Here's some \color[blablue]{blue text} inbetween!<br />
</context><br />
|}<br />
<br />
=== Colors with Hexadecimal Numbers ===<br />
<br />
You can also use hexadecimal numers to specify colors. You need to load the '''hex''' color module first:<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\setupcolor[hex]<br />
\definecolor[salmon][h=AB5757]<br />
<br />
Hey, \color[salmon]{look at that!}<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\setupcolor[hex]<br />
\definecolor[salmon][h=AB5757]<br />
<br />
Hey, \color[salmon]{look at that!}<br />
</context><br />
|}<br />
<br />
===Transparent Colors===<br />
<br />
You can define '''transparent''' colors through setting t, e.g. <tt>t=0.5</tt>. Beware, some PDF viewers and printshops can't handle PDF transparences!<br />
<br />
Hans Hagen posted the following sample code for transparent colors on the mailing list on 2005-07-13; the yellow blocks have been added to demonstrate the order in which the blocks are drawn on the page; the first yellow block is behind the transparent red and blue blocks, while the second is in front of them.<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\definecolor [transparentred] [r=1,t=.5,a=1]<br />
\definecolor [transparentblue] [b=1,t=.5,a=1]<br />
\definecolor [solidyellow] [y=1,t=1,a=1]<br />
<br />
\starttext<br />
<br />
\startTEXpage<br />
This is some sample text that goes behind the rectangles\hskip-8cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=transparentred]\hskip-0.67cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=transparentblue]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=solidyellow]\hskip2cm.<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\definecolor [transparentred] [r=1,t=.5,a=1]<br />
\definecolor [transparentblue] [b=1,t=.5,a=1]<br />
\definecolor [solidyellow] [y=1,t=1,a=1]<br />
<br />
\starttext<br />
<br />
\startTEXpage<br />
This is some sample text that goes behind the rectangles\hskip-8cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=transparentred]\hskip-0.67cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=transparentblue]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=solidyellow]\hskip2cm.<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</context><br />
|}<br />
<br />
== Defining color schemes: <cmd>definecolorgroup</cmd> and <cmd>definepalet</cmd>==<br />
<cmd>definecolorgroup</cmd><tt>[name][system][values]</tt><br />
<br />
<cmd>definepalet</cmd><tt>[palettename][colorname1=groupcolor:1, colorname2=groupcolor:2, ...]</tt><br />
<br />
Very interesting feature, to be described later... (see manual)<br />
<br />
=Choosing a color scheme=<br />
<br />
There are three basic strategies to select color combinations for a particular design<br />
<br />
# Create a color scheme by picking several colors found within the objects to be used (photographs, pictures, etc)<br />
# Create colors derived from those found in the objects to be used<br />
# Create a color scheme based on the message to convey / the psychological effects of color<br />
<br />
See for additional help & reference:<br />
* [http://colorschemedesigner.com/ colorschemedesigner.com] - Useful site to help choose a color scheme in rgb color space<br />
* Tina Sutton, Bride M Whelan: The Complete Color Harmony. Rockport Publishers (2004). ISBN 978-1592530311 (recommanded in the mailing list)<br />
<br />
<br />
=Using Colors=<br />
<br />
* Use the color name like <tt>[color=blablue]</tt> in some <tt>\setup...</tt> command.<br />
<br />
== Text ==<br />
<br />
Typeset single text elements with <cmd>color</cmd><tt>[colorname]{nice blue text}</tt>:<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
Three \color[red]{cool} cats<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\starttext<br />
Three \color[red]{cool} cats<br />
\stoptext<br />
</context><br />
|}<br />
<br />
Typeset longer sections with <cmd>startcolor</cmd><tt>[colorname] ...</tt> <cmd>stopcolor</cmd>:<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\starttext<br />
\startcolor[orange]<br />
\input tufte<br />
\stopcolor<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\starttext<br />
\startcolor[orange]<br />
\input tufte<br />
\stopcolor<br />
\stoptext<br />
</context><br />
|}<br />
<br />
== Background of the page ==<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\setupbackgrounds[page][background=color,backgroundcolor=blue]<br />
<br />
\starttext<br />
text<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
<br />
\setupbackgrounds[page][background=color,backgroundcolor=blue]<br />
<br />
\starttext<br />
text<br />
\stoptext<br />
</context><br />
|}<br />
<br />
== Background of cells in tables ==<br />
<br />
See [[Table#Background Colors]]<br />
<br />
== In Metapost ==<br />
<br />
Metapost in MkIV is different from MkII and all labels are typeset<br />
and colored in TeX, if you want a label use<br />
label(textext("\blue RED"),origin) ;<br />
<br />
== In TikZ ==<br />
<br />
<texcode><br />
\usemodule[tikz]<br />
\starttext<br />
\tikz\shade[ball color=red!40!yellow] (0,0) circle (.15cm);<br />
\stoptext<br />
</texcode><br />
<br />
=Spot colours=<br />
<br />
To produce a file ready for a clean PDF separation process at your print house, start with:<br />
<br />
<cmd>setupcolors</cmd><tt>[rgb=no,cmyk=yes,spot=yes,state=start,overprint=yes]</tt><br />
<br />
which will set things up for spot colors with CMYK allowed. The last setting ensures that black overprinting your spot colour tints will not knock out the colour - this is important for some types of commercial printing.<br />
<br />
Then define your basic spot colour. Note that the name cannot contain spaces or numbers (but we come to that later):<br />
<br />
<cmd>definecolor</cmd><tt>[PantoneTwoNineFour][c=1,m=.56,y=0,k=.18]</tt><br />
<br />
Now you can define the tints of this ink that you are actually going to use in your document. Let's say you'll have a 100% for headings:<br />
<br />
<cmd>definespotcolor</cmd><tt>[MyBlue][PantoneTwoNineFour][p=1]</tt><br />
<br />
And then a 20% tint for nice display boxes:<br />
<br />
<cmd>definespotcolor</cmd><tt>[MyBlueTint][PantoneTwoNineFour][p=.2]</tt><br />
<br />
And now you can happily use these named colours:<br />
<br />
<texcode><br />
\starttext<br />
\color[MyBlue]{Interesting}<br />
\stoptext<br />
</texcode><br />
<br />
If you are including graphics made by an external program, you might want to match the colour name used in the graphic with the colour name in your '''ConTeXt''' set-up so that only one colour space is used in the final file. Unfortunately Pantone names and others tend to have spaces and numbers in them, so you need to do a low-level mapping trick from your base name to the name you want embedded in the file:<br />
<br />
<cmd>doregisterspotcolorname</cmd><tt>{PantoneTwoNineFour}{PANTONE 294 CV}</tt><br />
<br />
Now your output file should work beautifully with graphics embedded!<br />
<br />
==Using the 'e' key to \definecolor to specify a spot colour name with spaces==<br />
<br />
As an update to the above description on defining spot colours, you can now use the 'e' key when defining your spot colours in order to specify the precise colour names to be used by your ConTeXt set-up in the output file. For example:<br />
<br />
<texcode><br />
% Define spot colours using 'e=....' to specify colour names to use in output file<br />
\definecolor<br />
[PantoneThreeZeroEight]<br />
[c=1,m=.05,y=0,k=.47,e=PANTONE 308 CV]<br />
<br />
\definecolor<br />
[PantoneTwoNineEight]<br />
[c=.69,m=.07,y=0,k=0,e=PANTONE 298 CV]<br />
<br />
% Define tints of spot colours to be used in document for colouring text<br />
\definespotcolor<br />
[DarkBlue]<br />
[PantoneThreeZeroEight]<br />
[p=1]<br />
<br />
\definespotcolor<br />
[LightBlue]<br />
[PantoneTwoNineEight]<br />
[p=1]<br />
</texcode><br />
<br />
(Tested only on minimal Linux distribution dated 31 Aug 2005 - can others confirm this<br />
to be true across the board now?)<br />
<br />
Any text between a <cmd>startcolor[DarkBlue]</cmd> and <cmd>stopcolor</cmd> should now be assigned to the correct spot colour channel - Pantone 308 CV - on output. More importantly if you include an external figure containing areas of this colour then your text and those parts of the graphic which have the same colour should now appear together in the 'Pantone 308 CV' colour channel on colour separation. <br />
<br />
For example, if your original graphic is an EPS file containing the following lines:<br />
<br />
%%DocumentCustomColors: (PANTONE 298 CV)<br />
%%+ (PANTONE 308 CV)<br />
%%CMYKCustomColor: 0.69 0.07 0 0 (PANTONE 298 CV)<br />
%%+ 1 0.05 0 0.47 (PANTONE 308 CV)<br />
<br />
and you convert this to a PDF using <tt>ps2pdf</tt> for inclusion in your '''ConTeXt''' document your PDF graphic will then contain something like:<br />
<br />
<code><br />
8 0 obj<br />
[/Separation<br />
/PANTONE#20308#20CV<br />
/DeviceCMYK<br />
9 0 R]endobj<br />
10 0 obj<br />
[/Separation<br />
/PANTONE#20298#20CV<br />
/DeviceCMYK<br />
11 0 R]endobj<br />
</code><br />
<br />
Note how the space characters in the colour name are now encoded as '#20', but the colour names are essentially identical between the original EPS graphic, the new PDF graphic and your text.<br />
<br />
A good way of testing colour separation if you don't have access to expensive pre-flight PDF validation tools is to use the following GhostScript command:<br />
<br />
gs \<br />
-dBATCH \<br />
-dNOPAUSE \<br />
-sDEVICE=tiffsep \<br />
-dDOINTERPOLATE \<br />
-dTextAlphaBits=4 \<br />
-dGraphicsAlphaBits=4 \<br />
-sOutputFile=output.tif \<br />
-r120 \<br />
-MaxSeparations=8 \<br />
input.pdf<br />
<br />
This renders a PDF file <tt>input.pdf</tt> as a set of TIFF files:<br />
<br />
output.tif - Composite including CMYK approximations to spot colours<br />
output.tif.Black.tif - K channel<br />
output.tif.Cyan.tif - C channel<br />
output.tif.Magenta.tif - M channel<br />
output.tif.Yellow.tif - Y channel<br />
output.tif.s0.tif - Pantone 308 CV<br />
output.tif.s1.tif - Pantone 298 CV<br />
<br />
=Multitones=<br />
<br />
Hans wrote on the mailinglist on 2004-12-27 about handling of multitone colors:<br />
<br />
Currently it's done by pdftools.rb<br />
<br />
Once pdfxTeX becomes pdfeTeX out of a sudden your beta can do it as well.<br />
<br />
I still need to figure out a way to automatically reverse the graphic, but one of these days you can start using it.<br />
<br />
Actually, multitones for text already work out of the box:<br />
<texcode><br />
\setupcolors[state=start]<br />
<br />
\definecolor [blue] [c=1,m=.38,y=0,k=.64]<br />
\definecolor [yellow] [c=0,m=.28,y=1,k=.06]<br />
<br />
\definespotcolor [blue-100] [blue] [p=1]<br />
\definespotcolor [yellow-100] [yellow] [p=1]<br />
<br />
\definemultitonecolor [combicolor] [blue=.12,yellow=.28] [c=.1,m=.1,y=.3,k=.1]<br />
<br />
\starttext<br />
<br />
\startcolor[blue]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\startcolor[yellow]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\startcolor[combicolor]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\stoptext<br />
</texcode><br />
(The CMYK color spec is the fall back color used on screen; one can preview separations in full Acrobat 7.)<br />
<br />
<br />
<br />
=Colorizing Grayscale Pictures=<br />
<br />
Another sample by Hans (mailing list 2005-11-16) demonstrates a lot of different possibilities:<br />
<br />
<texcode><br />
\setuplayout[header=0pt,footer=0pt,width=middle,height=middle,backspace=1cm,topspace=1cm]<br />
\setupcolors[state=start]<br />
<br />
\startbuffer<br />
\definecolor [blue] [c=1, m=.38, y=0, k=.64]<br />
\definecolor [yellow] [c=0, m=.28, y=1, k=.06]<br />
<br />
\definespotcolor [blue-100] [blue] [p=1]<br />
\definespotcolor [yellow-100] [yellow] [p=1]<br />
<br />
\definemultitonecolor [combicolor] [blue=.12, yellow=.28] [c=.1, m=.1, y=.3, k=.1]<br />
<br />
\definemultitonecolor [combicolor-b] [blue=1] [c=1, m=.38, y=0, k=.64] % force multitone<br />
\definemultitonecolor [combicolor-y] [yellow=1] [c=0, m=.28, y=1, k=.06] % force multitone<br />
<br />
\useexternalfigure[demo-a][mill.png] [object=no, width=.2\textwidth]<br />
\useexternalfigure[demo-b][hacker-bw.jpg][object=no, width=.2\textwidth]<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-a]} {no color}<br />
{\externalfigure[demo-a][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-a][color=combicolor-b]} {spot color}<br />
{\externalfigure[demo-a][color=combicolor-y]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-b]} {no color}<br />
{\externalfigure[demo-b][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-b][color=combicolor-b]} {spot color}<br />
{\externalfigure[demo-b][color=combicolor-y]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-a]} {no color}<br />
{\externalfigure[demo-a][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-a][color=blue-100]} {spot color}<br />
{\externalfigure[demo-a][color=yellow-100]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-b]} {no color}<br />
{\externalfigure[demo-b][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-b][color=blue-100]} {spot color}<br />
{\externalfigure[demo-b][color=yellow-100]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
\stopbuffer<br />
<br />
\getbuffer \typebuffer<br />
<br />
\stoptext<br />
</texcode><br />
<br />
= References =<br />
<br />
See "Color and Background" in the manual</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Color&diff=9802Color2009-06-01T14:40:11Z<p>Nicolas Girard: /* Using Colors */ +In Metapost: added comments from Wolfgang on 2009-03-27 in the mailing list</p>
<hr />
<div>< [[Visuals]] | [[Graphics]] ><br />
<br />
= Enabling colors =<br />
<br />
In current versions (earlier than 11.05.2009) of ConTeXt mkiv, colors are enabled by default.<br />
<br />
In older versions, colors must be enabled using<br />
<cmd>setupcolors</cmd><tt>[state=start]</tt><br />
<br />
=Defining Colors=<br />
<br />
Using colors with ConTeXt is easy:<br />
<br />
== Choosing a color model ==<br />
<br />
* RGB and CMYK are enabled by default. If you want only RGB or only CMYK color, use <tt>cmyk=no</tt> or <tt>rgb=no</tt>. Multitone colors see below. <br />
* For spot colors, say spot=yes. To eliminate everything except spot colours, leaving a clean file for professional printing, accompany this with rgb=no,cmyk=no. See spot colours below for more details.<br />
* Normally all colors are defined in RGB ''and'' CMYK and get converted if needed.<br />
<br />
== Using predefined colors: <cmd>setupcolor</cmd> ==<br />
<br />
You find lists of predefined colors in the files <tt>colo-xxx.tex</tt>, load them with <cmd>setupcolor</cmd><tt>[xxx]</tt>:<br />
* rgb: some simple colors, loaded by default (with translations for the different interface languages!)<br />
* xwi: X-Windows-colors<br />
* pra: PRAGMA ADE company colors<br />
* ema: Emacs colors<br />
<br />
* Try the magic <cmd>showcolor</cmd><tt>[xxx]</tt>!<br />
<br />
{|<br />
! width="25%"|<br />
! width="10%"|<br />
! width="65%"|<br />
|-<br />
| <texcode><br />
\showcolor[rgb]<br />
</texcode><br />
|<br />
| <context><br />
\setupcolors[state=start]<br />
\showcolor[rgb]<br />
</context><br />
|}<br />
<br />
== Defining colors: <cmd>definecolor</cmd> ==<br />
<br />
<cmd>definecolor</cmd><tt>[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]</tt> (definition for RGB, CMYK and Grey!)<br />
<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\definecolor[blablue][r=.25, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]<br />
<br />
Here's some \color[blablue]{blue text} inbetween!<br />
</texcode><br />
|<br />
| <context><br />
\setupcolors[state=start]<br />
\definecolor[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]<br />
<br />
Here's some \color[blablue]{blue text} inbetween!<br />
</context><br />
|}<br />
<br />
=== Colors with Hexadecimal Numbers ===<br />
<br />
You can also use hexadecimal numers to specify colors. You need to load the '''hex''' color module first:<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\setupcolor[hex]<br />
\definecolor[salmon][h=AB5757]<br />
<br />
Hey, \color[salmon]{look at that!}<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\setupcolor[hex]<br />
\definecolor[salmon][h=AB5757]<br />
<br />
Hey, \color[salmon]{look at that!}<br />
</context><br />
|}<br />
<br />
===Transparent Colors===<br />
<br />
You can define '''transparent''' colors through setting t, e.g. <tt>t=0.5</tt>. Beware, some PDF viewers and printshops can't handle PDF transparences!<br />
<br />
Hans Hagen posted the following sample code for transparent colors on the mailing list on 2005-07-13; the yellow blocks have been added to demonstrate the order in which the blocks are drawn on the page; the first yellow block is behind the transparent red and blue blocks, while the second is in front of them.<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\definecolor [transparentred] [r=1,t=.5,a=1]<br />
\definecolor [transparentblue] [b=1,t=.5,a=1]<br />
\definecolor [solidyellow] [y=1,t=1,a=1]<br />
<br />
\starttext<br />
<br />
\startTEXpage<br />
This is some sample text that goes behind the rectangles\hskip-8cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=transparentred]\hskip-0.67cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=transparentblue]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=solidyellow]\hskip2cm.<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\definecolor [transparentred] [r=1,t=.5,a=1]<br />
\definecolor [transparentblue] [b=1,t=.5,a=1]<br />
\definecolor [solidyellow] [y=1,t=1,a=1]<br />
<br />
\starttext<br />
<br />
\startTEXpage<br />
This is some sample text that goes behind the rectangles\hskip-8cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=transparentred]\hskip-0.67cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=transparentblue]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=solidyellow]\hskip2cm.<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</context><br />
|}<br />
<br />
== Defining color schemes: <cmd>definecolorgroup</cmd> and <cmd>definepalet</cmd>==<br />
<cmd>definecolorgroup</cmd><tt>[name][system][values]</tt><br />
<br />
<cmd>definepalet</cmd><tt>[palettename][colorname1=groupcolor:1, colorname2=groupcolor:2, ...]</tt><br />
<br />
Very interesting feature, to be described later... (see manual)<br />
<br />
=Choosing a color scheme=<br />
<br />
There are three basic strategies to select color combinations for a particular design<br />
<br />
# Create a color scheme by picking several colors found within the objects to be used (photographs, pictures, etc)<br />
# Create colors derived from those found in the objects to be used<br />
# Create a color scheme based on the message to convey / the psychological effects of color<br />
<br />
See for additional help & reference:<br />
* [http://colorschemedesigner.com/ colorschemedesigner.com] - Useful site to help choose a color scheme in rgb color space<br />
* Tina Sutton, Bride M Whelan: The Complete Color Harmony. Rockport Publishers (2004). ISBN 978-1592530311 (recommanded in the mailing list)<br />
<br />
<br />
=Using Colors=<br />
<br />
* Use the color name like <tt>[color=blablue]</tt> in some <tt>\setup...</tt> command.<br />
<br />
== Text ==<br />
<br />
Typeset single text elements with <cmd>color</cmd><tt>[colorname]{nice blue text}</tt>:<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
Three \color[red]{cool} cats<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\starttext<br />
Three \color[red]{cool} cats<br />
\stoptext<br />
</context><br />
|}<br />
<br />
Typeset longer sections with <cmd>startcolor</cmd><tt>[colorname] ...</tt> <cmd>stopcolor</cmd>:<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\starttext<br />
\startcolor[orange]<br />
\input tufte<br />
\stopcolor<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\starttext<br />
\startcolor[orange]<br />
\input tufte<br />
\stopcolor<br />
\stoptext<br />
</context><br />
|}<br />
<br />
== Background of the page ==<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\setupbackgrounds[page][background=color,backgroundcolor=blue]<br />
<br />
\starttext<br />
text<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
<br />
\setupbackgrounds[page][background=color,backgroundcolor=blue]<br />
<br />
\starttext<br />
text<br />
\stoptext<br />
</context><br />
|}<br />
<br />
== Background of cells in tables ==<br />
<br />
See [[Table#Background Colors]]<br />
<br />
== In Metapost ==<br />
<br />
Metapost in MkIV is different from MkII and all labels are typeset<br />
and colored in TeX, if you want a label use<br />
label(textext("\blue RED"),origin) ;<br />
<br />
=Spot colours=<br />
<br />
To produce a file ready for a clean PDF separation process at your print house, start with:<br />
<br />
<cmd>setupcolors</cmd><tt>[rgb=no,cmyk=yes,spot=yes,state=start,overprint=yes]</tt><br />
<br />
which will set things up for spot colors with CMYK allowed. The last setting ensures that black overprinting your spot colour tints will not knock out the colour - this is important for some types of commercial printing.<br />
<br />
Then define your basic spot colour. Note that the name cannot contain spaces or numbers (but we come to that later):<br />
<br />
<cmd>definecolor</cmd><tt>[PantoneTwoNineFour][c=1,m=.56,y=0,k=.18]</tt><br />
<br />
Now you can define the tints of this ink that you are actually going to use in your document. Let's say you'll have a 100% for headings:<br />
<br />
<cmd>definespotcolor</cmd><tt>[MyBlue][PantoneTwoNineFour][p=1]</tt><br />
<br />
And then a 20% tint for nice display boxes:<br />
<br />
<cmd>definespotcolor</cmd><tt>[MyBlueTint][PantoneTwoNineFour][p=.2]</tt><br />
<br />
And now you can happily use these named colours:<br />
<br />
<texcode><br />
\starttext<br />
\color[MyBlue]{Interesting}<br />
\stoptext<br />
</texcode><br />
<br />
If you are including graphics made by an external program, you might want to match the colour name used in the graphic with the colour name in your '''ConTeXt''' set-up so that only one colour space is used in the final file. Unfortunately Pantone names and others tend to have spaces and numbers in them, so you need to do a low-level mapping trick from your base name to the name you want embedded in the file:<br />
<br />
<cmd>doregisterspotcolorname</cmd><tt>{PantoneTwoNineFour}{PANTONE 294 CV}</tt><br />
<br />
Now your output file should work beautifully with graphics embedded!<br />
<br />
==Using the 'e' key to \definecolor to specify a spot colour name with spaces==<br />
<br />
As an update to the above description on defining spot colours, you can now use the 'e' key when defining your spot colours in order to specify the precise colour names to be used by your ConTeXt set-up in the output file. For example:<br />
<br />
<texcode><br />
% Define spot colours using 'e=....' to specify colour names to use in output file<br />
\definecolor<br />
[PantoneThreeZeroEight]<br />
[c=1,m=.05,y=0,k=.47,e=PANTONE 308 CV]<br />
<br />
\definecolor<br />
[PantoneTwoNineEight]<br />
[c=.69,m=.07,y=0,k=0,e=PANTONE 298 CV]<br />
<br />
% Define tints of spot colours to be used in document for colouring text<br />
\definespotcolor<br />
[DarkBlue]<br />
[PantoneThreeZeroEight]<br />
[p=1]<br />
<br />
\definespotcolor<br />
[LightBlue]<br />
[PantoneTwoNineEight]<br />
[p=1]<br />
</texcode><br />
<br />
(Tested only on minimal Linux distribution dated 31 Aug 2005 - can others confirm this<br />
to be true across the board now?)<br />
<br />
Any text between a <cmd>startcolor[DarkBlue]</cmd> and <cmd>stopcolor</cmd> should now be assigned to the correct spot colour channel - Pantone 308 CV - on output. More importantly if you include an external figure containing areas of this colour then your text and those parts of the graphic which have the same colour should now appear together in the 'Pantone 308 CV' colour channel on colour separation. <br />
<br />
For example, if your original graphic is an EPS file containing the following lines:<br />
<br />
%%DocumentCustomColors: (PANTONE 298 CV)<br />
%%+ (PANTONE 308 CV)<br />
%%CMYKCustomColor: 0.69 0.07 0 0 (PANTONE 298 CV)<br />
%%+ 1 0.05 0 0.47 (PANTONE 308 CV)<br />
<br />
and you convert this to a PDF using <tt>ps2pdf</tt> for inclusion in your '''ConTeXt''' document your PDF graphic will then contain something like:<br />
<br />
<code><br />
8 0 obj<br />
[/Separation<br />
/PANTONE#20308#20CV<br />
/DeviceCMYK<br />
9 0 R]endobj<br />
10 0 obj<br />
[/Separation<br />
/PANTONE#20298#20CV<br />
/DeviceCMYK<br />
11 0 R]endobj<br />
</code><br />
<br />
Note how the space characters in the colour name are now encoded as '#20', but the colour names are essentially identical between the original EPS graphic, the new PDF graphic and your text.<br />
<br />
A good way of testing colour separation if you don't have access to expensive pre-flight PDF validation tools is to use the following GhostScript command:<br />
<br />
gs \<br />
-dBATCH \<br />
-dNOPAUSE \<br />
-sDEVICE=tiffsep \<br />
-dDOINTERPOLATE \<br />
-dTextAlphaBits=4 \<br />
-dGraphicsAlphaBits=4 \<br />
-sOutputFile=output.tif \<br />
-r120 \<br />
-MaxSeparations=8 \<br />
input.pdf<br />
<br />
This renders a PDF file <tt>input.pdf</tt> as a set of TIFF files:<br />
<br />
output.tif - Composite including CMYK approximations to spot colours<br />
output.tif.Black.tif - K channel<br />
output.tif.Cyan.tif - C channel<br />
output.tif.Magenta.tif - M channel<br />
output.tif.Yellow.tif - Y channel<br />
output.tif.s0.tif - Pantone 308 CV<br />
output.tif.s1.tif - Pantone 298 CV<br />
<br />
=Multitones=<br />
<br />
Hans wrote on the mailinglist on 2004-12-27 about handling of multitone colors:<br />
<br />
Currently it's done by pdftools.rb<br />
<br />
Once pdfxTeX becomes pdfeTeX out of a sudden your beta can do it as well.<br />
<br />
I still need to figure out a way to automatically reverse the graphic, but one of these days you can start using it.<br />
<br />
Actually, multitones for text already work out of the box:<br />
<texcode><br />
\setupcolors[state=start]<br />
<br />
\definecolor [blue] [c=1,m=.38,y=0,k=.64]<br />
\definecolor [yellow] [c=0,m=.28,y=1,k=.06]<br />
<br />
\definespotcolor [blue-100] [blue] [p=1]<br />
\definespotcolor [yellow-100] [yellow] [p=1]<br />
<br />
\definemultitonecolor [combicolor] [blue=.12,yellow=.28] [c=.1,m=.1,y=.3,k=.1]<br />
<br />
\starttext<br />
<br />
\startcolor[blue]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\startcolor[yellow]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\startcolor[combicolor]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\stoptext<br />
</texcode><br />
(The CMYK color spec is the fall back color used on screen; one can preview separations in full Acrobat 7.)<br />
<br />
<br />
<br />
=Colorizing Grayscale Pictures=<br />
<br />
Another sample by Hans (mailing list 2005-11-16) demonstrates a lot of different possibilities:<br />
<br />
<texcode><br />
\setuplayout[header=0pt,footer=0pt,width=middle,height=middle,backspace=1cm,topspace=1cm]<br />
\setupcolors[state=start]<br />
<br />
\startbuffer<br />
\definecolor [blue] [c=1, m=.38, y=0, k=.64]<br />
\definecolor [yellow] [c=0, m=.28, y=1, k=.06]<br />
<br />
\definespotcolor [blue-100] [blue] [p=1]<br />
\definespotcolor [yellow-100] [yellow] [p=1]<br />
<br />
\definemultitonecolor [combicolor] [blue=.12, yellow=.28] [c=.1, m=.1, y=.3, k=.1]<br />
<br />
\definemultitonecolor [combicolor-b] [blue=1] [c=1, m=.38, y=0, k=.64] % force multitone<br />
\definemultitonecolor [combicolor-y] [yellow=1] [c=0, m=.28, y=1, k=.06] % force multitone<br />
<br />
\useexternalfigure[demo-a][mill.png] [object=no, width=.2\textwidth]<br />
\useexternalfigure[demo-b][hacker-bw.jpg][object=no, width=.2\textwidth]<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-a]} {no color}<br />
{\externalfigure[demo-a][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-a][color=combicolor-b]} {spot color}<br />
{\externalfigure[demo-a][color=combicolor-y]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-b]} {no color}<br />
{\externalfigure[demo-b][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-b][color=combicolor-b]} {spot color}<br />
{\externalfigure[demo-b][color=combicolor-y]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-a]} {no color}<br />
{\externalfigure[demo-a][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-a][color=blue-100]} {spot color}<br />
{\externalfigure[demo-a][color=yellow-100]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-b]} {no color}<br />
{\externalfigure[demo-b][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-b][color=blue-100]} {spot color}<br />
{\externalfigure[demo-b][color=yellow-100]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
\stopbuffer<br />
<br />
\getbuffer \typebuffer<br />
<br />
\stoptext<br />
</texcode><br />
<br />
= References =<br />
<br />
See "Color and Background" in the manual</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Color&diff=9801Color2009-06-01T14:35:30Z<p>Nicolas Girard: /* Using Colors */ +Text</p>
<hr />
<div>< [[Visuals]] | [[Graphics]] ><br />
<br />
= Enabling colors =<br />
<br />
In current versions (earlier than 11.05.2009) of ConTeXt mkiv, colors are enabled by default.<br />
<br />
In older versions, colors must be enabled using<br />
<cmd>setupcolors</cmd><tt>[state=start]</tt><br />
<br />
=Defining Colors=<br />
<br />
Using colors with ConTeXt is easy:<br />
<br />
== Choosing a color model ==<br />
<br />
* RGB and CMYK are enabled by default. If you want only RGB or only CMYK color, use <tt>cmyk=no</tt> or <tt>rgb=no</tt>. Multitone colors see below. <br />
* For spot colors, say spot=yes. To eliminate everything except spot colours, leaving a clean file for professional printing, accompany this with rgb=no,cmyk=no. See spot colours below for more details.<br />
* Normally all colors are defined in RGB ''and'' CMYK and get converted if needed.<br />
<br />
== Using predefined colors: <cmd>setupcolor</cmd> ==<br />
<br />
You find lists of predefined colors in the files <tt>colo-xxx.tex</tt>, load them with <cmd>setupcolor</cmd><tt>[xxx]</tt>:<br />
* rgb: some simple colors, loaded by default (with translations for the different interface languages!)<br />
* xwi: X-Windows-colors<br />
* pra: PRAGMA ADE company colors<br />
* ema: Emacs colors<br />
<br />
* Try the magic <cmd>showcolor</cmd><tt>[xxx]</tt>!<br />
<br />
{|<br />
! width="25%"|<br />
! width="10%"|<br />
! width="65%"|<br />
|-<br />
| <texcode><br />
\showcolor[rgb]<br />
</texcode><br />
|<br />
| <context><br />
\setupcolors[state=start]<br />
\showcolor[rgb]<br />
</context><br />
|}<br />
<br />
== Defining colors: <cmd>definecolor</cmd> ==<br />
<br />
<cmd>definecolor</cmd><tt>[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]</tt> (definition for RGB, CMYK and Grey!)<br />
<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\definecolor[blablue][r=.25, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]<br />
<br />
Here's some \color[blablue]{blue text} inbetween!<br />
</texcode><br />
|<br />
| <context><br />
\setupcolors[state=start]<br />
\definecolor[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]<br />
<br />
Here's some \color[blablue]{blue text} inbetween!<br />
</context><br />
|}<br />
<br />
=== Colors with Hexadecimal Numbers ===<br />
<br />
You can also use hexadecimal numers to specify colors. You need to load the '''hex''' color module first:<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\setupcolor[hex]<br />
\definecolor[salmon][h=AB5757]<br />
<br />
Hey, \color[salmon]{look at that!}<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\setupcolor[hex]<br />
\definecolor[salmon][h=AB5757]<br />
<br />
Hey, \color[salmon]{look at that!}<br />
</context><br />
|}<br />
<br />
===Transparent Colors===<br />
<br />
You can define '''transparent''' colors through setting t, e.g. <tt>t=0.5</tt>. Beware, some PDF viewers and printshops can't handle PDF transparences!<br />
<br />
Hans Hagen posted the following sample code for transparent colors on the mailing list on 2005-07-13; the yellow blocks have been added to demonstrate the order in which the blocks are drawn on the page; the first yellow block is behind the transparent red and blue blocks, while the second is in front of them.<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\definecolor [transparentred] [r=1,t=.5,a=1]<br />
\definecolor [transparentblue] [b=1,t=.5,a=1]<br />
\definecolor [solidyellow] [y=1,t=1,a=1]<br />
<br />
\starttext<br />
<br />
\startTEXpage<br />
This is some sample text that goes behind the rectangles\hskip-8cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=transparentred]\hskip-0.67cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=transparentblue]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=solidyellow]\hskip2cm.<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\definecolor [transparentred] [r=1,t=.5,a=1]<br />
\definecolor [transparentblue] [b=1,t=.5,a=1]<br />
\definecolor [solidyellow] [y=1,t=1,a=1]<br />
<br />
\starttext<br />
<br />
\startTEXpage<br />
This is some sample text that goes behind the rectangles\hskip-8cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=transparentred]\hskip-0.67cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=transparentblue]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=solidyellow]\hskip2cm.<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</context><br />
|}<br />
<br />
== Defining color schemes: <cmd>definecolorgroup</cmd> and <cmd>definepalet</cmd>==<br />
<cmd>definecolorgroup</cmd><tt>[name][system][values]</tt><br />
<br />
<cmd>definepalet</cmd><tt>[palettename][colorname1=groupcolor:1, colorname2=groupcolor:2, ...]</tt><br />
<br />
Very interesting feature, to be described later... (see manual)<br />
<br />
=Choosing a color scheme=<br />
<br />
There are three basic strategies to select color combinations for a particular design<br />
<br />
# Create a color scheme by picking several colors found within the objects to be used (photographs, pictures, etc)<br />
# Create colors derived from those found in the objects to be used<br />
# Create a color scheme based on the message to convey / the psychological effects of color<br />
<br />
See for additional help & reference:<br />
* [http://colorschemedesigner.com/ colorschemedesigner.com] - Useful site to help choose a color scheme in rgb color space<br />
* Tina Sutton, Bride M Whelan: The Complete Color Harmony. Rockport Publishers (2004). ISBN 978-1592530311 (recommanded in the mailing list)<br />
<br />
<br />
=Using Colors=<br />
<br />
* Use the color name like <tt>[color=blablue]</tt> in some <tt>\setup...</tt> command.<br />
<br />
== Text ==<br />
<br />
Typeset single text elements with <cmd>color</cmd><tt>[colorname]{nice blue text}</tt>:<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
Three \color[red]{cool} cats<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\starttext<br />
Three \color[red]{cool} cats<br />
\stoptext<br />
</context><br />
|}<br />
<br />
Typeset longer sections with <cmd>startcolor</cmd><tt>[colorname] ...</tt> <cmd>stopcolor</cmd>:<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\starttext<br />
\startcolor[orange]<br />
\input tufte<br />
\stopcolor<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\starttext<br />
\startcolor[orange]<br />
\input tufte<br />
\stopcolor<br />
\stoptext<br />
</context><br />
|}<br />
<br />
== Background of the page ==<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\setupbackgrounds[page][background=color,backgroundcolor=blue]<br />
<br />
\starttext<br />
text<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
<br />
\setupbackgrounds[page][background=color,backgroundcolor=blue]<br />
<br />
\starttext<br />
text<br />
\stoptext<br />
</context><br />
|}<br />
<br />
== Background of cells in tables ==<br />
<br />
See [[Table#Background Colors]]<br />
<br />
=Spot colours=<br />
<br />
To produce a file ready for a clean PDF separation process at your print house, start with:<br />
<br />
<cmd>setupcolors</cmd><tt>[rgb=no,cmyk=yes,spot=yes,state=start,overprint=yes]</tt><br />
<br />
which will set things up for spot colors with CMYK allowed. The last setting ensures that black overprinting your spot colour tints will not knock out the colour - this is important for some types of commercial printing.<br />
<br />
Then define your basic spot colour. Note that the name cannot contain spaces or numbers (but we come to that later):<br />
<br />
<cmd>definecolor</cmd><tt>[PantoneTwoNineFour][c=1,m=.56,y=0,k=.18]</tt><br />
<br />
Now you can define the tints of this ink that you are actually going to use in your document. Let's say you'll have a 100% for headings:<br />
<br />
<cmd>definespotcolor</cmd><tt>[MyBlue][PantoneTwoNineFour][p=1]</tt><br />
<br />
And then a 20% tint for nice display boxes:<br />
<br />
<cmd>definespotcolor</cmd><tt>[MyBlueTint][PantoneTwoNineFour][p=.2]</tt><br />
<br />
And now you can happily use these named colours:<br />
<br />
<texcode><br />
\starttext<br />
\color[MyBlue]{Interesting}<br />
\stoptext<br />
</texcode><br />
<br />
If you are including graphics made by an external program, you might want to match the colour name used in the graphic with the colour name in your '''ConTeXt''' set-up so that only one colour space is used in the final file. Unfortunately Pantone names and others tend to have spaces and numbers in them, so you need to do a low-level mapping trick from your base name to the name you want embedded in the file:<br />
<br />
<cmd>doregisterspotcolorname</cmd><tt>{PantoneTwoNineFour}{PANTONE 294 CV}</tt><br />
<br />
Now your output file should work beautifully with graphics embedded!<br />
<br />
==Using the 'e' key to \definecolor to specify a spot colour name with spaces==<br />
<br />
As an update to the above description on defining spot colours, you can now use the 'e' key when defining your spot colours in order to specify the precise colour names to be used by your ConTeXt set-up in the output file. For example:<br />
<br />
<texcode><br />
% Define spot colours using 'e=....' to specify colour names to use in output file<br />
\definecolor<br />
[PantoneThreeZeroEight]<br />
[c=1,m=.05,y=0,k=.47,e=PANTONE 308 CV]<br />
<br />
\definecolor<br />
[PantoneTwoNineEight]<br />
[c=.69,m=.07,y=0,k=0,e=PANTONE 298 CV]<br />
<br />
% Define tints of spot colours to be used in document for colouring text<br />
\definespotcolor<br />
[DarkBlue]<br />
[PantoneThreeZeroEight]<br />
[p=1]<br />
<br />
\definespotcolor<br />
[LightBlue]<br />
[PantoneTwoNineEight]<br />
[p=1]<br />
</texcode><br />
<br />
(Tested only on minimal Linux distribution dated 31 Aug 2005 - can others confirm this<br />
to be true across the board now?)<br />
<br />
Any text between a <cmd>startcolor[DarkBlue]</cmd> and <cmd>stopcolor</cmd> should now be assigned to the correct spot colour channel - Pantone 308 CV - on output. More importantly if you include an external figure containing areas of this colour then your text and those parts of the graphic which have the same colour should now appear together in the 'Pantone 308 CV' colour channel on colour separation. <br />
<br />
For example, if your original graphic is an EPS file containing the following lines:<br />
<br />
%%DocumentCustomColors: (PANTONE 298 CV)<br />
%%+ (PANTONE 308 CV)<br />
%%CMYKCustomColor: 0.69 0.07 0 0 (PANTONE 298 CV)<br />
%%+ 1 0.05 0 0.47 (PANTONE 308 CV)<br />
<br />
and you convert this to a PDF using <tt>ps2pdf</tt> for inclusion in your '''ConTeXt''' document your PDF graphic will then contain something like:<br />
<br />
<code><br />
8 0 obj<br />
[/Separation<br />
/PANTONE#20308#20CV<br />
/DeviceCMYK<br />
9 0 R]endobj<br />
10 0 obj<br />
[/Separation<br />
/PANTONE#20298#20CV<br />
/DeviceCMYK<br />
11 0 R]endobj<br />
</code><br />
<br />
Note how the space characters in the colour name are now encoded as '#20', but the colour names are essentially identical between the original EPS graphic, the new PDF graphic and your text.<br />
<br />
A good way of testing colour separation if you don't have access to expensive pre-flight PDF validation tools is to use the following GhostScript command:<br />
<br />
gs \<br />
-dBATCH \<br />
-dNOPAUSE \<br />
-sDEVICE=tiffsep \<br />
-dDOINTERPOLATE \<br />
-dTextAlphaBits=4 \<br />
-dGraphicsAlphaBits=4 \<br />
-sOutputFile=output.tif \<br />
-r120 \<br />
-MaxSeparations=8 \<br />
input.pdf<br />
<br />
This renders a PDF file <tt>input.pdf</tt> as a set of TIFF files:<br />
<br />
output.tif - Composite including CMYK approximations to spot colours<br />
output.tif.Black.tif - K channel<br />
output.tif.Cyan.tif - C channel<br />
output.tif.Magenta.tif - M channel<br />
output.tif.Yellow.tif - Y channel<br />
output.tif.s0.tif - Pantone 308 CV<br />
output.tif.s1.tif - Pantone 298 CV<br />
<br />
=Multitones=<br />
<br />
Hans wrote on the mailinglist on 2004-12-27 about handling of multitone colors:<br />
<br />
Currently it's done by pdftools.rb<br />
<br />
Once pdfxTeX becomes pdfeTeX out of a sudden your beta can do it as well.<br />
<br />
I still need to figure out a way to automatically reverse the graphic, but one of these days you can start using it.<br />
<br />
Actually, multitones for text already work out of the box:<br />
<texcode><br />
\setupcolors[state=start]<br />
<br />
\definecolor [blue] [c=1,m=.38,y=0,k=.64]<br />
\definecolor [yellow] [c=0,m=.28,y=1,k=.06]<br />
<br />
\definespotcolor [blue-100] [blue] [p=1]<br />
\definespotcolor [yellow-100] [yellow] [p=1]<br />
<br />
\definemultitonecolor [combicolor] [blue=.12,yellow=.28] [c=.1,m=.1,y=.3,k=.1]<br />
<br />
\starttext<br />
<br />
\startcolor[blue]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\startcolor[yellow]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\startcolor[combicolor]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\stoptext<br />
</texcode><br />
(The CMYK color spec is the fall back color used on screen; one can preview separations in full Acrobat 7.)<br />
<br />
<br />
<br />
=Colorizing Grayscale Pictures=<br />
<br />
Another sample by Hans (mailing list 2005-11-16) demonstrates a lot of different possibilities:<br />
<br />
<texcode><br />
\setuplayout[header=0pt,footer=0pt,width=middle,height=middle,backspace=1cm,topspace=1cm]<br />
\setupcolors[state=start]<br />
<br />
\startbuffer<br />
\definecolor [blue] [c=1, m=.38, y=0, k=.64]<br />
\definecolor [yellow] [c=0, m=.28, y=1, k=.06]<br />
<br />
\definespotcolor [blue-100] [blue] [p=1]<br />
\definespotcolor [yellow-100] [yellow] [p=1]<br />
<br />
\definemultitonecolor [combicolor] [blue=.12, yellow=.28] [c=.1, m=.1, y=.3, k=.1]<br />
<br />
\definemultitonecolor [combicolor-b] [blue=1] [c=1, m=.38, y=0, k=.64] % force multitone<br />
\definemultitonecolor [combicolor-y] [yellow=1] [c=0, m=.28, y=1, k=.06] % force multitone<br />
<br />
\useexternalfigure[demo-a][mill.png] [object=no, width=.2\textwidth]<br />
\useexternalfigure[demo-b][hacker-bw.jpg][object=no, width=.2\textwidth]<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-a]} {no color}<br />
{\externalfigure[demo-a][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-a][color=combicolor-b]} {spot color}<br />
{\externalfigure[demo-a][color=combicolor-y]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-b]} {no color}<br />
{\externalfigure[demo-b][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-b][color=combicolor-b]} {spot color}<br />
{\externalfigure[demo-b][color=combicolor-y]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-a]} {no color}<br />
{\externalfigure[demo-a][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-a][color=blue-100]} {spot color}<br />
{\externalfigure[demo-a][color=yellow-100]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-b]} {no color}<br />
{\externalfigure[demo-b][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-b][color=blue-100]} {spot color}<br />
{\externalfigure[demo-b][color=yellow-100]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
\stopbuffer<br />
<br />
\getbuffer \typebuffer<br />
<br />
\stoptext<br />
</texcode><br />
<br />
= References =<br />
<br />
See "Color and Background" in the manual</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Color&diff=9800Color2009-06-01T14:26:48Z<p>Nicolas Girard: /* Using Colors */ +Background of cells in tables</p>
<hr />
<div>< [[Visuals]] | [[Graphics]] ><br />
<br />
= Enabling colors =<br />
<br />
In current versions (earlier than 11.05.2009) of ConTeXt mkiv, colors are enabled by default.<br />
<br />
In older versions, colors must be enabled using<br />
<cmd>setupcolors</cmd><tt>[state=start]</tt><br />
<br />
=Defining Colors=<br />
<br />
Using colors with ConTeXt is easy:<br />
<br />
== Choosing a color model ==<br />
<br />
* RGB and CMYK are enabled by default. If you want only RGB or only CMYK color, use <tt>cmyk=no</tt> or <tt>rgb=no</tt>. Multitone colors see below. <br />
* For spot colors, say spot=yes. To eliminate everything except spot colours, leaving a clean file for professional printing, accompany this with rgb=no,cmyk=no. See spot colours below for more details.<br />
* Normally all colors are defined in RGB ''and'' CMYK and get converted if needed.<br />
<br />
== Using predefined colors: <cmd>setupcolor</cmd> ==<br />
<br />
You find lists of predefined colors in the files <tt>colo-xxx.tex</tt>, load them with <cmd>setupcolor</cmd><tt>[xxx]</tt>:<br />
* rgb: some simple colors, loaded by default (with translations for the different interface languages!)<br />
* xwi: X-Windows-colors<br />
* pra: PRAGMA ADE company colors<br />
* ema: Emacs colors<br />
<br />
* Try the magic <cmd>showcolor</cmd><tt>[xxx]</tt>!<br />
<br />
{|<br />
! width="25%"|<br />
! width="10%"|<br />
! width="65%"|<br />
|-<br />
| <texcode><br />
\showcolor[rgb]<br />
</texcode><br />
|<br />
| <context><br />
\setupcolors[state=start]<br />
\showcolor[rgb]<br />
</context><br />
|}<br />
<br />
== Defining colors: <cmd>definecolor</cmd> ==<br />
<br />
<cmd>definecolor</cmd><tt>[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]</tt> (definition for RGB, CMYK and Grey!)<br />
<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\definecolor[blablue][r=.25, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]<br />
<br />
Here's some \color[blablue]{blue text} inbetween!<br />
</texcode><br />
|<br />
| <context><br />
\setupcolors[state=start]<br />
\definecolor[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]<br />
<br />
Here's some \color[blablue]{blue text} inbetween!<br />
</context><br />
|}<br />
<br />
=== Colors with Hexadecimal Numbers ===<br />
<br />
You can also use hexadecimal numers to specify colors. You need to load the '''hex''' color module first:<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\setupcolor[hex]<br />
\definecolor[salmon][h=AB5757]<br />
<br />
Hey, \color[salmon]{look at that!}<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\setupcolor[hex]<br />
\definecolor[salmon][h=AB5757]<br />
<br />
Hey, \color[salmon]{look at that!}<br />
</context><br />
|}<br />
<br />
===Transparent Colors===<br />
<br />
You can define '''transparent''' colors through setting t, e.g. <tt>t=0.5</tt>. Beware, some PDF viewers and printshops can't handle PDF transparences!<br />
<br />
Hans Hagen posted the following sample code for transparent colors on the mailing list on 2005-07-13; the yellow blocks have been added to demonstrate the order in which the blocks are drawn on the page; the first yellow block is behind the transparent red and blue blocks, while the second is in front of them.<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\definecolor [transparentred] [r=1,t=.5,a=1]<br />
\definecolor [transparentblue] [b=1,t=.5,a=1]<br />
\definecolor [solidyellow] [y=1,t=1,a=1]<br />
<br />
\starttext<br />
<br />
\startTEXpage<br />
This is some sample text that goes behind the rectangles\hskip-8cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=transparentred]\hskip-0.67cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=transparentblue]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=solidyellow]\hskip2cm.<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\definecolor [transparentred] [r=1,t=.5,a=1]<br />
\definecolor [transparentblue] [b=1,t=.5,a=1]<br />
\definecolor [solidyellow] [y=1,t=1,a=1]<br />
<br />
\starttext<br />
<br />
\startTEXpage<br />
This is some sample text that goes behind the rectangles\hskip-8cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=transparentred]\hskip-0.67cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=transparentblue]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=solidyellow]\hskip2cm.<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</context><br />
|}<br />
<br />
== Defining color schemes: <cmd>definecolorgroup</cmd> and <cmd>definepalet</cmd>==<br />
<cmd>definecolorgroup</cmd><tt>[name][system][values]</tt><br />
<br />
<cmd>definepalet</cmd><tt>[palettename][colorname1=groupcolor:1, colorname2=groupcolor:2, ...]</tt><br />
<br />
Very interesting feature, to be described later... (see manual)<br />
<br />
=Choosing a color scheme=<br />
<br />
There are three basic strategies to select color combinations for a particular design<br />
<br />
# Create a color scheme by picking several colors found within the objects to be used (photographs, pictures, etc)<br />
# Create colors derived from those found in the objects to be used<br />
# Create a color scheme based on the message to convey / the psychological effects of color<br />
<br />
See for additional help & reference:<br />
* [http://colorschemedesigner.com/ colorschemedesigner.com] - Useful site to help choose a color scheme in rgb color space<br />
* Tina Sutton, Bride M Whelan: The Complete Color Harmony. Rockport Publishers (2004). ISBN 978-1592530311 (recommanded in the mailing list)<br />
<br />
<br />
=Using Colors=<br />
<br />
* Use the color name like <tt>[color=blablue]</tt> in some <tt>\setup...</tt> command.<br />
* Typeset single text elements with <cmd>color</cmd><tt>[blablue]{nice blue text}</tt> or longer sections with <cmd>startcolor</cmd><tt>[blablue] ...</tt> <cmd>stopcolor</cmd>.<br />
<br />
== Background of the page ==<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\setupbackgrounds[page][background=color,backgroundcolor=blue]<br />
<br />
\starttext<br />
text<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
<br />
\setupbackgrounds[page][background=color,backgroundcolor=blue]<br />
<br />
\starttext<br />
text<br />
\stoptext<br />
</context><br />
|}<br />
<br />
== Background of cells in tables ==<br />
<br />
See [[Table#Background Colors]]<br />
<br />
=Spot colours=<br />
<br />
To produce a file ready for a clean PDF separation process at your print house, start with:<br />
<br />
<cmd>setupcolors</cmd><tt>[rgb=no,cmyk=yes,spot=yes,state=start,overprint=yes]</tt><br />
<br />
which will set things up for spot colors with CMYK allowed. The last setting ensures that black overprinting your spot colour tints will not knock out the colour - this is important for some types of commercial printing.<br />
<br />
Then define your basic spot colour. Note that the name cannot contain spaces or numbers (but we come to that later):<br />
<br />
<cmd>definecolor</cmd><tt>[PantoneTwoNineFour][c=1,m=.56,y=0,k=.18]</tt><br />
<br />
Now you can define the tints of this ink that you are actually going to use in your document. Let's say you'll have a 100% for headings:<br />
<br />
<cmd>definespotcolor</cmd><tt>[MyBlue][PantoneTwoNineFour][p=1]</tt><br />
<br />
And then a 20% tint for nice display boxes:<br />
<br />
<cmd>definespotcolor</cmd><tt>[MyBlueTint][PantoneTwoNineFour][p=.2]</tt><br />
<br />
And now you can happily use these named colours:<br />
<br />
<texcode><br />
\starttext<br />
\color[MyBlue]{Interesting}<br />
\stoptext<br />
</texcode><br />
<br />
If you are including graphics made by an external program, you might want to match the colour name used in the graphic with the colour name in your '''ConTeXt''' set-up so that only one colour space is used in the final file. Unfortunately Pantone names and others tend to have spaces and numbers in them, so you need to do a low-level mapping trick from your base name to the name you want embedded in the file:<br />
<br />
<cmd>doregisterspotcolorname</cmd><tt>{PantoneTwoNineFour}{PANTONE 294 CV}</tt><br />
<br />
Now your output file should work beautifully with graphics embedded!<br />
<br />
==Using the 'e' key to \definecolor to specify a spot colour name with spaces==<br />
<br />
As an update to the above description on defining spot colours, you can now use the 'e' key when defining your spot colours in order to specify the precise colour names to be used by your ConTeXt set-up in the output file. For example:<br />
<br />
<texcode><br />
% Define spot colours using 'e=....' to specify colour names to use in output file<br />
\definecolor<br />
[PantoneThreeZeroEight]<br />
[c=1,m=.05,y=0,k=.47,e=PANTONE 308 CV]<br />
<br />
\definecolor<br />
[PantoneTwoNineEight]<br />
[c=.69,m=.07,y=0,k=0,e=PANTONE 298 CV]<br />
<br />
% Define tints of spot colours to be used in document for colouring text<br />
\definespotcolor<br />
[DarkBlue]<br />
[PantoneThreeZeroEight]<br />
[p=1]<br />
<br />
\definespotcolor<br />
[LightBlue]<br />
[PantoneTwoNineEight]<br />
[p=1]<br />
</texcode><br />
<br />
(Tested only on minimal Linux distribution dated 31 Aug 2005 - can others confirm this<br />
to be true across the board now?)<br />
<br />
Any text between a <cmd>startcolor[DarkBlue]</cmd> and <cmd>stopcolor</cmd> should now be assigned to the correct spot colour channel - Pantone 308 CV - on output. More importantly if you include an external figure containing areas of this colour then your text and those parts of the graphic which have the same colour should now appear together in the 'Pantone 308 CV' colour channel on colour separation. <br />
<br />
For example, if your original graphic is an EPS file containing the following lines:<br />
<br />
%%DocumentCustomColors: (PANTONE 298 CV)<br />
%%+ (PANTONE 308 CV)<br />
%%CMYKCustomColor: 0.69 0.07 0 0 (PANTONE 298 CV)<br />
%%+ 1 0.05 0 0.47 (PANTONE 308 CV)<br />
<br />
and you convert this to a PDF using <tt>ps2pdf</tt> for inclusion in your '''ConTeXt''' document your PDF graphic will then contain something like:<br />
<br />
<code><br />
8 0 obj<br />
[/Separation<br />
/PANTONE#20308#20CV<br />
/DeviceCMYK<br />
9 0 R]endobj<br />
10 0 obj<br />
[/Separation<br />
/PANTONE#20298#20CV<br />
/DeviceCMYK<br />
11 0 R]endobj<br />
</code><br />
<br />
Note how the space characters in the colour name are now encoded as '#20', but the colour names are essentially identical between the original EPS graphic, the new PDF graphic and your text.<br />
<br />
A good way of testing colour separation if you don't have access to expensive pre-flight PDF validation tools is to use the following GhostScript command:<br />
<br />
gs \<br />
-dBATCH \<br />
-dNOPAUSE \<br />
-sDEVICE=tiffsep \<br />
-dDOINTERPOLATE \<br />
-dTextAlphaBits=4 \<br />
-dGraphicsAlphaBits=4 \<br />
-sOutputFile=output.tif \<br />
-r120 \<br />
-MaxSeparations=8 \<br />
input.pdf<br />
<br />
This renders a PDF file <tt>input.pdf</tt> as a set of TIFF files:<br />
<br />
output.tif - Composite including CMYK approximations to spot colours<br />
output.tif.Black.tif - K channel<br />
output.tif.Cyan.tif - C channel<br />
output.tif.Magenta.tif - M channel<br />
output.tif.Yellow.tif - Y channel<br />
output.tif.s0.tif - Pantone 308 CV<br />
output.tif.s1.tif - Pantone 298 CV<br />
<br />
=Multitones=<br />
<br />
Hans wrote on the mailinglist on 2004-12-27 about handling of multitone colors:<br />
<br />
Currently it's done by pdftools.rb<br />
<br />
Once pdfxTeX becomes pdfeTeX out of a sudden your beta can do it as well.<br />
<br />
I still need to figure out a way to automatically reverse the graphic, but one of these days you can start using it.<br />
<br />
Actually, multitones for text already work out of the box:<br />
<texcode><br />
\setupcolors[state=start]<br />
<br />
\definecolor [blue] [c=1,m=.38,y=0,k=.64]<br />
\definecolor [yellow] [c=0,m=.28,y=1,k=.06]<br />
<br />
\definespotcolor [blue-100] [blue] [p=1]<br />
\definespotcolor [yellow-100] [yellow] [p=1]<br />
<br />
\definemultitonecolor [combicolor] [blue=.12,yellow=.28] [c=.1,m=.1,y=.3,k=.1]<br />
<br />
\starttext<br />
<br />
\startcolor[blue]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\startcolor[yellow]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\startcolor[combicolor]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\stoptext<br />
</texcode><br />
(The CMYK color spec is the fall back color used on screen; one can preview separations in full Acrobat 7.)<br />
<br />
<br />
<br />
=Colorizing Grayscale Pictures=<br />
<br />
Another sample by Hans (mailing list 2005-11-16) demonstrates a lot of different possibilities:<br />
<br />
<texcode><br />
\setuplayout[header=0pt,footer=0pt,width=middle,height=middle,backspace=1cm,topspace=1cm]<br />
\setupcolors[state=start]<br />
<br />
\startbuffer<br />
\definecolor [blue] [c=1, m=.38, y=0, k=.64]<br />
\definecolor [yellow] [c=0, m=.28, y=1, k=.06]<br />
<br />
\definespotcolor [blue-100] [blue] [p=1]<br />
\definespotcolor [yellow-100] [yellow] [p=1]<br />
<br />
\definemultitonecolor [combicolor] [blue=.12, yellow=.28] [c=.1, m=.1, y=.3, k=.1]<br />
<br />
\definemultitonecolor [combicolor-b] [blue=1] [c=1, m=.38, y=0, k=.64] % force multitone<br />
\definemultitonecolor [combicolor-y] [yellow=1] [c=0, m=.28, y=1, k=.06] % force multitone<br />
<br />
\useexternalfigure[demo-a][mill.png] [object=no, width=.2\textwidth]<br />
\useexternalfigure[demo-b][hacker-bw.jpg][object=no, width=.2\textwidth]<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-a]} {no color}<br />
{\externalfigure[demo-a][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-a][color=combicolor-b]} {spot color}<br />
{\externalfigure[demo-a][color=combicolor-y]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-b]} {no color}<br />
{\externalfigure[demo-b][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-b][color=combicolor-b]} {spot color}<br />
{\externalfigure[demo-b][color=combicolor-y]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-a]} {no color}<br />
{\externalfigure[demo-a][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-a][color=blue-100]} {spot color}<br />
{\externalfigure[demo-a][color=yellow-100]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-b]} {no color}<br />
{\externalfigure[demo-b][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-b][color=blue-100]} {spot color}<br />
{\externalfigure[demo-b][color=yellow-100]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
\stopbuffer<br />
<br />
\getbuffer \typebuffer<br />
<br />
\stoptext<br />
</texcode><br />
<br />
= References =<br />
<br />
See "Color and Background" in the manual</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Color&diff=9799Color2009-06-01T14:22:44Z<p>Nicolas Girard: /* Using Colors */ +example: Background of the page</p>
<hr />
<div>< [[Visuals]] | [[Graphics]] ><br />
<br />
= Enabling colors =<br />
<br />
In current versions (earlier than 11.05.2009) of ConTeXt mkiv, colors are enabled by default.<br />
<br />
In older versions, colors must be enabled using<br />
<cmd>setupcolors</cmd><tt>[state=start]</tt><br />
<br />
=Defining Colors=<br />
<br />
Using colors with ConTeXt is easy:<br />
<br />
== Choosing a color model ==<br />
<br />
* RGB and CMYK are enabled by default. If you want only RGB or only CMYK color, use <tt>cmyk=no</tt> or <tt>rgb=no</tt>. Multitone colors see below. <br />
* For spot colors, say spot=yes. To eliminate everything except spot colours, leaving a clean file for professional printing, accompany this with rgb=no,cmyk=no. See spot colours below for more details.<br />
* Normally all colors are defined in RGB ''and'' CMYK and get converted if needed.<br />
<br />
== Using predefined colors: <cmd>setupcolor</cmd> ==<br />
<br />
You find lists of predefined colors in the files <tt>colo-xxx.tex</tt>, load them with <cmd>setupcolor</cmd><tt>[xxx]</tt>:<br />
* rgb: some simple colors, loaded by default (with translations for the different interface languages!)<br />
* xwi: X-Windows-colors<br />
* pra: PRAGMA ADE company colors<br />
* ema: Emacs colors<br />
<br />
* Try the magic <cmd>showcolor</cmd><tt>[xxx]</tt>!<br />
<br />
{|<br />
! width="25%"|<br />
! width="10%"|<br />
! width="65%"|<br />
|-<br />
| <texcode><br />
\showcolor[rgb]<br />
</texcode><br />
|<br />
| <context><br />
\setupcolors[state=start]<br />
\showcolor[rgb]<br />
</context><br />
|}<br />
<br />
== Defining colors: <cmd>definecolor</cmd> ==<br />
<br />
<cmd>definecolor</cmd><tt>[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]</tt> (definition for RGB, CMYK and Grey!)<br />
<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\definecolor[blablue][r=.25, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]<br />
<br />
Here's some \color[blablue]{blue text} inbetween!<br />
</texcode><br />
|<br />
| <context><br />
\setupcolors[state=start]<br />
\definecolor[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]<br />
<br />
Here's some \color[blablue]{blue text} inbetween!<br />
</context><br />
|}<br />
<br />
=== Colors with Hexadecimal Numbers ===<br />
<br />
You can also use hexadecimal numers to specify colors. You need to load the '''hex''' color module first:<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\setupcolor[hex]<br />
\definecolor[salmon][h=AB5757]<br />
<br />
Hey, \color[salmon]{look at that!}<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\setupcolor[hex]<br />
\definecolor[salmon][h=AB5757]<br />
<br />
Hey, \color[salmon]{look at that!}<br />
</context><br />
|}<br />
<br />
===Transparent Colors===<br />
<br />
You can define '''transparent''' colors through setting t, e.g. <tt>t=0.5</tt>. Beware, some PDF viewers and printshops can't handle PDF transparences!<br />
<br />
Hans Hagen posted the following sample code for transparent colors on the mailing list on 2005-07-13; the yellow blocks have been added to demonstrate the order in which the blocks are drawn on the page; the first yellow block is behind the transparent red and blue blocks, while the second is in front of them.<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\definecolor [transparentred] [r=1,t=.5,a=1]<br />
\definecolor [transparentblue] [b=1,t=.5,a=1]<br />
\definecolor [solidyellow] [y=1,t=1,a=1]<br />
<br />
\starttext<br />
<br />
\startTEXpage<br />
This is some sample text that goes behind the rectangles\hskip-8cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=transparentred]\hskip-0.67cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=transparentblue]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=solidyellow]\hskip2cm.<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\definecolor [transparentred] [r=1,t=.5,a=1]<br />
\definecolor [transparentblue] [b=1,t=.5,a=1]<br />
\definecolor [solidyellow] [y=1,t=1,a=1]<br />
<br />
\starttext<br />
<br />
\startTEXpage<br />
This is some sample text that goes behind the rectangles\hskip-8cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=transparentred]\hskip-0.67cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=transparentblue]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=solidyellow]\hskip2cm.<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</context><br />
|}<br />
<br />
== Defining color schemes: <cmd>definecolorgroup</cmd> and <cmd>definepalet</cmd>==<br />
<cmd>definecolorgroup</cmd><tt>[name][system][values]</tt><br />
<br />
<cmd>definepalet</cmd><tt>[palettename][colorname1=groupcolor:1, colorname2=groupcolor:2, ...]</tt><br />
<br />
Very interesting feature, to be described later... (see manual)<br />
<br />
=Choosing a color scheme=<br />
<br />
There are three basic strategies to select color combinations for a particular design<br />
<br />
# Create a color scheme by picking several colors found within the objects to be used (photographs, pictures, etc)<br />
# Create colors derived from those found in the objects to be used<br />
# Create a color scheme based on the message to convey / the psychological effects of color<br />
<br />
See for additional help & reference:<br />
* [http://colorschemedesigner.com/ colorschemedesigner.com] - Useful site to help choose a color scheme in rgb color space<br />
* Tina Sutton, Bride M Whelan: The Complete Color Harmony. Rockport Publishers (2004). ISBN 978-1592530311 (recommanded in the mailing list)<br />
<br />
<br />
=Using Colors=<br />
<br />
* Use the color name like <tt>[color=blablue]</tt> in some <tt>\setup...</tt> command.<br />
* Typeset single text elements with <cmd>color</cmd><tt>[blablue]{nice blue text}</tt> or longer sections with <cmd>startcolor</cmd><tt>[blablue] ...</tt> <cmd>stopcolor</cmd>.<br />
<br />
== Background of the page ==<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\setupbackgrounds[page][background=color,backgroundcolor=blue]<br />
<br />
\starttext<br />
text<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
<br />
\setupbackgrounds[page][background=color,backgroundcolor=blue]<br />
<br />
\starttext<br />
text<br />
\stoptext<br />
</context><br />
|}<br />
<br />
=Spot colours=<br />
<br />
To produce a file ready for a clean PDF separation process at your print house, start with:<br />
<br />
<cmd>setupcolors</cmd><tt>[rgb=no,cmyk=yes,spot=yes,state=start,overprint=yes]</tt><br />
<br />
which will set things up for spot colors with CMYK allowed. The last setting ensures that black overprinting your spot colour tints will not knock out the colour - this is important for some types of commercial printing.<br />
<br />
Then define your basic spot colour. Note that the name cannot contain spaces or numbers (but we come to that later):<br />
<br />
<cmd>definecolor</cmd><tt>[PantoneTwoNineFour][c=1,m=.56,y=0,k=.18]</tt><br />
<br />
Now you can define the tints of this ink that you are actually going to use in your document. Let's say you'll have a 100% for headings:<br />
<br />
<cmd>definespotcolor</cmd><tt>[MyBlue][PantoneTwoNineFour][p=1]</tt><br />
<br />
And then a 20% tint for nice display boxes:<br />
<br />
<cmd>definespotcolor</cmd><tt>[MyBlueTint][PantoneTwoNineFour][p=.2]</tt><br />
<br />
And now you can happily use these named colours:<br />
<br />
<texcode><br />
\starttext<br />
\color[MyBlue]{Interesting}<br />
\stoptext<br />
</texcode><br />
<br />
If you are including graphics made by an external program, you might want to match the colour name used in the graphic with the colour name in your '''ConTeXt''' set-up so that only one colour space is used in the final file. Unfortunately Pantone names and others tend to have spaces and numbers in them, so you need to do a low-level mapping trick from your base name to the name you want embedded in the file:<br />
<br />
<cmd>doregisterspotcolorname</cmd><tt>{PantoneTwoNineFour}{PANTONE 294 CV}</tt><br />
<br />
Now your output file should work beautifully with graphics embedded!<br />
<br />
==Using the 'e' key to \definecolor to specify a spot colour name with spaces==<br />
<br />
As an update to the above description on defining spot colours, you can now use the 'e' key when defining your spot colours in order to specify the precise colour names to be used by your ConTeXt set-up in the output file. For example:<br />
<br />
<texcode><br />
% Define spot colours using 'e=....' to specify colour names to use in output file<br />
\definecolor<br />
[PantoneThreeZeroEight]<br />
[c=1,m=.05,y=0,k=.47,e=PANTONE 308 CV]<br />
<br />
\definecolor<br />
[PantoneTwoNineEight]<br />
[c=.69,m=.07,y=0,k=0,e=PANTONE 298 CV]<br />
<br />
% Define tints of spot colours to be used in document for colouring text<br />
\definespotcolor<br />
[DarkBlue]<br />
[PantoneThreeZeroEight]<br />
[p=1]<br />
<br />
\definespotcolor<br />
[LightBlue]<br />
[PantoneTwoNineEight]<br />
[p=1]<br />
</texcode><br />
<br />
(Tested only on minimal Linux distribution dated 31 Aug 2005 - can others confirm this<br />
to be true across the board now?)<br />
<br />
Any text between a <cmd>startcolor[DarkBlue]</cmd> and <cmd>stopcolor</cmd> should now be assigned to the correct spot colour channel - Pantone 308 CV - on output. More importantly if you include an external figure containing areas of this colour then your text and those parts of the graphic which have the same colour should now appear together in the 'Pantone 308 CV' colour channel on colour separation. <br />
<br />
For example, if your original graphic is an EPS file containing the following lines:<br />
<br />
%%DocumentCustomColors: (PANTONE 298 CV)<br />
%%+ (PANTONE 308 CV)<br />
%%CMYKCustomColor: 0.69 0.07 0 0 (PANTONE 298 CV)<br />
%%+ 1 0.05 0 0.47 (PANTONE 308 CV)<br />
<br />
and you convert this to a PDF using <tt>ps2pdf</tt> for inclusion in your '''ConTeXt''' document your PDF graphic will then contain something like:<br />
<br />
<code><br />
8 0 obj<br />
[/Separation<br />
/PANTONE#20308#20CV<br />
/DeviceCMYK<br />
9 0 R]endobj<br />
10 0 obj<br />
[/Separation<br />
/PANTONE#20298#20CV<br />
/DeviceCMYK<br />
11 0 R]endobj<br />
</code><br />
<br />
Note how the space characters in the colour name are now encoded as '#20', but the colour names are essentially identical between the original EPS graphic, the new PDF graphic and your text.<br />
<br />
A good way of testing colour separation if you don't have access to expensive pre-flight PDF validation tools is to use the following GhostScript command:<br />
<br />
gs \<br />
-dBATCH \<br />
-dNOPAUSE \<br />
-sDEVICE=tiffsep \<br />
-dDOINTERPOLATE \<br />
-dTextAlphaBits=4 \<br />
-dGraphicsAlphaBits=4 \<br />
-sOutputFile=output.tif \<br />
-r120 \<br />
-MaxSeparations=8 \<br />
input.pdf<br />
<br />
This renders a PDF file <tt>input.pdf</tt> as a set of TIFF files:<br />
<br />
output.tif - Composite including CMYK approximations to spot colours<br />
output.tif.Black.tif - K channel<br />
output.tif.Cyan.tif - C channel<br />
output.tif.Magenta.tif - M channel<br />
output.tif.Yellow.tif - Y channel<br />
output.tif.s0.tif - Pantone 308 CV<br />
output.tif.s1.tif - Pantone 298 CV<br />
<br />
=Multitones=<br />
<br />
Hans wrote on the mailinglist on 2004-12-27 about handling of multitone colors:<br />
<br />
Currently it's done by pdftools.rb<br />
<br />
Once pdfxTeX becomes pdfeTeX out of a sudden your beta can do it as well.<br />
<br />
I still need to figure out a way to automatically reverse the graphic, but one of these days you can start using it.<br />
<br />
Actually, multitones for text already work out of the box:<br />
<texcode><br />
\setupcolors[state=start]<br />
<br />
\definecolor [blue] [c=1,m=.38,y=0,k=.64]<br />
\definecolor [yellow] [c=0,m=.28,y=1,k=.06]<br />
<br />
\definespotcolor [blue-100] [blue] [p=1]<br />
\definespotcolor [yellow-100] [yellow] [p=1]<br />
<br />
\definemultitonecolor [combicolor] [blue=.12,yellow=.28] [c=.1,m=.1,y=.3,k=.1]<br />
<br />
\starttext<br />
<br />
\startcolor[blue]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\startcolor[yellow]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\startcolor[combicolor]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\stoptext<br />
</texcode><br />
(The CMYK color spec is the fall back color used on screen; one can preview separations in full Acrobat 7.)<br />
<br />
<br />
<br />
=Colorizing Grayscale Pictures=<br />
<br />
Another sample by Hans (mailing list 2005-11-16) demonstrates a lot of different possibilities:<br />
<br />
<texcode><br />
\setuplayout[header=0pt,footer=0pt,width=middle,height=middle,backspace=1cm,topspace=1cm]<br />
\setupcolors[state=start]<br />
<br />
\startbuffer<br />
\definecolor [blue] [c=1, m=.38, y=0, k=.64]<br />
\definecolor [yellow] [c=0, m=.28, y=1, k=.06]<br />
<br />
\definespotcolor [blue-100] [blue] [p=1]<br />
\definespotcolor [yellow-100] [yellow] [p=1]<br />
<br />
\definemultitonecolor [combicolor] [blue=.12, yellow=.28] [c=.1, m=.1, y=.3, k=.1]<br />
<br />
\definemultitonecolor [combicolor-b] [blue=1] [c=1, m=.38, y=0, k=.64] % force multitone<br />
\definemultitonecolor [combicolor-y] [yellow=1] [c=0, m=.28, y=1, k=.06] % force multitone<br />
<br />
\useexternalfigure[demo-a][mill.png] [object=no, width=.2\textwidth]<br />
\useexternalfigure[demo-b][hacker-bw.jpg][object=no, width=.2\textwidth]<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-a]} {no color}<br />
{\externalfigure[demo-a][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-a][color=combicolor-b]} {spot color}<br />
{\externalfigure[demo-a][color=combicolor-y]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-b]} {no color}<br />
{\externalfigure[demo-b][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-b][color=combicolor-b]} {spot color}<br />
{\externalfigure[demo-b][color=combicolor-y]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-a]} {no color}<br />
{\externalfigure[demo-a][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-a][color=blue-100]} {spot color}<br />
{\externalfigure[demo-a][color=yellow-100]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-b]} {no color}<br />
{\externalfigure[demo-b][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-b][color=blue-100]} {spot color}<br />
{\externalfigure[demo-b][color=yellow-100]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
\stopbuffer<br />
<br />
\getbuffer \typebuffer<br />
<br />
\stoptext<br />
</texcode><br />
<br />
= References =<br />
<br />
See "Color and Background" in the manual</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Color&diff=9798Color2009-06-01T14:10:20Z<p>Nicolas Girard: +Section: Choosing a color scheme</p>
<hr />
<div>< [[Visuals]] | [[Graphics]] ><br />
<br />
= Enabling colors =<br />
<br />
In current versions (earlier than 11.05.2009) of ConTeXt mkiv, colors are enabled by default.<br />
<br />
In older versions, colors must be enabled using<br />
<cmd>setupcolors</cmd><tt>[state=start]</tt><br />
<br />
=Defining Colors=<br />
<br />
Using colors with ConTeXt is easy:<br />
<br />
== Choosing a color model ==<br />
<br />
* RGB and CMYK are enabled by default. If you want only RGB or only CMYK color, use <tt>cmyk=no</tt> or <tt>rgb=no</tt>. Multitone colors see below. <br />
* For spot colors, say spot=yes. To eliminate everything except spot colours, leaving a clean file for professional printing, accompany this with rgb=no,cmyk=no. See spot colours below for more details.<br />
* Normally all colors are defined in RGB ''and'' CMYK and get converted if needed.<br />
<br />
== Using predefined colors: <cmd>setupcolor</cmd> ==<br />
<br />
You find lists of predefined colors in the files <tt>colo-xxx.tex</tt>, load them with <cmd>setupcolor</cmd><tt>[xxx]</tt>:<br />
* rgb: some simple colors, loaded by default (with translations for the different interface languages!)<br />
* xwi: X-Windows-colors<br />
* pra: PRAGMA ADE company colors<br />
* ema: Emacs colors<br />
<br />
* Try the magic <cmd>showcolor</cmd><tt>[xxx]</tt>!<br />
<br />
{|<br />
! width="25%"|<br />
! width="10%"|<br />
! width="65%"|<br />
|-<br />
| <texcode><br />
\showcolor[rgb]<br />
</texcode><br />
|<br />
| <context><br />
\setupcolors[state=start]<br />
\showcolor[rgb]<br />
</context><br />
|}<br />
<br />
== Defining colors: <cmd>definecolor</cmd> ==<br />
<br />
<cmd>definecolor</cmd><tt>[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]</tt> (definition for RGB, CMYK and Grey!)<br />
<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\definecolor[blablue][r=.25, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]<br />
<br />
Here's some \color[blablue]{blue text} inbetween!<br />
</texcode><br />
|<br />
| <context><br />
\setupcolors[state=start]<br />
\definecolor[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]<br />
<br />
Here's some \color[blablue]{blue text} inbetween!<br />
</context><br />
|}<br />
<br />
=== Colors with Hexadecimal Numbers ===<br />
<br />
You can also use hexadecimal numers to specify colors. You need to load the '''hex''' color module first:<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\setupcolor[hex]<br />
\definecolor[salmon][h=AB5757]<br />
<br />
Hey, \color[salmon]{look at that!}<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\setupcolor[hex]<br />
\definecolor[salmon][h=AB5757]<br />
<br />
Hey, \color[salmon]{look at that!}<br />
</context><br />
|}<br />
<br />
===Transparent Colors===<br />
<br />
You can define '''transparent''' colors through setting t, e.g. <tt>t=0.5</tt>. Beware, some PDF viewers and printshops can't handle PDF transparences!<br />
<br />
Hans Hagen posted the following sample code for transparent colors on the mailing list on 2005-07-13; the yellow blocks have been added to demonstrate the order in which the blocks are drawn on the page; the first yellow block is behind the transparent red and blue blocks, while the second is in front of them.<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\definecolor [transparentred] [r=1,t=.5,a=1]<br />
\definecolor [transparentblue] [b=1,t=.5,a=1]<br />
\definecolor [solidyellow] [y=1,t=1,a=1]<br />
<br />
\starttext<br />
<br />
\startTEXpage<br />
This is some sample text that goes behind the rectangles\hskip-8cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=transparentred]\hskip-0.67cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=transparentblue]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=solidyellow]\hskip2cm.<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\definecolor [transparentred] [r=1,t=.5,a=1]<br />
\definecolor [transparentblue] [b=1,t=.5,a=1]<br />
\definecolor [solidyellow] [y=1,t=1,a=1]<br />
<br />
\starttext<br />
<br />
\startTEXpage<br />
This is some sample text that goes behind the rectangles\hskip-8cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=transparentred]\hskip-0.67cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=transparentblue]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=solidyellow]\hskip2cm.<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</context><br />
|}<br />
<br />
== Defining color schemes: <cmd>definecolorgroup</cmd> and <cmd>definepalet</cmd>==<br />
<cmd>definecolorgroup</cmd><tt>[name][system][values]</tt><br />
<br />
<cmd>definepalet</cmd><tt>[palettename][colorname1=groupcolor:1, colorname2=groupcolor:2, ...]</tt><br />
<br />
Very interesting feature, to be described later... (see manual)<br />
<br />
=Choosing a color scheme=<br />
<br />
There are three basic strategies to select color combinations for a particular design<br />
<br />
# Create a color scheme by picking several colors found within the objects to be used (photographs, pictures, etc)<br />
# Create colors derived from those found in the objects to be used<br />
# Create a color scheme based on the message to convey / the psychological effects of color<br />
<br />
See for additional help & reference:<br />
* [http://colorschemedesigner.com/ colorschemedesigner.com] - Useful site to help choose a color scheme in rgb color space<br />
* Tina Sutton, Bride M Whelan: The Complete Color Harmony. Rockport Publishers (2004). ISBN 978-1592530311 (recommanded in the mailing list)<br />
<br />
<br />
=Using Colors=<br />
<br />
* Use the color name like <tt>[color=blablue]</tt> in some <tt>\setup...</tt> command.<br />
* Typeset single text elements with <cmd>color</cmd><tt>[blablue]{nice blue text}</tt> or longer sections with <cmd>startcolor</cmd><tt>[blablue] ...</tt> <cmd>stopcolor</cmd>.<br />
<br />
=Spot colours=<br />
<br />
To produce a file ready for a clean PDF separation process at your print house, start with:<br />
<br />
<cmd>setupcolors</cmd><tt>[rgb=no,cmyk=yes,spot=yes,state=start,overprint=yes]</tt><br />
<br />
which will set things up for spot colors with CMYK allowed. The last setting ensures that black overprinting your spot colour tints will not knock out the colour - this is important for some types of commercial printing.<br />
<br />
Then define your basic spot colour. Note that the name cannot contain spaces or numbers (but we come to that later):<br />
<br />
<cmd>definecolor</cmd><tt>[PantoneTwoNineFour][c=1,m=.56,y=0,k=.18]</tt><br />
<br />
Now you can define the tints of this ink that you are actually going to use in your document. Let's say you'll have a 100% for headings:<br />
<br />
<cmd>definespotcolor</cmd><tt>[MyBlue][PantoneTwoNineFour][p=1]</tt><br />
<br />
And then a 20% tint for nice display boxes:<br />
<br />
<cmd>definespotcolor</cmd><tt>[MyBlueTint][PantoneTwoNineFour][p=.2]</tt><br />
<br />
And now you can happily use these named colours:<br />
<br />
<texcode><br />
\starttext<br />
\color[MyBlue]{Interesting}<br />
\stoptext<br />
</texcode><br />
<br />
If you are including graphics made by an external program, you might want to match the colour name used in the graphic with the colour name in your '''ConTeXt''' set-up so that only one colour space is used in the final file. Unfortunately Pantone names and others tend to have spaces and numbers in them, so you need to do a low-level mapping trick from your base name to the name you want embedded in the file:<br />
<br />
<cmd>doregisterspotcolorname</cmd><tt>{PantoneTwoNineFour}{PANTONE 294 CV}</tt><br />
<br />
Now your output file should work beautifully with graphics embedded!<br />
<br />
==Using the 'e' key to \definecolor to specify a spot colour name with spaces==<br />
<br />
As an update to the above description on defining spot colours, you can now use the 'e' key when defining your spot colours in order to specify the precise colour names to be used by your ConTeXt set-up in the output file. For example:<br />
<br />
<texcode><br />
% Define spot colours using 'e=....' to specify colour names to use in output file<br />
\definecolor<br />
[PantoneThreeZeroEight]<br />
[c=1,m=.05,y=0,k=.47,e=PANTONE 308 CV]<br />
<br />
\definecolor<br />
[PantoneTwoNineEight]<br />
[c=.69,m=.07,y=0,k=0,e=PANTONE 298 CV]<br />
<br />
% Define tints of spot colours to be used in document for colouring text<br />
\definespotcolor<br />
[DarkBlue]<br />
[PantoneThreeZeroEight]<br />
[p=1]<br />
<br />
\definespotcolor<br />
[LightBlue]<br />
[PantoneTwoNineEight]<br />
[p=1]<br />
</texcode><br />
<br />
(Tested only on minimal Linux distribution dated 31 Aug 2005 - can others confirm this<br />
to be true across the board now?)<br />
<br />
Any text between a <cmd>startcolor[DarkBlue]</cmd> and <cmd>stopcolor</cmd> should now be assigned to the correct spot colour channel - Pantone 308 CV - on output. More importantly if you include an external figure containing areas of this colour then your text and those parts of the graphic which have the same colour should now appear together in the 'Pantone 308 CV' colour channel on colour separation. <br />
<br />
For example, if your original graphic is an EPS file containing the following lines:<br />
<br />
%%DocumentCustomColors: (PANTONE 298 CV)<br />
%%+ (PANTONE 308 CV)<br />
%%CMYKCustomColor: 0.69 0.07 0 0 (PANTONE 298 CV)<br />
%%+ 1 0.05 0 0.47 (PANTONE 308 CV)<br />
<br />
and you convert this to a PDF using <tt>ps2pdf</tt> for inclusion in your '''ConTeXt''' document your PDF graphic will then contain something like:<br />
<br />
<code><br />
8 0 obj<br />
[/Separation<br />
/PANTONE#20308#20CV<br />
/DeviceCMYK<br />
9 0 R]endobj<br />
10 0 obj<br />
[/Separation<br />
/PANTONE#20298#20CV<br />
/DeviceCMYK<br />
11 0 R]endobj<br />
</code><br />
<br />
Note how the space characters in the colour name are now encoded as '#20', but the colour names are essentially identical between the original EPS graphic, the new PDF graphic and your text.<br />
<br />
A good way of testing colour separation if you don't have access to expensive pre-flight PDF validation tools is to use the following GhostScript command:<br />
<br />
gs \<br />
-dBATCH \<br />
-dNOPAUSE \<br />
-sDEVICE=tiffsep \<br />
-dDOINTERPOLATE \<br />
-dTextAlphaBits=4 \<br />
-dGraphicsAlphaBits=4 \<br />
-sOutputFile=output.tif \<br />
-r120 \<br />
-MaxSeparations=8 \<br />
input.pdf<br />
<br />
This renders a PDF file <tt>input.pdf</tt> as a set of TIFF files:<br />
<br />
output.tif - Composite including CMYK approximations to spot colours<br />
output.tif.Black.tif - K channel<br />
output.tif.Cyan.tif - C channel<br />
output.tif.Magenta.tif - M channel<br />
output.tif.Yellow.tif - Y channel<br />
output.tif.s0.tif - Pantone 308 CV<br />
output.tif.s1.tif - Pantone 298 CV<br />
<br />
=Multitones=<br />
<br />
Hans wrote on the mailinglist on 2004-12-27 about handling of multitone colors:<br />
<br />
Currently it's done by pdftools.rb<br />
<br />
Once pdfxTeX becomes pdfeTeX out of a sudden your beta can do it as well.<br />
<br />
I still need to figure out a way to automatically reverse the graphic, but one of these days you can start using it.<br />
<br />
Actually, multitones for text already work out of the box:<br />
<texcode><br />
\setupcolors[state=start]<br />
<br />
\definecolor [blue] [c=1,m=.38,y=0,k=.64]<br />
\definecolor [yellow] [c=0,m=.28,y=1,k=.06]<br />
<br />
\definespotcolor [blue-100] [blue] [p=1]<br />
\definespotcolor [yellow-100] [yellow] [p=1]<br />
<br />
\definemultitonecolor [combicolor] [blue=.12,yellow=.28] [c=.1,m=.1,y=.3,k=.1]<br />
<br />
\starttext<br />
<br />
\startcolor[blue]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\startcolor[yellow]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\startcolor[combicolor]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\stoptext<br />
</texcode><br />
(The CMYK color spec is the fall back color used on screen; one can preview separations in full Acrobat 7.)<br />
<br />
<br />
<br />
=Colorizing Grayscale Pictures=<br />
<br />
Another sample by Hans (mailing list 2005-11-16) demonstrates a lot of different possibilities:<br />
<br />
<texcode><br />
\setuplayout[header=0pt,footer=0pt,width=middle,height=middle,backspace=1cm,topspace=1cm]<br />
\setupcolors[state=start]<br />
<br />
\startbuffer<br />
\definecolor [blue] [c=1, m=.38, y=0, k=.64]<br />
\definecolor [yellow] [c=0, m=.28, y=1, k=.06]<br />
<br />
\definespotcolor [blue-100] [blue] [p=1]<br />
\definespotcolor [yellow-100] [yellow] [p=1]<br />
<br />
\definemultitonecolor [combicolor] [blue=.12, yellow=.28] [c=.1, m=.1, y=.3, k=.1]<br />
<br />
\definemultitonecolor [combicolor-b] [blue=1] [c=1, m=.38, y=0, k=.64] % force multitone<br />
\definemultitonecolor [combicolor-y] [yellow=1] [c=0, m=.28, y=1, k=.06] % force multitone<br />
<br />
\useexternalfigure[demo-a][mill.png] [object=no, width=.2\textwidth]<br />
\useexternalfigure[demo-b][hacker-bw.jpg][object=no, width=.2\textwidth]<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-a]} {no color}<br />
{\externalfigure[demo-a][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-a][color=combicolor-b]} {spot color}<br />
{\externalfigure[demo-a][color=combicolor-y]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-b]} {no color}<br />
{\externalfigure[demo-b][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-b][color=combicolor-b]} {spot color}<br />
{\externalfigure[demo-b][color=combicolor-y]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-a]} {no color}<br />
{\externalfigure[demo-a][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-a][color=blue-100]} {spot color}<br />
{\externalfigure[demo-a][color=yellow-100]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-b]} {no color}<br />
{\externalfigure[demo-b][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-b][color=blue-100]} {spot color}<br />
{\externalfigure[demo-b][color=yellow-100]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
\stopbuffer<br />
<br />
\getbuffer \typebuffer<br />
<br />
\stoptext<br />
</texcode><br />
<br />
= References =<br />
<br />
See "Color and Background" in the manual</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Color&diff=9797Color2009-06-01T13:34:45Z<p>Nicolas Girard: Reorganized contents</p>
<hr />
<div>< [[Visuals]] | [[Graphics]] ><br />
<br />
= Enabling colors =<br />
<br />
In current versions (earlier than 11.05.2009) of ConTeXt mkiv, colors are enabled by default.<br />
<br />
In older versions, colors must be enabled using<br />
<cmd>setupcolors</cmd><tt>[state=start]</tt><br />
<br />
=Defining Colors=<br />
<br />
Using colors with ConTeXt is easy:<br />
<br />
== Choosing a color model ==<br />
<br />
* RGB and CMYK are enabled by default. If you want only RGB or only CMYK color, use <tt>cmyk=no</tt> or <tt>rgb=no</tt>. Multitone colors see below. <br />
* For spot colors, say spot=yes. To eliminate everything except spot colours, leaving a clean file for professional printing, accompany this with rgb=no,cmyk=no. See spot colours below for more details.<br />
* Normally all colors are defined in RGB ''and'' CMYK and get converted if needed.<br />
<br />
== Using predefined colors: <cmd>setupcolor</cmd> ==<br />
<br />
You find lists of predefined colors in the files <tt>colo-xxx.tex</tt>, load them with <cmd>setupcolor</cmd><tt>[xxx]</tt>:<br />
* rgb: some simple colors, loaded by default (with translations for the different interface languages!)<br />
* xwi: X-Windows-colors<br />
* pra: PRAGMA ADE company colors<br />
* ema: Emacs colors<br />
<br />
* Try the magic <cmd>showcolor</cmd><tt>[xxx]</tt>!<br />
<br />
{|<br />
! width="25%"|<br />
! width="10%"|<br />
! width="65%"|<br />
|-<br />
| <texcode><br />
\showcolor[rgb]<br />
</texcode><br />
|<br />
| <context><br />
\setupcolors[state=start]<br />
\showcolor[rgb]<br />
</context><br />
|}<br />
<br />
== Defining colors: <cmd>definecolor</cmd> ==<br />
<br />
<cmd>definecolor</cmd><tt>[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]</tt> (definition for RGB, CMYK and Grey!)<br />
<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\definecolor[blablue][r=.25, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]<br />
<br />
Here's some \color[blablue]{blue text} inbetween!<br />
</texcode><br />
|<br />
| <context><br />
\setupcolors[state=start]<br />
\definecolor[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]<br />
<br />
Here's some \color[blablue]{blue text} inbetween!<br />
</context><br />
|}<br />
<br />
=== Colors with Hexadecimal Numbers ===<br />
<br />
You can also use hexadecimal numers to specify colors. You need to load the '''hex''' color module first:<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\setupcolor[hex]<br />
\definecolor[salmon][h=AB5757]<br />
<br />
Hey, \color[salmon]{look at that!}<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\setupcolor[hex]<br />
\definecolor[salmon][h=AB5757]<br />
<br />
Hey, \color[salmon]{look at that!}<br />
</context><br />
|}<br />
<br />
===Transparent Colors===<br />
<br />
You can define '''transparent''' colors through setting t, e.g. <tt>t=0.5</tt>. Beware, some PDF viewers and printshops can't handle PDF transparences!<br />
<br />
Hans Hagen posted the following sample code for transparent colors on the mailing list on 2005-07-13; the yellow blocks have been added to demonstrate the order in which the blocks are drawn on the page; the first yellow block is behind the transparent red and blue blocks, while the second is in front of them.<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\definecolor [transparentred] [r=1,t=.5,a=1]<br />
\definecolor [transparentblue] [b=1,t=.5,a=1]<br />
\definecolor [solidyellow] [y=1,t=1,a=1]<br />
<br />
\starttext<br />
<br />
\startTEXpage<br />
This is some sample text that goes behind the rectangles\hskip-8cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=transparentred]\hskip-0.67cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=transparentblue]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=solidyellow]\hskip2cm.<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</texcode><br />
|<br />
|<context><br />
\setupcolors[state=start]<br />
\definecolor [transparentred] [r=1,t=.5,a=1]<br />
\definecolor [transparentblue] [b=1,t=.5,a=1]<br />
\definecolor [solidyellow] [y=1,t=1,a=1]<br />
<br />
\starttext<br />
<br />
\startTEXpage<br />
This is some sample text that goes behind the rectangles\hskip-8cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=transparentred]\hskip-0.67cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=transparentblue]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=solidyellow]\hskip2cm.<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</context><br />
|}<br />
<br />
== Defining color schemes: <cmd>definecolorgroup</cmd> and <cmd>definepalet</cmd>==<br />
<cmd>definecolorgroup</cmd><tt>[name][system][values]</tt><br />
<br />
<cmd>definepalet</cmd><tt>[palettename][colorname1=groupcolor:1, colorname2=groupcolor:2, ...]</tt><br />
<br />
Very interesting feature, to be described later... (see manual)<br />
<br />
=Using Colors=<br />
<br />
* Use the color name like <tt>[color=blablue]</tt> in some <tt>\setup...</tt> command.<br />
* Typeset single text elements with <cmd>color</cmd><tt>[blablue]{nice blue text}</tt> or longer sections with <cmd>startcolor</cmd><tt>[blablue] ...</tt> <cmd>stopcolor</cmd>.<br />
<br />
=Spot colours=<br />
<br />
To produce a file ready for a clean PDF separation process at your print house, start with:<br />
<br />
<cmd>setupcolors</cmd><tt>[rgb=no,cmyk=yes,spot=yes,state=start,overprint=yes]</tt><br />
<br />
which will set things up for spot colors with CMYK allowed. The last setting ensures that black overprinting your spot colour tints will not knock out the colour - this is important for some types of commercial printing.<br />
<br />
Then define your basic spot colour. Note that the name cannot contain spaces or numbers (but we come to that later):<br />
<br />
<cmd>definecolor</cmd><tt>[PantoneTwoNineFour][c=1,m=.56,y=0,k=.18]</tt><br />
<br />
Now you can define the tints of this ink that you are actually going to use in your document. Let's say you'll have a 100% for headings:<br />
<br />
<cmd>definespotcolor</cmd><tt>[MyBlue][PantoneTwoNineFour][p=1]</tt><br />
<br />
And then a 20% tint for nice display boxes:<br />
<br />
<cmd>definespotcolor</cmd><tt>[MyBlueTint][PantoneTwoNineFour][p=.2]</tt><br />
<br />
And now you can happily use these named colours:<br />
<br />
<texcode><br />
\starttext<br />
\color[MyBlue]{Interesting}<br />
\stoptext<br />
</texcode><br />
<br />
If you are including graphics made by an external program, you might want to match the colour name used in the graphic with the colour name in your '''ConTeXt''' set-up so that only one colour space is used in the final file. Unfortunately Pantone names and others tend to have spaces and numbers in them, so you need to do a low-level mapping trick from your base name to the name you want embedded in the file:<br />
<br />
<cmd>doregisterspotcolorname</cmd><tt>{PantoneTwoNineFour}{PANTONE 294 CV}</tt><br />
<br />
Now your output file should work beautifully with graphics embedded!<br />
<br />
==Using the 'e' key to \definecolor to specify a spot colour name with spaces==<br />
<br />
As an update to the above description on defining spot colours, you can now use the 'e' key when defining your spot colours in order to specify the precise colour names to be used by your ConTeXt set-up in the output file. For example:<br />
<br />
<texcode><br />
% Define spot colours using 'e=....' to specify colour names to use in output file<br />
\definecolor<br />
[PantoneThreeZeroEight]<br />
[c=1,m=.05,y=0,k=.47,e=PANTONE 308 CV]<br />
<br />
\definecolor<br />
[PantoneTwoNineEight]<br />
[c=.69,m=.07,y=0,k=0,e=PANTONE 298 CV]<br />
<br />
% Define tints of spot colours to be used in document for colouring text<br />
\definespotcolor<br />
[DarkBlue]<br />
[PantoneThreeZeroEight]<br />
[p=1]<br />
<br />
\definespotcolor<br />
[LightBlue]<br />
[PantoneTwoNineEight]<br />
[p=1]<br />
</texcode><br />
<br />
(Tested only on minimal Linux distribution dated 31 Aug 2005 - can others confirm this<br />
to be true across the board now?)<br />
<br />
Any text between a <cmd>startcolor[DarkBlue]</cmd> and <cmd>stopcolor</cmd> should now be assigned to the correct spot colour channel - Pantone 308 CV - on output. More importantly if you include an external figure containing areas of this colour then your text and those parts of the graphic which have the same colour should now appear together in the 'Pantone 308 CV' colour channel on colour separation. <br />
<br />
For example, if your original graphic is an EPS file containing the following lines:<br />
<br />
%%DocumentCustomColors: (PANTONE 298 CV)<br />
%%+ (PANTONE 308 CV)<br />
%%CMYKCustomColor: 0.69 0.07 0 0 (PANTONE 298 CV)<br />
%%+ 1 0.05 0 0.47 (PANTONE 308 CV)<br />
<br />
and you convert this to a PDF using <tt>ps2pdf</tt> for inclusion in your '''ConTeXt''' document your PDF graphic will then contain something like:<br />
<br />
<code><br />
8 0 obj<br />
[/Separation<br />
/PANTONE#20308#20CV<br />
/DeviceCMYK<br />
9 0 R]endobj<br />
10 0 obj<br />
[/Separation<br />
/PANTONE#20298#20CV<br />
/DeviceCMYK<br />
11 0 R]endobj<br />
</code><br />
<br />
Note how the space characters in the colour name are now encoded as '#20', but the colour names are essentially identical between the original EPS graphic, the new PDF graphic and your text.<br />
<br />
A good way of testing colour separation if you don't have access to expensive pre-flight PDF validation tools is to use the following GhostScript command:<br />
<br />
gs \<br />
-dBATCH \<br />
-dNOPAUSE \<br />
-sDEVICE=tiffsep \<br />
-dDOINTERPOLATE \<br />
-dTextAlphaBits=4 \<br />
-dGraphicsAlphaBits=4 \<br />
-sOutputFile=output.tif \<br />
-r120 \<br />
-MaxSeparations=8 \<br />
input.pdf<br />
<br />
This renders a PDF file <tt>input.pdf</tt> as a set of TIFF files:<br />
<br />
output.tif - Composite including CMYK approximations to spot colours<br />
output.tif.Black.tif - K channel<br />
output.tif.Cyan.tif - C channel<br />
output.tif.Magenta.tif - M channel<br />
output.tif.Yellow.tif - Y channel<br />
output.tif.s0.tif - Pantone 308 CV<br />
output.tif.s1.tif - Pantone 298 CV<br />
<br />
=Multitones=<br />
<br />
Hans wrote on the mailinglist on 2004-12-27 about handling of multitone colors:<br />
<br />
Currently it's done by pdftools.rb<br />
<br />
Once pdfxTeX becomes pdfeTeX out of a sudden your beta can do it as well.<br />
<br />
I still need to figure out a way to automatically reverse the graphic, but one of these days you can start using it.<br />
<br />
Actually, multitones for text already work out of the box:<br />
<texcode><br />
\setupcolors[state=start]<br />
<br />
\definecolor [blue] [c=1,m=.38,y=0,k=.64]<br />
\definecolor [yellow] [c=0,m=.28,y=1,k=.06]<br />
<br />
\definespotcolor [blue-100] [blue] [p=1]<br />
\definespotcolor [yellow-100] [yellow] [p=1]<br />
<br />
\definemultitonecolor [combicolor] [blue=.12,yellow=.28] [c=.1,m=.1,y=.3,k=.1]<br />
<br />
\starttext<br />
<br />
\startcolor[blue]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\startcolor[yellow]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\startcolor[combicolor]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\stoptext<br />
</texcode><br />
(The CMYK color spec is the fall back color used on screen; one can preview separations in full Acrobat 7.)<br />
<br />
<br />
<br />
=Colorizing Grayscale Pictures=<br />
<br />
Another sample by Hans (mailing list 2005-11-16) demonstrates a lot of different possibilities:<br />
<br />
<texcode><br />
\setuplayout[header=0pt,footer=0pt,width=middle,height=middle,backspace=1cm,topspace=1cm]<br />
\setupcolors[state=start]<br />
<br />
\startbuffer<br />
\definecolor [blue] [c=1, m=.38, y=0, k=.64]<br />
\definecolor [yellow] [c=0, m=.28, y=1, k=.06]<br />
<br />
\definespotcolor [blue-100] [blue] [p=1]<br />
\definespotcolor [yellow-100] [yellow] [p=1]<br />
<br />
\definemultitonecolor [combicolor] [blue=.12, yellow=.28] [c=.1, m=.1, y=.3, k=.1]<br />
<br />
\definemultitonecolor [combicolor-b] [blue=1] [c=1, m=.38, y=0, k=.64] % force multitone<br />
\definemultitonecolor [combicolor-y] [yellow=1] [c=0, m=.28, y=1, k=.06] % force multitone<br />
<br />
\useexternalfigure[demo-a][mill.png] [object=no, width=.2\textwidth]<br />
\useexternalfigure[demo-b][hacker-bw.jpg][object=no, width=.2\textwidth]<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-a]} {no color}<br />
{\externalfigure[demo-a][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-a][color=combicolor-b]} {spot color}<br />
{\externalfigure[demo-a][color=combicolor-y]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-b]} {no color}<br />
{\externalfigure[demo-b][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-b][color=combicolor-b]} {spot color}<br />
{\externalfigure[demo-b][color=combicolor-y]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-a]} {no color}<br />
{\externalfigure[demo-a][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-a][color=blue-100]} {spot color}<br />
{\externalfigure[demo-a][color=yellow-100]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-b]} {no color}<br />
{\externalfigure[demo-b][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-b][color=blue-100]} {spot color}<br />
{\externalfigure[demo-b][color=yellow-100]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
\stopbuffer<br />
<br />
\getbuffer \typebuffer<br />
<br />
\stoptext<br />
</texcode><br />
<br />
= References =<br />
<br />
See "Color and Background" in the manual</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Color&diff=9796Color2009-06-01T13:15:00Z<p>Nicolas Girard: /* Using Colors */ Added subsections</p>
<hr />
<div>< [[Visuals]] | [[Graphics]] ><br />
<br />
= Enabling colors =<br />
<br />
In current versions (earlier than 11.05.2009) of ConTeXt mkiv, colors are enabled by default.<br />
<br />
In older versions, colors must be enabled using<br />
<cmd>setupcolors</cmd><tt>[state=start]</tt><br />
<br />
=Using Colors=<br />
<br />
Using colors with ConTeXt is easy:<br />
<br />
== Choosing a color model ==<br />
<br />
* RGB and CMYK are enabled by default. If you want only RGB or only CMYK color, use <tt>cmyk=no</tt> or <tt>rgb=no</tt>. Multitone colors see below. <br />
* For spot colors, say spot=yes. To eliminate everything except spot colours, leaving a clean file for professional printing, accompany this with rgb=no,cmyk=no. See spot colours below for more details.<br />
* Normally all colors are defined in RGB ''and'' CMYK and get converted if needed.<br />
<br />
== Using predefined colors: <cmd>setupcolor</cmd> ==<br />
<br />
You find lists of predefined colors in the files <tt>colo-xxx.tex</tt>, load them with <cmd>setupcolor</cmd><tt>[xxx]</tt>:<br />
* rgb: some simple colors, loaded by default (with translations for the different interface languages!)<br />
* xwi: X-Windows-colors<br />
* pra: PRAGMA ADE company colors<br />
* ema: Emacs colors<br />
<br />
* Try the magic <cmd>showcolor</cmd><tt>[xxx]</tt>!<br />
<br />
{|<br />
! width="25%"|<br />
! width="10%"|<br />
! width="65%"|<br />
|-<br />
| <texcode><br />
\showcolor[rgb]<br />
</texcode><br />
|<br />
| <context><br />
\setupcolors[state=start]<br />
\showcolor[rgb]<br />
</context><br />
|}<br />
<br />
== Defining colors: <cmd>definecolor</cmd> ==<br />
<br />
<cmd>definecolor</cmd><tt>[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]</tt> (definition for RGB, CMYK and Grey!)<br />
* You can define '''transparent''' colors through setting t, e.g. <tt>t=0.5</tt>. Beware, most PDF viewers and printshops can't handle PDF transparences!<br />
* Use the color name like <tt>[color=blablue]</tt> in some <tt>\setup...</tt> command.<br />
* Typeset single text elements with <cmd>color</cmd><tt>[blablue]{nice blue text}</tt> or longer sections with <cmd>startcolor</cmd><tt>[blablue] ...</tt> <cmd>stopcolor</cmd>.<br />
<br />
(See also "Color and Background" in the manual!)<br />
<br />
{|<br />
! width="45%"|<br />
! width="10%"|<br />
! width="45%"|<br />
|-<br />
| <texcode><br />
\definecolor[blablue][r=.25, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]<br />
<br />
Here's some \color[blablue]{blue text} inbetween!<br />
</texcode><br />
|<br />
| <context><br />
\setupcolors[state=start]<br />
\definecolor[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]<br />
<br />
Here's some \color[blablue]{blue text} inbetween!<br />
</context><br />
|}<br />
<br />
=Colorgroups and Palettes=<br />
<cmd>definecolorgroup</cmd><tt>[name][system][values]</tt><br />
<br />
<cmd>definepalet</cmd><tt>[palettename][colorname1=groupcolor:1, colorname2=groupcolor:2, ...]</tt><br />
<br />
Very interesting feature, to be described later... (see manual)<br />
<br />
=Spot colours=<br />
<br />
To produce a file ready for a clean PDF separation process at your print house, start with:<br />
<br />
<cmd>setupcolors</cmd><tt>[rgb=no,cmyk=yes,spot=yes,state=start,overprint=yes]</tt><br />
<br />
which will set things up for spot colors with CMYK allowed. The last setting ensures that black overprinting your spot colour tints will not knock out the colour - this is important for some types of commercial printing.<br />
<br />
Then define your basic spot colour. Note that the name cannot contain spaces or numbers (but we come to that later):<br />
<br />
<cmd>definecolor</cmd><tt>[PantoneTwoNineFour][c=1,m=.56,y=0,k=.18]</tt><br />
<br />
Now you can define the tints of this ink that you are actually going to use in your document. Let's say you'll have a 100% for headings:<br />
<br />
<cmd>definespotcolor</cmd><tt>[MyBlue][PantoneTwoNineFour][p=1]</tt><br />
<br />
And then a 20% tint for nice display boxes:<br />
<br />
<cmd>definespotcolor</cmd><tt>[MyBlueTint][PantoneTwoNineFour][p=.2]</tt><br />
<br />
And now you can happily use these named colours:<br />
<br />
<texcode><br />
\starttext<br />
\color[MyBlue]{Interesting}<br />
\stoptext<br />
</texcode><br />
<br />
If you are including graphics made by an external program, you might want to match the colour name used in the graphic with the colour name in your '''ConTeXt''' set-up so that only one colour space is used in the final file. Unfortunately Pantone names and others tend to have spaces and numbers in them, so you need to do a low-level mapping trick from your base name to the name you want embedded in the file:<br />
<br />
<cmd>doregisterspotcolorname</cmd><tt>{PantoneTwoNineFour}{PANTONE 294 CV}</tt><br />
<br />
Now your output file should work beautifully with graphics embedded!<br />
<br />
==Using the 'e' key to \definecolor to specify a spot colour name with spaces==<br />
<br />
As an update to the above description on defining spot colours, you can now use the 'e' key when defining your spot colours in order to specify the precise colour names to be used by your ConTeXt set-up in the output file. For example:<br />
<br />
<texcode><br />
% Define spot colours using 'e=....' to specify colour names to use in output file<br />
\definecolor<br />
[PantoneThreeZeroEight]<br />
[c=1,m=.05,y=0,k=.47,e=PANTONE 308 CV]<br />
<br />
\definecolor<br />
[PantoneTwoNineEight]<br />
[c=.69,m=.07,y=0,k=0,e=PANTONE 298 CV]<br />
<br />
% Define tints of spot colours to be used in document for colouring text<br />
\definespotcolor<br />
[DarkBlue]<br />
[PantoneThreeZeroEight]<br />
[p=1]<br />
<br />
\definespotcolor<br />
[LightBlue]<br />
[PantoneTwoNineEight]<br />
[p=1]<br />
</texcode><br />
<br />
(Tested only on minimal Linux distribution dated 31 Aug 2005 - can others confirm this<br />
to be true across the board now?)<br />
<br />
Any text between a <cmd>startcolor[DarkBlue]</cmd> and <cmd>stopcolor</cmd> should now be assigned to the correct spot colour channel - Pantone 308 CV - on output. More importantly if you include an external figure containing areas of this colour then your text and those parts of the graphic which have the same colour should now appear together in the 'Pantone 308 CV' colour channel on colour separation. <br />
<br />
For example, if your original graphic is an EPS file containing the following lines:<br />
<br />
%%DocumentCustomColors: (PANTONE 298 CV)<br />
%%+ (PANTONE 308 CV)<br />
%%CMYKCustomColor: 0.69 0.07 0 0 (PANTONE 298 CV)<br />
%%+ 1 0.05 0 0.47 (PANTONE 308 CV)<br />
<br />
and you convert this to a PDF using <tt>ps2pdf</tt> for inclusion in your '''ConTeXt''' document your PDF graphic will then contain something like:<br />
<br />
<code><br />
8 0 obj<br />
[/Separation<br />
/PANTONE#20308#20CV<br />
/DeviceCMYK<br />
9 0 R]endobj<br />
10 0 obj<br />
[/Separation<br />
/PANTONE#20298#20CV<br />
/DeviceCMYK<br />
11 0 R]endobj<br />
</code><br />
<br />
Note how the space characters in the colour name are now encoded as '#20', but the colour names are essentially identical between the original EPS graphic, the new PDF graphic and your text.<br />
<br />
A good way of testing colour separation if you don't have access to expensive pre-flight PDF validation tools is to use the following GhostScript command:<br />
<br />
gs \<br />
-dBATCH \<br />
-dNOPAUSE \<br />
-sDEVICE=tiffsep \<br />
-dDOINTERPOLATE \<br />
-dTextAlphaBits=4 \<br />
-dGraphicsAlphaBits=4 \<br />
-sOutputFile=output.tif \<br />
-r120 \<br />
-MaxSeparations=8 \<br />
input.pdf<br />
<br />
This renders a PDF file <tt>input.pdf</tt> as a set of TIFF files:<br />
<br />
output.tif - Composite including CMYK approximations to spot colours<br />
output.tif.Black.tif - K channel<br />
output.tif.Cyan.tif - C channel<br />
output.tif.Magenta.tif - M channel<br />
output.tif.Yellow.tif - Y channel<br />
output.tif.s0.tif - Pantone 308 CV<br />
output.tif.s1.tif - Pantone 298 CV<br />
<br />
=Multitones=<br />
<br />
Hans wrote on the mailinglist on 2004-12-27 about handling of multitone colors:<br />
<br />
Currently it's done by pdftools.rb<br />
<br />
Once pdfxTeX becomes pdfeTeX out of a sudden your beta can do it as well.<br />
<br />
I still need to figure out a way to automatically reverse the graphic, but one of these days you can start using it.<br />
<br />
Actually, multitones for text already work out of the box:<br />
<texcode><br />
\setupcolors[state=start]<br />
<br />
\definecolor [blue] [c=1,m=.38,y=0,k=.64]<br />
\definecolor [yellow] [c=0,m=.28,y=1,k=.06]<br />
<br />
\definespotcolor [blue-100] [blue] [p=1]<br />
\definespotcolor [yellow-100] [yellow] [p=1]<br />
<br />
\definemultitonecolor [combicolor] [blue=.12,yellow=.28] [c=.1,m=.1,y=.3,k=.1]<br />
<br />
\starttext<br />
<br />
\startcolor[blue]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\startcolor[yellow]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\startcolor[combicolor]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\stoptext<br />
</texcode><br />
(The CMYK color spec is the fall back color used on screen; one can preview separations in full Acrobat 7.)<br />
<br />
=Transparent Colors=<br />
<br />
As mentioned earlier, transparent colors can be produced by setting the <tt>t</tt> value for the color. Hans Hagen posted the following sample code for transparent colors on the mailing list on 2005-07-13; the yellow blocks have been added to demonstrate the order in which the blocks are drawn on the page; the first yellow block is behind the transparent red and blue blocks, while the second is in front of them.<br />
<br />
<texcode><br />
\setupcolors[state=start]<br />
\definecolor [transparentred] [r=1,t=.5,a=1]<br />
\definecolor [transparentblue] [b=1,t=.5,a=1]<br />
\definecolor [solidyellow] [y=1,t=1,a=1]<br />
<br />
\starttext<br />
<br />
\startTEXpage<br />
This is some sample text that goes behind the rectangles\hskip-8cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=transparentred]\hskip-0.67cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=transparentblue]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=solidyellow]\hskip2cm.<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</texcode><br />
<br />
<context><br />
\setupcolors[state=start]<br />
\definecolor [transparentred] [r=1,t=.5,a=1]<br />
\definecolor [transparentblue] [b=1,t=.5,a=1]<br />
\definecolor [solidyellow] [y=1,t=1,a=1]<br />
<br />
\starttext<br />
<br />
\startTEXpage<br />
This is some sample text that goes behind the rectangles\hskip-8cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=transparentred]\hskip-0.67cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=transparentblue]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=solidyellow]\hskip2cm.<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</context><br />
<br />
=Colorizing Grayscale Pictures=<br />
<br />
Another sample by Hans (mailing list 2005-11-16) demonstrates a lot of different possibilities:<br />
<br />
<texcode><br />
\setuplayout[header=0pt,footer=0pt,width=middle,height=middle,backspace=1cm,topspace=1cm]<br />
\setupcolors[state=start]<br />
<br />
\startbuffer<br />
\definecolor [blue] [c=1, m=.38, y=0, k=.64]<br />
\definecolor [yellow] [c=0, m=.28, y=1, k=.06]<br />
<br />
\definespotcolor [blue-100] [blue] [p=1]<br />
\definespotcolor [yellow-100] [yellow] [p=1]<br />
<br />
\definemultitonecolor [combicolor] [blue=.12, yellow=.28] [c=.1, m=.1, y=.3, k=.1]<br />
<br />
\definemultitonecolor [combicolor-b] [blue=1] [c=1, m=.38, y=0, k=.64] % force multitone<br />
\definemultitonecolor [combicolor-y] [yellow=1] [c=0, m=.28, y=1, k=.06] % force multitone<br />
<br />
\useexternalfigure[demo-a][mill.png] [object=no, width=.2\textwidth]<br />
\useexternalfigure[demo-b][hacker-bw.jpg][object=no, width=.2\textwidth]<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-a]} {no color}<br />
{\externalfigure[demo-a][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-a][color=combicolor-b]} {spot color}<br />
{\externalfigure[demo-a][color=combicolor-y]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-b]} {no color}<br />
{\externalfigure[demo-b][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-b][color=combicolor-b]} {spot color}<br />
{\externalfigure[demo-b][color=combicolor-y]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-a]} {no color}<br />
{\externalfigure[demo-a][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-a][color=blue-100]} {spot color}<br />
{\externalfigure[demo-a][color=yellow-100]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-b]} {no color}<br />
{\externalfigure[demo-b][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-b][color=blue-100]} {spot color}<br />
{\externalfigure[demo-b][color=yellow-100]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
\stopbuffer<br />
<br />
\getbuffer \typebuffer<br />
<br />
\stoptext<br />
</texcode><br />
<br />
= Colors with Hexadecimal Numbers =<br />
<br />
You can also use hexadecimal numers to specify colors. You need to load the '''hex''' color module first:<br />
<texcode><br />
\setupcolor[hex]<br />
</texcode><br />
and then you may define colors with<br />
<texcode><br />
\definecolor[hex-red][h=FF0000]<br />
</texcode></div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Color&diff=9795Color2009-06-01T10:37:00Z<p>Nicolas Girard: /* Enabling colors */ Typo</p>
<hr />
<div>< [[Visuals]] | [[Graphics]] ><br />
<br />
= Enabling colors =<br />
<br />
In current versions (earlier than 11.05.2009) of ConTeXt mkiv, colors are enabled by default.<br />
<br />
In older versions, colors must be enabled using<br />
<cmd>setupcolors</cmd><tt>[state=start]</tt><br />
<br />
=Using Colors=<br />
<br />
Using colors with ConTeXt is easy:<br />
<br />
* RGB and CMYK are enabled by default. If you want only RGB or only CMYK color, use <tt>cmyk=no</tt> or <tt>rgb=no</tt>. Multitone colors see below. <br />
* For spot colors, say spot=yes. To eliminate everything except spot colours, leaving a clean file for professional printing, accompany this with rgb=no,cmyk=no. See spot colours below for more details.<br />
* Normally all colors are defined in RGB ''and'' CMYK and get converted if needed.<br />
* You find lists of predefined colors in the files <tt>colo-xxx.tex</tt>, load them with <cmd>setupcolor</cmd><tt>[xxx]</tt>:<br />
** rgb: some simple colors, loaded by default (with translations for the different interface languages!)<br />
** xwi: X-Windows-colors<br />
** pra: PRAGMA ADE company colors<br />
** ema: Emacs colors<br />
* Try the magic <cmd>showcolor</cmd><tt>[xxx]</tt>!<br />
* Define your own colors with <cmd>definecolor</cmd><tt>[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]</tt> (definition for RGB, CMYK and Grey!)<br />
* You can define '''transparent''' colors through setting t, e.g. <tt>t=0.5</tt>. Beware, most PDF viewers and printshops can't handle PDF transparences!<br />
* Use the color name like <tt>[color=blablue]</tt> in some <tt>\setup...</tt> command.<br />
* Typeset single text elements with <cmd>color</cmd><tt>[blablue]{nice blue text}</tt> or longer sections with <cmd>startcolor</cmd><tt>[blablue] ...</tt> <cmd>stopcolor</cmd>.<br />
<br />
(See also "Color and Background" in the manual!)<br />
<br />
===Sample===<br />
<texcode><br />
\setupcolors[state=start]<br />
\definecolor[blablue][r=.25, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]<br />
<br />
Here's some \color[blablue]{blue text} inbetween!<br />
<br />
\showcolor[rgb]<br />
</texcode><br />
<context><br />
\setupcolors[state=start]<br />
\definecolor[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]<br />
<br />
Here's some \color[blablue]{blue text} inbetween!<br />
<br />
\showcolor[rgb]<br />
</context><br />
<br />
=Colorgroups and Palettes=<br />
<cmd>definecolorgroup</cmd><tt>[name][system][values]</tt><br />
<br />
<cmd>definepalet</cmd><tt>[palettename][colorname1=groupcolor:1, colorname2=groupcolor:2, ...]</tt><br />
<br />
Very interesting feature, to be described later... (see manual)<br />
<br />
=Spot colours=<br />
<br />
To produce a file ready for a clean PDF separation process at your print house, start with:<br />
<br />
<cmd>setupcolors</cmd><tt>[rgb=no,cmyk=yes,spot=yes,state=start,overprint=yes]</tt><br />
<br />
which will set things up for spot colors with CMYK allowed. The last setting ensures that black overprinting your spot colour tints will not knock out the colour - this is important for some types of commercial printing.<br />
<br />
Then define your basic spot colour. Note that the name cannot contain spaces or numbers (but we come to that later):<br />
<br />
<cmd>definecolor</cmd><tt>[PantoneTwoNineFour][c=1,m=.56,y=0,k=.18]</tt><br />
<br />
Now you can define the tints of this ink that you are actually going to use in your document. Let's say you'll have a 100% for headings:<br />
<br />
<cmd>definespotcolor</cmd><tt>[MyBlue][PantoneTwoNineFour][p=1]</tt><br />
<br />
And then a 20% tint for nice display boxes:<br />
<br />
<cmd>definespotcolor</cmd><tt>[MyBlueTint][PantoneTwoNineFour][p=.2]</tt><br />
<br />
And now you can happily use these named colours:<br />
<br />
<texcode><br />
\starttext<br />
\color[MyBlue]{Interesting}<br />
\stoptext<br />
</texcode><br />
<br />
If you are including graphics made by an external program, you might want to match the colour name used in the graphic with the colour name in your '''ConTeXt''' set-up so that only one colour space is used in the final file. Unfortunately Pantone names and others tend to have spaces and numbers in them, so you need to do a low-level mapping trick from your base name to the name you want embedded in the file:<br />
<br />
<cmd>doregisterspotcolorname</cmd><tt>{PantoneTwoNineFour}{PANTONE 294 CV}</tt><br />
<br />
Now your output file should work beautifully with graphics embedded!<br />
<br />
==Using the 'e' key to \definecolor to specify a spot colour name with spaces==<br />
<br />
As an update to the above description on defining spot colours, you can now use the 'e' key when defining your spot colours in order to specify the precise colour names to be used by your ConTeXt set-up in the output file. For example:<br />
<br />
<texcode><br />
% Define spot colours using 'e=....' to specify colour names to use in output file<br />
\definecolor<br />
[PantoneThreeZeroEight]<br />
[c=1,m=.05,y=0,k=.47,e=PANTONE 308 CV]<br />
<br />
\definecolor<br />
[PantoneTwoNineEight]<br />
[c=.69,m=.07,y=0,k=0,e=PANTONE 298 CV]<br />
<br />
% Define tints of spot colours to be used in document for colouring text<br />
\definespotcolor<br />
[DarkBlue]<br />
[PantoneThreeZeroEight]<br />
[p=1]<br />
<br />
\definespotcolor<br />
[LightBlue]<br />
[PantoneTwoNineEight]<br />
[p=1]<br />
</texcode><br />
<br />
(Tested only on minimal Linux distribution dated 31 Aug 2005 - can others confirm this<br />
to be true across the board now?)<br />
<br />
Any text between a <cmd>startcolor[DarkBlue]</cmd> and <cmd>stopcolor</cmd> should now be assigned to the correct spot colour channel - Pantone 308 CV - on output. More importantly if you include an external figure containing areas of this colour then your text and those parts of the graphic which have the same colour should now appear together in the 'Pantone 308 CV' colour channel on colour separation. <br />
<br />
For example, if your original graphic is an EPS file containing the following lines:<br />
<br />
%%DocumentCustomColors: (PANTONE 298 CV)<br />
%%+ (PANTONE 308 CV)<br />
%%CMYKCustomColor: 0.69 0.07 0 0 (PANTONE 298 CV)<br />
%%+ 1 0.05 0 0.47 (PANTONE 308 CV)<br />
<br />
and you convert this to a PDF using <tt>ps2pdf</tt> for inclusion in your '''ConTeXt''' document your PDF graphic will then contain something like:<br />
<br />
<code><br />
8 0 obj<br />
[/Separation<br />
/PANTONE#20308#20CV<br />
/DeviceCMYK<br />
9 0 R]endobj<br />
10 0 obj<br />
[/Separation<br />
/PANTONE#20298#20CV<br />
/DeviceCMYK<br />
11 0 R]endobj<br />
</code><br />
<br />
Note how the space characters in the colour name are now encoded as '#20', but the colour names are essentially identical between the original EPS graphic, the new PDF graphic and your text.<br />
<br />
A good way of testing colour separation if you don't have access to expensive pre-flight PDF validation tools is to use the following GhostScript command:<br />
<br />
gs \<br />
-dBATCH \<br />
-dNOPAUSE \<br />
-sDEVICE=tiffsep \<br />
-dDOINTERPOLATE \<br />
-dTextAlphaBits=4 \<br />
-dGraphicsAlphaBits=4 \<br />
-sOutputFile=output.tif \<br />
-r120 \<br />
-MaxSeparations=8 \<br />
input.pdf<br />
<br />
This renders a PDF file <tt>input.pdf</tt> as a set of TIFF files:<br />
<br />
output.tif - Composite including CMYK approximations to spot colours<br />
output.tif.Black.tif - K channel<br />
output.tif.Cyan.tif - C channel<br />
output.tif.Magenta.tif - M channel<br />
output.tif.Yellow.tif - Y channel<br />
output.tif.s0.tif - Pantone 308 CV<br />
output.tif.s1.tif - Pantone 298 CV<br />
<br />
=Multitones=<br />
<br />
Hans wrote on the mailinglist on 2004-12-27 about handling of multitone colors:<br />
<br />
Currently it's done by pdftools.rb<br />
<br />
Once pdfxTeX becomes pdfeTeX out of a sudden your beta can do it as well.<br />
<br />
I still need to figure out a way to automatically reverse the graphic, but one of these days you can start using it.<br />
<br />
Actually, multitones for text already work out of the box:<br />
<texcode><br />
\setupcolors[state=start]<br />
<br />
\definecolor [blue] [c=1,m=.38,y=0,k=.64]<br />
\definecolor [yellow] [c=0,m=.28,y=1,k=.06]<br />
<br />
\definespotcolor [blue-100] [blue] [p=1]<br />
\definespotcolor [yellow-100] [yellow] [p=1]<br />
<br />
\definemultitonecolor [combicolor] [blue=.12,yellow=.28] [c=.1,m=.1,y=.3,k=.1]<br />
<br />
\starttext<br />
<br />
\startcolor[blue]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\startcolor[yellow]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\startcolor[combicolor]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\stoptext<br />
</texcode><br />
(The CMYK color spec is the fall back color used on screen; one can preview separations in full Acrobat 7.)<br />
<br />
=Transparent Colors=<br />
<br />
As mentioned earlier, transparent colors can be produced by setting the <tt>t</tt> value for the color. Hans Hagen posted the following sample code for transparent colors on the mailing list on 2005-07-13; the yellow blocks have been added to demonstrate the order in which the blocks are drawn on the page; the first yellow block is behind the transparent red and blue blocks, while the second is in front of them.<br />
<br />
<texcode><br />
\setupcolors[state=start]<br />
\definecolor [transparentred] [r=1,t=.5,a=1]<br />
\definecolor [transparentblue] [b=1,t=.5,a=1]<br />
\definecolor [solidyellow] [y=1,t=1,a=1]<br />
<br />
\starttext<br />
<br />
\startTEXpage<br />
This is some sample text that goes behind the rectangles\hskip-8cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=transparentred]\hskip-0.67cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=transparentblue]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=solidyellow]\hskip2cm.<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</texcode><br />
<br />
<context><br />
\setupcolors[state=start]<br />
\definecolor [transparentred] [r=1,t=.5,a=1]<br />
\definecolor [transparentblue] [b=1,t=.5,a=1]<br />
\definecolor [solidyellow] [y=1,t=1,a=1]<br />
<br />
\starttext<br />
<br />
\startTEXpage<br />
This is some sample text that goes behind the rectangles\hskip-8cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=transparentred]\hskip-0.67cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=transparentblue]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=solidyellow]\hskip2cm.<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</context><br />
<br />
=Colorizing Grayscale Pictures=<br />
<br />
Another sample by Hans (mailing list 2005-11-16) demonstrates a lot of different possibilities:<br />
<br />
<texcode><br />
\setuplayout[header=0pt,footer=0pt,width=middle,height=middle,backspace=1cm,topspace=1cm]<br />
\setupcolors[state=start]<br />
<br />
\startbuffer<br />
\definecolor [blue] [c=1, m=.38, y=0, k=.64]<br />
\definecolor [yellow] [c=0, m=.28, y=1, k=.06]<br />
<br />
\definespotcolor [blue-100] [blue] [p=1]<br />
\definespotcolor [yellow-100] [yellow] [p=1]<br />
<br />
\definemultitonecolor [combicolor] [blue=.12, yellow=.28] [c=.1, m=.1, y=.3, k=.1]<br />
<br />
\definemultitonecolor [combicolor-b] [blue=1] [c=1, m=.38, y=0, k=.64] % force multitone<br />
\definemultitonecolor [combicolor-y] [yellow=1] [c=0, m=.28, y=1, k=.06] % force multitone<br />
<br />
\useexternalfigure[demo-a][mill.png] [object=no, width=.2\textwidth]<br />
\useexternalfigure[demo-b][hacker-bw.jpg][object=no, width=.2\textwidth]<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-a]} {no color}<br />
{\externalfigure[demo-a][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-a][color=combicolor-b]} {spot color}<br />
{\externalfigure[demo-a][color=combicolor-y]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-b]} {no color}<br />
{\externalfigure[demo-b][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-b][color=combicolor-b]} {spot color}<br />
{\externalfigure[demo-b][color=combicolor-y]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-a]} {no color}<br />
{\externalfigure[demo-a][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-a][color=blue-100]} {spot color}<br />
{\externalfigure[demo-a][color=yellow-100]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-b]} {no color}<br />
{\externalfigure[demo-b][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-b][color=blue-100]} {spot color}<br />
{\externalfigure[demo-b][color=yellow-100]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
\stopbuffer<br />
<br />
\getbuffer \typebuffer<br />
<br />
\stoptext<br />
</texcode><br />
<br />
= Colors with Hexadecimal Numbers =<br />
<br />
You can also use hexadecimal numers to specify colors. You need to load the '''hex''' color module first:<br />
<texcode><br />
\setupcolor[hex]<br />
</texcode><br />
and then you may define colors with<br />
<texcode><br />
\definecolor[hex-red][h=FF0000]<br />
</texcode></div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Color&diff=9794Color2009-06-01T10:36:17Z<p>Nicolas Girard: /* Using Colors */ Colors are now enabled by default</p>
<hr />
<div>< [[Visuals]] | [[Graphics]] ><br />
<br />
= Enabling colors =<br />
<br />
In current versions (earlier than 11.05.2009) of ConTeXt mkiv, colors are enabled by default.<br />
<br />
In older versions, colors must be enabled using<br />
<cmd>setupcolors</cmd><tt>[state=start]</tt>.<br />
<br />
=Using Colors=<br />
<br />
Using colors with ConTeXt is easy:<br />
<br />
* RGB and CMYK are enabled by default. If you want only RGB or only CMYK color, use <tt>cmyk=no</tt> or <tt>rgb=no</tt>. Multitone colors see below. <br />
* For spot colors, say spot=yes. To eliminate everything except spot colours, leaving a clean file for professional printing, accompany this with rgb=no,cmyk=no. See spot colours below for more details.<br />
* Normally all colors are defined in RGB ''and'' CMYK and get converted if needed.<br />
* You find lists of predefined colors in the files <tt>colo-xxx.tex</tt>, load them with <cmd>setupcolor</cmd><tt>[xxx]</tt>:<br />
** rgb: some simple colors, loaded by default (with translations for the different interface languages!)<br />
** xwi: X-Windows-colors<br />
** pra: PRAGMA ADE company colors<br />
** ema: Emacs colors<br />
* Try the magic <cmd>showcolor</cmd><tt>[xxx]</tt>!<br />
* Define your own colors with <cmd>definecolor</cmd><tt>[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]</tt> (definition for RGB, CMYK and Grey!)<br />
* You can define '''transparent''' colors through setting t, e.g. <tt>t=0.5</tt>. Beware, most PDF viewers and printshops can't handle PDF transparences!<br />
* Use the color name like <tt>[color=blablue]</tt> in some <tt>\setup...</tt> command.<br />
* Typeset single text elements with <cmd>color</cmd><tt>[blablue]{nice blue text}</tt> or longer sections with <cmd>startcolor</cmd><tt>[blablue] ...</tt> <cmd>stopcolor</cmd>.<br />
<br />
(See also "Color and Background" in the manual!)<br />
<br />
===Sample===<br />
<texcode><br />
\setupcolors[state=start]<br />
\definecolor[blablue][r=.25, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]<br />
<br />
Here's some \color[blablue]{blue text} inbetween!<br />
<br />
\showcolor[rgb]<br />
</texcode><br />
<context><br />
\setupcolors[state=start]<br />
\definecolor[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]<br />
<br />
Here's some \color[blablue]{blue text} inbetween!<br />
<br />
\showcolor[rgb]<br />
</context><br />
<br />
=Colorgroups and Palettes=<br />
<cmd>definecolorgroup</cmd><tt>[name][system][values]</tt><br />
<br />
<cmd>definepalet</cmd><tt>[palettename][colorname1=groupcolor:1, colorname2=groupcolor:2, ...]</tt><br />
<br />
Very interesting feature, to be described later... (see manual)<br />
<br />
=Spot colours=<br />
<br />
To produce a file ready for a clean PDF separation process at your print house, start with:<br />
<br />
<cmd>setupcolors</cmd><tt>[rgb=no,cmyk=yes,spot=yes,state=start,overprint=yes]</tt><br />
<br />
which will set things up for spot colors with CMYK allowed. The last setting ensures that black overprinting your spot colour tints will not knock out the colour - this is important for some types of commercial printing.<br />
<br />
Then define your basic spot colour. Note that the name cannot contain spaces or numbers (but we come to that later):<br />
<br />
<cmd>definecolor</cmd><tt>[PantoneTwoNineFour][c=1,m=.56,y=0,k=.18]</tt><br />
<br />
Now you can define the tints of this ink that you are actually going to use in your document. Let's say you'll have a 100% for headings:<br />
<br />
<cmd>definespotcolor</cmd><tt>[MyBlue][PantoneTwoNineFour][p=1]</tt><br />
<br />
And then a 20% tint for nice display boxes:<br />
<br />
<cmd>definespotcolor</cmd><tt>[MyBlueTint][PantoneTwoNineFour][p=.2]</tt><br />
<br />
And now you can happily use these named colours:<br />
<br />
<texcode><br />
\starttext<br />
\color[MyBlue]{Interesting}<br />
\stoptext<br />
</texcode><br />
<br />
If you are including graphics made by an external program, you might want to match the colour name used in the graphic with the colour name in your '''ConTeXt''' set-up so that only one colour space is used in the final file. Unfortunately Pantone names and others tend to have spaces and numbers in them, so you need to do a low-level mapping trick from your base name to the name you want embedded in the file:<br />
<br />
<cmd>doregisterspotcolorname</cmd><tt>{PantoneTwoNineFour}{PANTONE 294 CV}</tt><br />
<br />
Now your output file should work beautifully with graphics embedded!<br />
<br />
==Using the 'e' key to \definecolor to specify a spot colour name with spaces==<br />
<br />
As an update to the above description on defining spot colours, you can now use the 'e' key when defining your spot colours in order to specify the precise colour names to be used by your ConTeXt set-up in the output file. For example:<br />
<br />
<texcode><br />
% Define spot colours using 'e=....' to specify colour names to use in output file<br />
\definecolor<br />
[PantoneThreeZeroEight]<br />
[c=1,m=.05,y=0,k=.47,e=PANTONE 308 CV]<br />
<br />
\definecolor<br />
[PantoneTwoNineEight]<br />
[c=.69,m=.07,y=0,k=0,e=PANTONE 298 CV]<br />
<br />
% Define tints of spot colours to be used in document for colouring text<br />
\definespotcolor<br />
[DarkBlue]<br />
[PantoneThreeZeroEight]<br />
[p=1]<br />
<br />
\definespotcolor<br />
[LightBlue]<br />
[PantoneTwoNineEight]<br />
[p=1]<br />
</texcode><br />
<br />
(Tested only on minimal Linux distribution dated 31 Aug 2005 - can others confirm this<br />
to be true across the board now?)<br />
<br />
Any text between a <cmd>startcolor[DarkBlue]</cmd> and <cmd>stopcolor</cmd> should now be assigned to the correct spot colour channel - Pantone 308 CV - on output. More importantly if you include an external figure containing areas of this colour then your text and those parts of the graphic which have the same colour should now appear together in the 'Pantone 308 CV' colour channel on colour separation. <br />
<br />
For example, if your original graphic is an EPS file containing the following lines:<br />
<br />
%%DocumentCustomColors: (PANTONE 298 CV)<br />
%%+ (PANTONE 308 CV)<br />
%%CMYKCustomColor: 0.69 0.07 0 0 (PANTONE 298 CV)<br />
%%+ 1 0.05 0 0.47 (PANTONE 308 CV)<br />
<br />
and you convert this to a PDF using <tt>ps2pdf</tt> for inclusion in your '''ConTeXt''' document your PDF graphic will then contain something like:<br />
<br />
<code><br />
8 0 obj<br />
[/Separation<br />
/PANTONE#20308#20CV<br />
/DeviceCMYK<br />
9 0 R]endobj<br />
10 0 obj<br />
[/Separation<br />
/PANTONE#20298#20CV<br />
/DeviceCMYK<br />
11 0 R]endobj<br />
</code><br />
<br />
Note how the space characters in the colour name are now encoded as '#20', but the colour names are essentially identical between the original EPS graphic, the new PDF graphic and your text.<br />
<br />
A good way of testing colour separation if you don't have access to expensive pre-flight PDF validation tools is to use the following GhostScript command:<br />
<br />
gs \<br />
-dBATCH \<br />
-dNOPAUSE \<br />
-sDEVICE=tiffsep \<br />
-dDOINTERPOLATE \<br />
-dTextAlphaBits=4 \<br />
-dGraphicsAlphaBits=4 \<br />
-sOutputFile=output.tif \<br />
-r120 \<br />
-MaxSeparations=8 \<br />
input.pdf<br />
<br />
This renders a PDF file <tt>input.pdf</tt> as a set of TIFF files:<br />
<br />
output.tif - Composite including CMYK approximations to spot colours<br />
output.tif.Black.tif - K channel<br />
output.tif.Cyan.tif - C channel<br />
output.tif.Magenta.tif - M channel<br />
output.tif.Yellow.tif - Y channel<br />
output.tif.s0.tif - Pantone 308 CV<br />
output.tif.s1.tif - Pantone 298 CV<br />
<br />
=Multitones=<br />
<br />
Hans wrote on the mailinglist on 2004-12-27 about handling of multitone colors:<br />
<br />
Currently it's done by pdftools.rb<br />
<br />
Once pdfxTeX becomes pdfeTeX out of a sudden your beta can do it as well.<br />
<br />
I still need to figure out a way to automatically reverse the graphic, but one of these days you can start using it.<br />
<br />
Actually, multitones for text already work out of the box:<br />
<texcode><br />
\setupcolors[state=start]<br />
<br />
\definecolor [blue] [c=1,m=.38,y=0,k=.64]<br />
\definecolor [yellow] [c=0,m=.28,y=1,k=.06]<br />
<br />
\definespotcolor [blue-100] [blue] [p=1]<br />
\definespotcolor [yellow-100] [yellow] [p=1]<br />
<br />
\definemultitonecolor [combicolor] [blue=.12,yellow=.28] [c=.1,m=.1,y=.3,k=.1]<br />
<br />
\starttext<br />
<br />
\startcolor[blue]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\startcolor[yellow]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\startcolor[combicolor]\blackrule[width=3cm,height=3cm]\stopcolor<br />
<br />
\stoptext<br />
</texcode><br />
(The CMYK color spec is the fall back color used on screen; one can preview separations in full Acrobat 7.)<br />
<br />
=Transparent Colors=<br />
<br />
As mentioned earlier, transparent colors can be produced by setting the <tt>t</tt> value for the color. Hans Hagen posted the following sample code for transparent colors on the mailing list on 2005-07-13; the yellow blocks have been added to demonstrate the order in which the blocks are drawn on the page; the first yellow block is behind the transparent red and blue blocks, while the second is in front of them.<br />
<br />
<texcode><br />
\setupcolors[state=start]<br />
\definecolor [transparentred] [r=1,t=.5,a=1]<br />
\definecolor [transparentblue] [b=1,t=.5,a=1]<br />
\definecolor [solidyellow] [y=1,t=1,a=1]<br />
<br />
\starttext<br />
<br />
\startTEXpage<br />
This is some sample text that goes behind the rectangles\hskip-8cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=transparentred]\hskip-0.67cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=transparentblue]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=solidyellow]\hskip2cm.<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</texcode><br />
<br />
<context><br />
\setupcolors[state=start]<br />
\definecolor [transparentred] [r=1,t=.5,a=1]<br />
\definecolor [transparentblue] [b=1,t=.5,a=1]<br />
\definecolor [solidyellow] [y=1,t=1,a=1]<br />
<br />
\starttext<br />
<br />
\startTEXpage<br />
This is some sample text that goes behind the rectangles\hskip-8cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=transparentred]\hskip-0.67cm<br />
\blackrule[width=2cm,height=1cm,depth=1cm,color=transparentblue]\hskip-0.67cm<br />
\blackrule[width=2cm,height=2cm,color=solidyellow]\hskip2cm.<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</context><br />
<br />
=Colorizing Grayscale Pictures=<br />
<br />
Another sample by Hans (mailing list 2005-11-16) demonstrates a lot of different possibilities:<br />
<br />
<texcode><br />
\setuplayout[header=0pt,footer=0pt,width=middle,height=middle,backspace=1cm,topspace=1cm]<br />
\setupcolors[state=start]<br />
<br />
\startbuffer<br />
\definecolor [blue] [c=1, m=.38, y=0, k=.64]<br />
\definecolor [yellow] [c=0, m=.28, y=1, k=.06]<br />
<br />
\definespotcolor [blue-100] [blue] [p=1]<br />
\definespotcolor [yellow-100] [yellow] [p=1]<br />
<br />
\definemultitonecolor [combicolor] [blue=.12, yellow=.28] [c=.1, m=.1, y=.3, k=.1]<br />
<br />
\definemultitonecolor [combicolor-b] [blue=1] [c=1, m=.38, y=0, k=.64] % force multitone<br />
\definemultitonecolor [combicolor-y] [yellow=1] [c=0, m=.28, y=1, k=.06] % force multitone<br />
<br />
\useexternalfigure[demo-a][mill.png] [object=no, width=.2\textwidth]<br />
\useexternalfigure[demo-b][hacker-bw.jpg][object=no, width=.2\textwidth]<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-a]} {no color}<br />
{\externalfigure[demo-a][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-a][color=combicolor-b]} {spot color}<br />
{\externalfigure[demo-a][color=combicolor-y]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-b]} {no color}<br />
{\externalfigure[demo-b][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-b][color=combicolor-b]} {spot color}<br />
{\externalfigure[demo-b][color=combicolor-y]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-a]} {no color}<br />
{\externalfigure[demo-a][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-a][color=blue-100]} {spot color}<br />
{\externalfigure[demo-a][color=yellow-100]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
<br />
\startbaselinecorrection<br />
\startcombination[4*1]<br />
{\externalfigure[demo-b]} {no color}<br />
{\externalfigure[demo-b][color=combicolor]} {indexed duotone}<br />
{\externalfigure[demo-b][color=blue-100]} {spot color}<br />
{\externalfigure[demo-b][color=yellow-100]} {spot color}<br />
\stopcombination<br />
\stopbaselinecorrection<br />
\stopbuffer<br />
<br />
\getbuffer \typebuffer<br />
<br />
\stoptext<br />
</texcode><br />
<br />
= Colors with Hexadecimal Numbers =<br />
<br />
You can also use hexadecimal numers to specify colors. You need to load the '''hex''' color module first:<br />
<texcode><br />
\setupcolor[hex]<br />
</texcode><br />
and then you may define colors with<br />
<texcode><br />
\definecolor[hex-red][h=FF0000]<br />
</texcode></div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Fonts_in_LuaTeX&diff=9791Fonts in LuaTeX2009-06-01T09:03:36Z<p>Nicolas Girard: /* Old contents */ Added link</p>
<hr />
<div>{{note|This page is not finished yet}}<br />
<br />
'''Please, someone, fill this page !'''<br />
<br />
'''This page is beeing regorganized'''<br />
<br />
= Getting access to the system fonts =<br />
<br />
LuaTeX can use non-TeX fonts (in OpenType, TrueType or Type1 format) directly.<br />
<br />
The first time that you run<br />
<br />
context myfile.tex<br />
<br />
on a file that uses such non-traditional fonts (which is probably always), the actual fonts themselves have to be loaded in luatex's embedded section of fontforge to extract their metric information. This removes the need for tfm and vf files on your disk, but it is also a somewhat lengthy and often memory-hungry process.<br />
<br />
That is why the results of that internal preprocessing are also saved inside the texmf cache. Future runs using the same font (not just this file, but all files using that particular font) can then use the cached version of the metrics instead. <br />
<br />
== Building the font database ==<br />
<br />
You need to specify where the fonts should be looked for, by setting the <code>OSFONTDIR</code> environment variable. For instance,<br />
set OSFONTDIR=c:/windows/fonts/<br />
if the fonts should be found in <code>c:/windows/fonts/</code>; or<br />
export OSFONTDIR="/usr/local/share/fonts;$HOME/.fonts"<br />
if the fonts should be found in both <code>/usr/local/share/fonts</code> and <code>$HOME/.fonts</code>.<br />
<br />
The font database will then be automatically generated in the next run of <code>context</code><br />
<br />
You can also generate it manually by typing <br />
mtxrun --script font --reload<br />
or equally<br />
mtxrun --script fonts --reload<br />
<br />
The output should look like<br />
MTXrun | fontnames: identifying tree font files with suffix otf<br />
MTXrun | fontnames: identifying tree font files with suffix OTF<br />
MTXrun | fontnames: 331 tree files identified, 332 hash entries added, runtime 7.653 seconds<br />
MTXrun | fontnames: identifying tree font files with suffix ttf<br />
MTXrun | fontnames: identifying tree font files with suffix TTF<br />
MTXrun | fontnames: 17 tree files identified, 14 hash entries added, runtime 4.645 seconds<br />
...<br />
MTXrun | fontnames: 94 system files identified, 94 hash entries added, runtime 0.554 seconds<br />
MTXrun | fontnames: 3837 files read, 3342 normal and 49 extra entries added, 5 rejected, 3386 valid<br />
<br />
<br />
<br />
== Querying the font database ==<br />
<br />
The command<br />
mtxrun --script fonts --list<br />
will return the whole entries of the font database as a list, such as<br />
<br />
...<br />
warnockprobold WarnockPro-Bold E:/Fonts/Warnock Pro/WarnockPro-Bold.otf<br />
warnockproboldcapt WarnockPro-BoldCapt E:/Fonts/Warnock Pro/WarnockPro-BoldCapt.otf<br />
warnockprobolddisp WarnockPro-BoldDisp E:/Fonts/Warnock Pro/WarnockPro-BoldDisp.otf<br />
warnockproboldit WarnockPro-BoldIt E:/Fonts/Warnock Pro/WarnockPro-BoldIt.otf<br />
warnockprobolditcapt WarnockPro-BoldItCapt E:/Fonts/Warnock Pro/WarnockPro-BoldItCapt.otf<br />
warnockprobolditdisp WarnockPro-BoldItDisp E:/Fonts/Warnock Pro/WarnockPro-BoldItDisp.otf<br />
warnockprobolditsubh WarnockPro-BoldItSubh E:/Fonts/Warnock Pro/WarnockPro-BoldItSubh.otf<br />
warnockproboldsubh WarnockPro-BoldSubh E:/Fonts/Warnock Pro/WarnockPro-BoldSubh.otf<br />
...<br />
<br />
You can query the database against a particular pattern. For instance,<br />
mtxrun --script fonts --list --pattern=Delicious*<br />
will return<br />
deliciousbold Delicious-Bold /usr/local/share/fonts/d/delicious_bold.otf<br />
deliciousbolditalic Delicious-BoldItalic /usr/local/share/fonts/d/delicious_bolditalic.otf<br />
deliciousheavy Delicious-Heavy /usr/local/share/fonts/d/delicious_heavy.otf<br />
deliciousitalic Delicious-Italic /usr/local/share/fonts/d/delicious_italic.otf<br />
deliciousroman Delicious-Roman /usr/local/share/fonts/d/delicious_roman.otf<br />
delicioussmallcaps Delicious-SmallCaps /usr/local/share/fonts/d/delicious_smallcaps.otf<br />
<br />
You can get useful informations about your fonts by using the <code>--info</code> option. For instance,<br />
mtxrun --script fonts --list --info --pattern=Delicious*Roman<br />
will return<br />
MTXrun | fontname: deliciousroman<br />
MTXrun | fullname: Delicious-Roman<br />
MTXrun | filename: /usr/local/share/fonts/d/delicious_roman.otf<br />
MTXrun |<br />
MTXrun | gpos features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | kern latn dflt<br />
MTXrun |<br />
MTXrun | gsub features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | tlig all all<br />
MTXrun | trep all all<br />
<br />
== Installing new fonts ==<br />
<br />
After installing new fonts, the font database must be rebuilt for LuaTeX to access them.<br />
<br />
In current versions of Mark IV (earlier than July 2008) this is automatically done whenever a named font cannot be found.<br />
<br />
You only have to do the reload manually when you have installed updates to already installed fonts that cause the font and/or file names to change. <br />
This normally only happens for fonts that are still in development like [[TeX Gyre]] and [[Latin Modern]].<br />
<br />
You can rebuild the database manually, using the already-mentioned command<br />
mtxrun --script fonts --reload<br />
<br />
Alternatively, you can turn off the automatic rebuild of the database, by setting either of<br />
MTX.FONTS.AUTOLOAD<br />
MTX_FONTS_AUTOLOAD<br />
to "no".<br />
<br />
== References ==<br />
<br />
[http://context.aanhet.net/svn/contextman/context-reference/en/co-fonts.pdf The new manual chapter on fonts]<br />
<br />
= Using fonts =<br />
<br />
Handling fonts in LuaTeX can be done<br />
* in a simple but limited way, using the <code>simplefonts</code> module;<br />
* in the standard way, using [[Typescripts]]<br />
<br />
== With the <code>simplefonts</code> module ==<br />
<br />
<code>simplefonts</code> is a third-party module written by Wolfgang Schuster.<br />
<br />
It simplifies the use of fonts in LuaTeX by<br />
* freeing the user from writing or using [[Typescripts]];<br />
* offering an interface similar to the [http://www.ctan.org/tex-archive/macros/xetex/latex/fontspec/ fontspec package for XeTeX]<br />
<br />
For instance, assuming the [http://www.josbuivenga.demon.nl/delicious.html Delicious fonts] are properly installed and recognized by ConTeXt, you can simply write:<br />
<br />
<texcode><br />
\usemodule[simplefonts] % load the module<br />
\setmainfont[Delicious] % set Delicious as main (serif) font<br />
<br />
\starttext<br />
\rm\tf roman \it italic \bf bold \bi bolditalic \sc smallcaps<br />
\stoptext<br />
</texcode><br />
<br />
== The standard way: Typescripts ==<br />
<br />
To be continued<br />
<br />
=== Where to find existing typescripts ===<br />
<br />
Each of the typescripts below defines a keyword to use with <cmd>setupbodyfont</cmd>. Usually this is the same as the name of the typescript, but there is one exception (<code>antykwa-torunska</code>)<br />
<br />
* Latin Modern (typescript name: <code>modern</code>; this is the default font set)<br />
* Latin Modern variant (ts name: <code>modernvariable</code>; LM variable typewriter for serif)<br />
* Postscript (ts name: <code>postscript</code>; Termes for serif, Heros for sans, Cursor for mono)<br />
* Antykwa Toruńska (ts name: <code>antykwa-torunska</code>; only serif; defines <tt>antykwa</tt> as keyword for <cmd>setupbodyfont</cmd>)<br />
* Iwona (ts name: <code>iwona</code>; only sans serif)<br />
* Iwona Light, Medium and Heavy (ts names: <code>iwona-light</code>, <code>iwona-medium</code>, <code>iwona-heavy</code>; only sans; the medium variant is a small bit heavier than a "regular" one)<br />
* Pagella (ts name: <code>palatino</code>; only serif)<br />
* Termes (ts name: <code>times</code>; only serif, Heros for sans)<br />
<br />
== Usage example ==<br />
<br />
<texcode><br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,18pt]<br />
<br />
\starttext<br />
Hello world, I'm Pagella!<br />
\stoptext<br />
</texcode><br />
<br />
The first line seems to order ConTeXt to "install" (for the current file) the given typescript (it accepts what I have earlier called a "typescript name"). The last one starts using it (you may omit the size if you are satisfied with the default).<br />
<br />
== Combining predefined fonts in your own typescripts ==<br />
<br />
It is also possible to combine fonts from the TeX Gyre collection in your own typescripts. The example below combines Bonum (Bookman) roman, Adventor (AvantGarde) for sans serif, Cursor (Courier) for teletype, and Euler for math. The <code>rscale=...</code> option ensures that all fonts have the same x-height. (You can lookup the relative x-heigt of a font using fontforge.)<br />
<br />
<texcode><br />
\starttypescript [Bonum]<br />
\definetypeface [Bonum] [rm] [serif] [bonum] [default]<br />
\definetypeface [Bonum] [ss] [sans] [adventor] [default] [rscale=0.887]<br />
\definetypeface [Bonum] [tt] [mono] [cursor] [default] [rscale=1.163]<br />
\definetypeface [Bonum] [mm] [math] [euler] [default] [rscale=1.050]<br />
\stoptypescript<br />
<br />
\usetypescript[Bonum]<br />
\setupbodyfont[Bonum,12pt]<br />
<br />
\starttext<br />
Hello world, I'm Bonum!<br />
\stoptext<br />
</texcode><br />
<br />
= Old contents =<br />
<br />
* [[TrueType fonts in luaTeX]]<br />
<br />
==== Good ol' typescripts ====<br />
<br />
Of course, Mark IV allows you to use typescripts as you've always done; for example:<br />
<br />
<texcode><br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,12pt]<br />
effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
<br />
\sc effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
</texcode><br />
<br />
That's as simple as using a traditional ConTeXt typescript!<br />
<br />
But ... how is it any different, then? Well, the difference is that in Mark IV, we can use an Opentype font directly, so that what is done here: when we want to use Palatino, the [[TeX Gyre]] equivalent (“Pagella”) is called and we can use its Opentype “features”; read on.<br />
<br />
==== Opentype features ====<br />
<br />
A “feature”, in the Opentype jargon, is a set of rules describing changes in the appearance of the text. Hmm, that's not very precise. Let's show some examples. First of all, you have to know that features are referred to by 4-letter tags, and you will see this a lot. One of them is ‘smcp‘, for “small caps“. Let's consider the following Mark IV-only code:<br />
<br />
<texcode><br />
\definefontfeature[smallcaps][language=DFLT,script=latn,smcp=yes]<br />
\font\palasmallcaps=texgyrepagella-regular*smallcaps<br />
\palasmallcaps This is a text in small capitals.<br />
</texcode><br />
<br />
Here you basically define a (Mark IV) feature with the name ”smallcaps”, and associate it with the (Opentype) feature “smcp”. You have to specify which script you want to use it with; scripts in Opentype are also tagged with four letters, and “latn” is of course Latin.<br />
<br />
Then you define a TeX font with that feature.<br />
<br />
You can see what features are defined in a particular font with the following bit of code<br />
<br />
<texcode><br />
\ctxlua<br />
{<br />
fontname = 'texgyrepagella-regular.otf'<br />
<br />
--[[ First read the font data.<br />
This makes heavy use of some of the Mark IV code]]<br />
tfmdata = fonts.tfm.read_and_define("file:" .. fontname, 655360)<br />
font = tfmdata.shared.otfdata<br />
if font<br />
then<br />
gsubfeatures = fonts.otf.analyze_features(font.gsub)<br />
gposfeatures = fonts.otf.analyze_features(font.gpos)<br />
end<br />
<br />
if gsubfeatures then<br />
table.sort(gsubfeatures) % We want our list sorted alphabetically!<br />
tex.sprint("\\rm GSUB features: \\tt ") % Beware: you don't want \rm to be interpreted by lua (\rm would yield carriage return + letter m)!<br />
for _, feat in ipairs(gsubfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GSUB features")<br />
end<br />
tex.sprint("\\par")<br />
<br />
if gposfeatures then<br />
tex.sprint("\\rm GPOS features: \\tt ")<br />
table.sort(gposfeatures)<br />
for _, feat in ipairs(gposfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GPOS features")<br />
end<br />
}<br />
</texcode><br />
<br />
It prints the list on the page. You'll notice there are two sets of features, each one of them defined in a different table of the Opentype font: the <code>GSUB</code> table (for Glyph SUBstitution) gives rules for replacing glyphs in certains circumstances (think of ligatures: f + i -> fi); the <code>GPOS</code> table (Glyph POSititioning) gives rules for moving glyphs (think of kerning: A + V -> A <kerning> V).<br />
<br />
Incidentally, the above code gives some basic examples of LuaTeX programming, a mixture of both Lua and TeX programming with some special features (features in the general sense, not the Opentype one :-).<br />
<br />
==== A (Complete) Typescript Example ====<br />
<br />
<texcode><br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [FranklinBookRegular] [name:FranklinGothicBookITC-Regular] [features=default]<br />
\definefontsynonym [FranklinMediumRegular] [name:FranklinGothicMediumITC-Regular] [features=default]<br />
\definefontsynonym [FranklinDemiRegular] [name:FranklinGothicDemiITC-Regular] [features=default]<br />
\definefontsynonym [FranklinHeavyRegular] [name:FranklinGothicHeavyITC-Regular] [features=default]<br />
<br />
\definefontsynonym [FranklinBookItalic] [name:FranklinGothicBookITC-Italic] [features=default]<br />
\definefontsynonym [FranklinDemiItalic] [name:FranklinGothicMediumITC-Italic] [features=default]<br />
\definefontsynonym [FranklinHeavyItalic] [name:FranklinGothicDemiITC-Italic] [features=default]<br />
\definefontsynonym [FranklinMediumItalic] [name:FranklinGothicHeavyITC-Italic] [features=default]<br />
<br />
\stoptypescript<br />
<br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [Sans] [FranklinBookRegular] [features=default]<br />
\definefontsynonym [SansItalic] [FranklinBookItalic] [features=default]<br />
\definefontsynonym [SansBold] [FranklinDemiRegular] [features=default]<br />
\definefontsynonym [SansBoldItalic] [FranklinDemiItalic] [features=default]<br />
\definefontsynonym [SansSlanted] [SansItalic] [features=default]<br />
\definefontsynonym [SansBoldSlanted] [SansBoldItalic] [features=default]<br />
\definefontsynonym [SansCaps] [Sans] [features=smallcaps]<br />
<br />
\stoptypescript<br />
<br />
\definetypeface[franklin][rm][sans][franklin][default]<br />
\definetypeface[franklin][ss][sans][franklin][default]<br />
\definetypeface[franklin][tt][mono][modern] [default][rscale=1.12]<br />
\definetypeface[franklin][mm][math][iwona] [default][rscale=1.02]<br />
<br />
\setupbodyfont[franklin,ss,10pt]<br />
</texcode><br />
<br />
<br />
<br />
Just the simplest way to use an otf font — or any font that does appear in <tt>mtxrun --script font --list</tt> — in all the document.<br />
<br />
I’m stick here :<br />
<br />
\definefontfeature [myfontfeature] [method=node, kern=yes, OTHER_FEATURE_COMMA_SEPERATED]<br />
\definefontsynonym [MyFontRegular] [name:TheFontName-Regular][features=myfontfeature]<br />
\definedfont [MyFontRegular at 16pt]<br />
<br />
This doesn’t run for my title which use « \tfc », only for the body of the text.<br />
<br />
*\definefontfeature<br />
**[myfontfeature] : you can use the name you want. It will be use at the next line ;<br />
**the fonts feature can be found with <tt>otfinfo -f TheFontFile.otf</tt>.<br />
*\definefontsynonym :<br />
**[MyFontRegular] : you can use the name you want. It will be use at the next line ;<br />
**The name after <tt>name:</tt> is the name given by <tt>mtxrun --script font --list</tt><br />
**The « name: » part can be replaced by <tt>file:TheFontFile.otf</tt><br />
<br />
<br />
== Example ==<br />
<br />
<br />
Now to access, say the regular warnock font, the following are valid. And I ought to mention that Hans recommends the first http://article.gmane.org/gmane.comp.tex.context/43685.<br />
<br />
<texcode><br />
% Hans recommends this format;<br />
\definefontsynonym [WarnockPro-Regular] [name:warnockproregular] <br />
</texcode><br />
<br />
and<br />
<br />
<texcode><br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular]<br />
</texcode><br />
<br />
An entire typescript would be defined as;<br />
<br />
<texcode><br />
\definefontfeature[latin-smallcaps][smallcaps][script=latn]<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\setups[font:fallback:sans]<br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular] <br />
\definefontsynonym [WarnockPro-Bold] [name:WarnockPro-Bold] <br />
\definefontsynonym [WarnockPro-Italic] [name:WarnockPro-It] <br />
\definefontsynonym [WarnockPro-BoldItalic] [name:WarnockPro-BoldIt] <br />
\stoptypescript<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\definefontsynonym [Serif] [WarnockPro-Regular] [features=default]<br />
\definefontsynonym [SerifBold] [WarnockPro-Bold] [features=default]<br />
\definefontsynonym [SerifItalic] [WarnockPro-Italic] [features=default]<br />
\definefontsynonym [SerifBoldItalic] [WarnockPro-BoldItalic] [features=default]<br />
\definefontsynonym [SerifCaps] [Serif] [features=latin-smallcaps]<br />
\stoptypescript<br />
<br />
\definetypeface[adobe][rm][serif][warnockpro][default]<br />
\setupbodyfont[adobe,11pt]<br />
<br />
</texcode><br />
<br />
[[Category:Fonts]]<br />
[[Category:International]]</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Fonts_-_Old_Content&diff=9788Fonts - Old Content2009-06-01T08:49:51Z<p>Nicolas Girard: /* Unsorted links */ Dead link</p>
<hr />
<div>< [[Visuals]] | [[Symbols]] ><br />
<br />
= Where to find fonts =<br />
<br />
== Available Free Fonts ==<br />
* [http://ctan.tug.org/tex-archive/info/Free_Math_Font_Survey/survey.html Free Math Fonts] : overview of different free Math fonts; [http://www.geocities.com/hartke01/ links to other free fonts]<br />
* [http://greekfontsociety.org/ GFS Didot] : Latin, full set of polytonik Greek, small caps, oldstyle figures, full f-ligatures ([http://modules.contextgarden.net/gfsdidot Module for ConTeXt])<br />
* [[TeX Gyre]] : a set of great text fonts by our GUST friends, based on URW's free PostScript standard fonts for GhostScript.<br />
* [http://www.janusz.nowacki.strefa.pl/kurier.html Foto Alfa] : some TeX related fonts from Poland (Antykwa Toruńska. Antykwa Półtawskiego, Kurier, Iwona...)<br />
* [http://linuxlibertine.sourceforge.net Libertine Open Fonts Project]: GPL/OFL serif font<br />
* [http://scripts.sil.org SIL International] : great Unicode fonts for scholars by SIL (Gentium, Doulos, Charis, etc.)<br />
* [http://ist-socrates.berkeley.edu/~pinax/greekkeys/GreekKeys.html GreekKeys] : links to polytonic Greek fonts<br />
* [http://scholarsfonts.net Scholar's Fonts] : Font for Scholars (Latin, Germanic languages, Greek, Hebrew and Linguistics)<br />
* [http://www.engl.virginia.edu/OE/junicode/junicode.html Junicode] : Junius-Unicode, a font for medievalists<br />
* [http://www.freelang.net/fonts/index.html FreeLang fonts] : fonts for exotic languages<br />
* [http://www.blambot.com Blambot] : Comic fonts<br />
* [http://www.chank.com/freefonts.php Chank] : some free Chank fonts<br />
* [http://www.fontface.com/fonts/ FontFace] : free fonts<br />
* [http://www.dafont.com DaFont] : more free fonts<br />
* [http://fonts.tom7.com/fonts98.html Divide by Zero] : more fonts<br />
* [http://moorstation.org/typoasis/typoasis1.htm TypOasis] : lots of nice fonts, but a bit hard to find (have a look at designers Apostrophic Lab, Manfred Klein and Dieter Steffmann)<br />
* [http://kadyellebee.com/fonts/ Kristine's Font Organization] : find a font in a sorted directory<br />
* [http://www.fontlover.com FontLover] : font news portal site<br />
* [http://www.stormtype.com/typefaces-fonts-shop/free.php Lido] : OpenType and TrueType typeface by Storm Type Foundry, free for non-commercial use. [http://modules.contextgarden.net/stormfontsupport Support].<br />
* [http://www.alanwood.net/unicode/fontsbyrange.html Alan Wood’s Unicode Resources] : find fonts by Unicode character range<br />
* [http://www.josbuivenga.demon.nl/ exljbris] Free Quality Font Foundry by Jos Buivenga<br />
* [http://www.stixfonts.org/ STIX Fonts] Beta download of the STIX-Fonts<br />
* ''... many more to be added ...''<br />
<br />
= How to use fonts in ConTeXt =<br />
'''The ConTeXt way of handling fonts are [[TypeScripts]].''' It’s a system of abstraction and aliases, which may seem “strange” at first for LaTeX users.<br />
* If you happen to use [[XeTeX]] then you can forget almost all the magic and start using your system fonts (see [[Fonts_in_XeTeX]]).<br />
* If you use [[LuaTeX]], see [[Fonts_in_LuaTex]]<br />
* If you want to keep using [[pdfTeX]], read on.<br />
<br />
<br />
= Font support & configuration =<br />
== Type 1 fonts ==<br />
* Using [[psnfss]] metrics in ConTeXt<br />
* Matt Gushee's introduction to [http://havenrock.com/textips/bookfonts.html virtual fonts], especially for getting expert fonts to work.<br />
* [[URW Garamond]]<br />
* [[Lucida]] : large font family designed by Bigelow & Holmes; suitable e.g. for presentations<br />
* [http://dl.contextgarden.net/myway/expertfonts.pdf Installing Expert Fonts: Minion Pro] by Idris Samawi Hamid; contains step-by-step instructions, from preinstallation to writing typescripts<br />
* [http://www.stormtype.com Storm Type Foundry] : [http://modules.contextgarden.net/stormfontsupport support] of selected fonts<br />
<br />
== True Type fonts ==<br />
* [http://tug.org/pracjourn/2005-2/schmitz/schmitz.pdf Integrating TrueType Fonts into ConTeXt] by Thomas A. Schmitz (PracTeX Journal)<br />
* [[Installing a TrueType font, step by step]]. If you just need to install a TrueType font, this may be what you are looking for.<br />
<br />
== OpenType fonts ==<br />
* [[otfinstall|otfinst - a script for using OpenType fonts in ConTeXt]]<br />
<br />
== Basic Hints ==<br />
<br />
''Some hints by Taco from the mailing list on 2005-11-20:''<br />
<br />
Q: How up to date or out of date is the information in [http://www.pragma-ade.com/general/manuals/mfonts.pdf mfonts manual]?<br />
<br />
A: It looks like it is still quite up-to-date, but some of the examples it gives may no longer be the very best and latest way of doing things, and possibly there are some new developments that do not get as much attention as desired (like [http://www.pragma-ade.com/general/manuals/mtexfont.pdf texfont], and the issues arising from font map files). Overall, the document appears accurate, though.<br />
<br />
An important thing to remember is this:<br />
<br />
'''ConTeXt does not share font metric conventions with LaTeX.'''<br />
<br />
(at one point it started doing so, like supporting the ''Karl Berry naming scheme'' and the ''PSNFSS'' style font family names, but that has since been abandoned).<br />
<br />
Another important thing is that it also does not share font map files with LaTeX and, specifically,<br />
<br />
'''ConTeXt does not make pdfetex read <tt>pdftex.map</tt>.'''<br />
<br />
(this is at the root of a great many problems reported by users only familiar with PSNFSS)<br />
<br />
The preferred format for metric files in ConTeXt is<br />
<br />
<tt><vendor>/<familyname>/<encoding>-<fontname>.tfm</tt><br />
<br />
for metrics and<br />
<br />
<tt><encoding>-<vendor>-<familyname>.map</tt><br />
<br />
for the mapping files.<br />
<br />
* <fontname> is usually derived from the font source (afm or ttf),<br />
* <encoding> is a 'controlled' list, (see [[Encodings and Regimes]])<br />
* <vendor> and <familyname> are user-supplied (at install time).<br />
<br />
There are ways to trick ConTeXt into using different conventions, but if you do that you are likely to run into trouble.<br />
<br />
== Hints by Language ==<br />
* general: [[Encodings and Regimes]]<br />
* [[Arabic and Hebrew]] (Idris? other ArabTeX specialists?)<br />
* [[Chinese]]<br />
* [[Czech]]<br />
* [[Greek]]<br />
* [[Russian]]<br />
* [[Vietnamese]]<br />
<br />
= Unsorted links =<br />
<br />
* [http://www.pragma-ade.com/general/manuals/mtexfont.pdf font installation with texfont] by Pragma<br />
* [http://www.pragma-ade.com/general/manuals/mfonts.pdf ConTeXt's font mechanism in detail] by Pragma<br />
* [http://tug.org/TUGboat/Articles/tb28-2/tb89mahajan.pdf ConTeXt basics for users: Font styles] by Aditya Mahajan (2007)<br />
* [http://www.pragma-ade.com/general/manuals/mmakempy.pdf making outlines] by Pragma<br />
* [http://pragma-ade.com/specials/fonts/fontspecial-p.pdf Here] you can try out several TeX fonts online (PDF interface!)<br />
* Troubleshooting: solving [[TeXfont]] problems.<br />
* Character [[Protrusion]] (also known as hanging or font handling) is a more subtle typographic effect.<br />
* [[Font Handling Internals]]<br />
* [http://watershade.net/wmcclain/context-help.html Bill McClain's ConTeXt beginners page] has also a lot about fonts<br />
* [[Pseudo Small Caps]] by Vit Zyka<br />
* [[Understanding how fonts work in ConTeXt]]<br />
* Fonts rely on [[Encodings and Regimes]], and it helps to know what happens underneath the hood, from time to time.<br />
* In newer distributions, map files belong in <tt>&hellip;/fonts/map/pdftex/context</tt>!<br />
* Don't forget to look at [[cont-sys.tex]]!<br />
<br />
<br />
[[Category:Fonts]]</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Fonts_-_Old_Content&diff=9787Fonts - Old Content2009-06-01T08:49:02Z<p>Nicolas Girard: +section: OpenType</p>
<hr />
<div>< [[Visuals]] | [[Symbols]] ><br />
<br />
= Where to find fonts =<br />
<br />
== Available Free Fonts ==<br />
* [http://ctan.tug.org/tex-archive/info/Free_Math_Font_Survey/survey.html Free Math Fonts] : overview of different free Math fonts; [http://www.geocities.com/hartke01/ links to other free fonts]<br />
* [http://greekfontsociety.org/ GFS Didot] : Latin, full set of polytonik Greek, small caps, oldstyle figures, full f-ligatures ([http://modules.contextgarden.net/gfsdidot Module for ConTeXt])<br />
* [[TeX Gyre]] : a set of great text fonts by our GUST friends, based on URW's free PostScript standard fonts for GhostScript.<br />
* [http://www.janusz.nowacki.strefa.pl/kurier.html Foto Alfa] : some TeX related fonts from Poland (Antykwa Toruńska. Antykwa Półtawskiego, Kurier, Iwona...)<br />
* [http://linuxlibertine.sourceforge.net Libertine Open Fonts Project]: GPL/OFL serif font<br />
* [http://scripts.sil.org SIL International] : great Unicode fonts for scholars by SIL (Gentium, Doulos, Charis, etc.)<br />
* [http://ist-socrates.berkeley.edu/~pinax/greekkeys/GreekKeys.html GreekKeys] : links to polytonic Greek fonts<br />
* [http://scholarsfonts.net Scholar's Fonts] : Font for Scholars (Latin, Germanic languages, Greek, Hebrew and Linguistics)<br />
* [http://www.engl.virginia.edu/OE/junicode/junicode.html Junicode] : Junius-Unicode, a font for medievalists<br />
* [http://www.freelang.net/fonts/index.html FreeLang fonts] : fonts for exotic languages<br />
* [http://www.blambot.com Blambot] : Comic fonts<br />
* [http://www.chank.com/freefonts.php Chank] : some free Chank fonts<br />
* [http://www.fontface.com/fonts/ FontFace] : free fonts<br />
* [http://www.dafont.com DaFont] : more free fonts<br />
* [http://fonts.tom7.com/fonts98.html Divide by Zero] : more fonts<br />
* [http://moorstation.org/typoasis/typoasis1.htm TypOasis] : lots of nice fonts, but a bit hard to find (have a look at designers Apostrophic Lab, Manfred Klein and Dieter Steffmann)<br />
* [http://kadyellebee.com/fonts/ Kristine's Font Organization] : find a font in a sorted directory<br />
* [http://www.fontlover.com FontLover] : font news portal site<br />
* [http://www.stormtype.com/typefaces-fonts-shop/free.php Lido] : OpenType and TrueType typeface by Storm Type Foundry, free for non-commercial use. [http://modules.contextgarden.net/stormfontsupport Support].<br />
* [http://www.alanwood.net/unicode/fontsbyrange.html Alan Wood’s Unicode Resources] : find fonts by Unicode character range<br />
* [http://www.josbuivenga.demon.nl/ exljbris] Free Quality Font Foundry by Jos Buivenga<br />
* [http://www.stixfonts.org/ STIX Fonts] Beta download of the STIX-Fonts<br />
* ''... many more to be added ...''<br />
<br />
= How to use fonts in ConTeXt =<br />
'''The ConTeXt way of handling fonts are [[TypeScripts]].''' It’s a system of abstraction and aliases, which may seem “strange” at first for LaTeX users.<br />
* If you happen to use [[XeTeX]] then you can forget almost all the magic and start using your system fonts (see [[Fonts_in_XeTeX]]).<br />
* If you use [[LuaTeX]], see [[Fonts_in_LuaTex]]<br />
* If you want to keep using [[pdfTeX]], read on.<br />
<br />
<br />
= Font support & configuration =<br />
== Type 1 fonts ==<br />
* Using [[psnfss]] metrics in ConTeXt<br />
* Matt Gushee's introduction to [http://havenrock.com/textips/bookfonts.html virtual fonts], especially for getting expert fonts to work.<br />
* [[URW Garamond]]<br />
* [[Lucida]] : large font family designed by Bigelow & Holmes; suitable e.g. for presentations<br />
* [http://dl.contextgarden.net/myway/expertfonts.pdf Installing Expert Fonts: Minion Pro] by Idris Samawi Hamid; contains step-by-step instructions, from preinstallation to writing typescripts<br />
* [http://www.stormtype.com Storm Type Foundry] : [http://modules.contextgarden.net/stormfontsupport support] of selected fonts<br />
<br />
== True Type fonts ==<br />
* [http://tug.org/pracjourn/2005-2/schmitz/schmitz.pdf Integrating TrueType Fonts into ConTeXt] by Thomas A. Schmitz (PracTeX Journal)<br />
* [[Installing a TrueType font, step by step]]. If you just need to install a TrueType font, this may be what you are looking for.<br />
<br />
== OpenType fonts ==<br />
* [[otfinstall|otfinst - a script for using OpenType fonts in ConTeXt]]<br />
<br />
== Basic Hints ==<br />
<br />
''Some hints by Taco from the mailing list on 2005-11-20:''<br />
<br />
Q: How up to date or out of date is the information in [http://www.pragma-ade.com/general/manuals/mfonts.pdf mfonts manual]?<br />
<br />
A: It looks like it is still quite up-to-date, but some of the examples it gives may no longer be the very best and latest way of doing things, and possibly there are some new developments that do not get as much attention as desired (like [http://www.pragma-ade.com/general/manuals/mtexfont.pdf texfont], and the issues arising from font map files). Overall, the document appears accurate, though.<br />
<br />
An important thing to remember is this:<br />
<br />
'''ConTeXt does not share font metric conventions with LaTeX.'''<br />
<br />
(at one point it started doing so, like supporting the ''Karl Berry naming scheme'' and the ''PSNFSS'' style font family names, but that has since been abandoned).<br />
<br />
Another important thing is that it also does not share font map files with LaTeX and, specifically,<br />
<br />
'''ConTeXt does not make pdfetex read <tt>pdftex.map</tt>.'''<br />
<br />
(this is at the root of a great many problems reported by users only familiar with PSNFSS)<br />
<br />
The preferred format for metric files in ConTeXt is<br />
<br />
<tt><vendor>/<familyname>/<encoding>-<fontname>.tfm</tt><br />
<br />
for metrics and<br />
<br />
<tt><encoding>-<vendor>-<familyname>.map</tt><br />
<br />
for the mapping files.<br />
<br />
* <fontname> is usually derived from the font source (afm or ttf),<br />
* <encoding> is a 'controlled' list, (see [[Encodings and Regimes]])<br />
* <vendor> and <familyname> are user-supplied (at install time).<br />
<br />
There are ways to trick ConTeXt into using different conventions, but if you do that you are likely to run into trouble.<br />
<br />
== Hints by Language ==<br />
* general: [[Encodings and Regimes]]<br />
* [[Arabic and Hebrew]] (Idris? other ArabTeX specialists?)<br />
* [[Chinese]]<br />
* [[Czech]]<br />
* [[Greek]]<br />
* [[Russian]]<br />
* [[Vietnamese]]<br />
<br />
= Unsorted links =<br />
<br />
* [http://www.pragma-ade.com/general/manuals/mtexfont.pdf font installation with texfont] by Pragma<br />
* [http://www.pragma-ade.com/general/manuals/mfonts.pdf ConTeXt's font mechanism in detail] by Pragma<br />
* [http://tug.org/TUGboat/Articles/tb28-2/tb89mahajan.pdf ConTeXt basics for users: Font styles] by Aditya Mahajan (2007)<br />
* [http://www.pragma-ade.com/general/manuals/mmakempy.pdf making outlines] by Pragma<br />
* [http://pragma-ade.com/specials/fonts/fontspecial-p.pdf Here] you can try out several TeX fonts online (PDF interface!)<br />
* Troubleshooting: solving [[TeXfont]] problems.<br />
* Character [[Protrusion]] (also known as hanging or font handling) is a more subtle typographic effect.<br />
* [[Font Handling Internals]]<br />
* [http://homepage.mac.com/atl/tex/ Adam Lindsay's page] focuses on typography (OpenType, Unicode etc.), esp. on MacOS X<br />
* [http://watershade.net/wmcclain/context-help.html Bill McClain's ConTeXt beginners page] has also a lot about fonts<br />
* [[Pseudo Small Caps]] by Vit Zyka<br />
* [[Understanding how fonts work in ConTeXt]]<br />
* Fonts rely on [[Encodings and Regimes]], and it helps to know what happens underneath the hood, from time to time.<br />
* In newer distributions, map files belong in <tt>&hellip;/fonts/map/pdftex/context</tt>!<br />
* Don't forget to look at [[cont-sys.tex]]!<br />
<br />
<br />
[[Category:Fonts]]</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Fonts_-_Old_Content&diff=9786Fonts - Old Content2009-06-01T08:40:12Z<p>Nicolas Girard: Reorganized contents</p>
<hr />
<div>< [[Visuals]] | [[Symbols]] ><br />
<br />
= Where to find fonts =<br />
<br />
== Available Free Fonts ==<br />
* [http://ctan.tug.org/tex-archive/info/Free_Math_Font_Survey/survey.html Free Math Fonts] : overview of different free Math fonts; [http://www.geocities.com/hartke01/ links to other free fonts]<br />
* [http://greekfontsociety.org/ GFS Didot] : Latin, full set of polytonik Greek, small caps, oldstyle figures, full f-ligatures ([http://modules.contextgarden.net/gfsdidot Module for ConTeXt])<br />
* [[TeX Gyre]] : a set of great text fonts by our GUST friends, based on URW's free PostScript standard fonts for GhostScript.<br />
* [http://www.janusz.nowacki.strefa.pl/kurier.html Foto Alfa] : some TeX related fonts from Poland (Antykwa Toruńska. Antykwa Półtawskiego, Kurier, Iwona...)<br />
* [http://linuxlibertine.sourceforge.net Libertine Open Fonts Project]: GPL/OFL serif font<br />
* [http://scripts.sil.org SIL International] : great Unicode fonts for scholars by SIL (Gentium, Doulos, Charis, etc.)<br />
* [http://ist-socrates.berkeley.edu/~pinax/greekkeys/GreekKeys.html GreekKeys] : links to polytonic Greek fonts<br />
* [http://scholarsfonts.net Scholar's Fonts] : Font for Scholars (Latin, Germanic languages, Greek, Hebrew and Linguistics)<br />
* [http://www.engl.virginia.edu/OE/junicode/junicode.html Junicode] : Junius-Unicode, a font for medievalists<br />
* [http://www.freelang.net/fonts/index.html FreeLang fonts] : fonts for exotic languages<br />
* [http://www.blambot.com Blambot] : Comic fonts<br />
* [http://www.chank.com/freefonts.php Chank] : some free Chank fonts<br />
* [http://www.fontface.com/fonts/ FontFace] : free fonts<br />
* [http://www.dafont.com DaFont] : more free fonts<br />
* [http://fonts.tom7.com/fonts98.html Divide by Zero] : more fonts<br />
* [http://moorstation.org/typoasis/typoasis1.htm TypOasis] : lots of nice fonts, but a bit hard to find (have a look at designers Apostrophic Lab, Manfred Klein and Dieter Steffmann)<br />
* [http://kadyellebee.com/fonts/ Kristine's Font Organization] : find a font in a sorted directory<br />
* [http://www.fontlover.com FontLover] : font news portal site<br />
* [http://www.stormtype.com/typefaces-fonts-shop/free.php Lido] : OpenType and TrueType typeface by Storm Type Foundry, free for non-commercial use. [http://modules.contextgarden.net/stormfontsupport Support].<br />
* [http://www.alanwood.net/unicode/fontsbyrange.html Alan Wood’s Unicode Resources] : find fonts by Unicode character range<br />
* [http://www.josbuivenga.demon.nl/ exljbris] Free Quality Font Foundry by Jos Buivenga<br />
* [http://www.stixfonts.org/ STIX Fonts] Beta download of the STIX-Fonts<br />
* ''... many more to be added ...''<br />
<br />
= How to use fonts in ConTeXt =<br />
'''The ConTeXt way of handling fonts are [[TypeScripts]].''' It’s a system of abstraction and aliases, which may seem “strange” at first for LaTeX users.<br />
* If you happen to use [[XeTeX]] then you can forget almost all the magic and start using your system fonts (see [[Fonts_in_XeTeX]]).<br />
* If you use [[LuaTeX]], see [[Fonts_in_LuaTex]]<br />
* If you want to keep using [[pdfTeX]], read on.<br />
<br />
<br />
= Font support & configuration =<br />
== Type 1 fonts ==<br />
* Using [[psnfss]] metrics in ConTeXt<br />
* Matt Gushee's introduction to [http://havenrock.com/textips/bookfonts.html virtual fonts], especially for getting expert fonts to work.<br />
* [[URW Garamond]]<br />
* [[Lucida]] : large font family designed by Bigelow & Holmes; suitable e.g. for presentations<br />
* [http://dl.contextgarden.net/myway/expertfonts.pdf Installing Expert Fonts: Minion Pro] by Idris Samawi Hamid; contains step-by-step instructions, from preinstallation to writing typescripts<br />
* [http://www.stormtype.com Storm Type Foundry] : [http://modules.contextgarden.net/stormfontsupport support] of selected fonts<br />
<br />
== True Type fonts ==<br />
* [http://tug.org/pracjourn/2005-2/schmitz/schmitz.pdf Integrating TrueType Fonts into ConTeXt] by Thomas A. Schmitz (PracTeX Journal)<br />
* [[Installing a TrueType font, step by step]]. If you just need to install a TrueType font, this may be what you are looking for.<br />
<br />
== Basic Hints ==<br />
<br />
''Some hints by Taco from the mailing list on 2005-11-20:''<br />
<br />
Q: How up to date or out of date is the information in [http://www.pragma-ade.com/general/manuals/mfonts.pdf mfonts manual]?<br />
<br />
A: It looks like it is still quite up-to-date, but some of the examples it gives may no longer be the very best and latest way of doing things, and possibly there are some new developments that do not get as much attention as desired (like [http://www.pragma-ade.com/general/manuals/mtexfont.pdf texfont], and the issues arising from font map files). Overall, the document appears accurate, though.<br />
<br />
An important thing to remember is this:<br />
<br />
'''ConTeXt does not share font metric conventions with LaTeX.'''<br />
<br />
(at one point it started doing so, like supporting the ''Karl Berry naming scheme'' and the ''PSNFSS'' style font family names, but that has since been abandoned).<br />
<br />
Another important thing is that it also does not share font map files with LaTeX and, specifically,<br />
<br />
'''ConTeXt does not make pdfetex read <tt>pdftex.map</tt>.'''<br />
<br />
(this is at the root of a great many problems reported by users only familiar with PSNFSS)<br />
<br />
The preferred format for metric files in ConTeXt is<br />
<br />
<tt><vendor>/<familyname>/<encoding>-<fontname>.tfm</tt><br />
<br />
for metrics and<br />
<br />
<tt><encoding>-<vendor>-<familyname>.map</tt><br />
<br />
for the mapping files.<br />
<br />
* <fontname> is usually derived from the font source (afm or ttf),<br />
* <encoding> is a 'controlled' list, (see [[Encodings and Regimes]])<br />
* <vendor> and <familyname> are user-supplied (at install time).<br />
<br />
There are ways to trick ConTeXt into using different conventions, but if you do that you are likely to run into trouble.<br />
<br />
== Hints by Language ==<br />
* general: [[Encodings and Regimes]]<br />
* [[Arabic and Hebrew]] (Idris? other ArabTeX specialists?)<br />
* [[Chinese]]<br />
* [[Czech]]<br />
* [[Greek]]<br />
* [[Russian]]<br />
* [[Vietnamese]]<br />
<br />
= Unsorted links =<br />
<br />
* [http://www.pragma-ade.com/general/manuals/mtexfont.pdf font installation with texfont] by Pragma<br />
* [http://www.pragma-ade.com/general/manuals/mfonts.pdf ConTeXt's font mechanism in detail] by Pragma<br />
* [http://tug.org/TUGboat/Articles/tb28-2/tb89mahajan.pdf ConTeXt basics for users: Font styles] by Aditya Mahajan (2007)<br />
* [http://www.pragma-ade.com/general/manuals/mmakempy.pdf making outlines] by Pragma<br />
* [http://pragma-ade.com/specials/fonts/fontspecial-p.pdf Here] you can try out several TeX fonts online (PDF interface!)<br />
* Troubleshooting: solving [[TeXfont]] problems.<br />
* Character [[Protrusion]] (also known as hanging or font handling) is a more subtle typographic effect.<br />
* [[Font Handling Internals]]<br />
* [http://homepage.mac.com/atl/tex/ Adam Lindsay's page] focuses on typography (OpenType, Unicode etc.), esp. on MacOS X<br />
* [http://watershade.net/wmcclain/context-help.html Bill McClain's ConTeXt beginners page] has also a lot about fonts<br />
* [[Pseudo Small Caps]] by Vit Zyka<br />
* [[otfinstall|otfinst - a sample ruby script for using OpenType fonts in ConTeXt]]<br />
* [[Understanding how fonts work in ConTeXt]]<br />
* Fonts rely on [[Encodings and Regimes]], and it helps to know what happens underneath the hood, from time to time.<br />
* In newer distributions, map files belong in <tt>&hellip;/fonts/map/pdftex/context</tt>!<br />
* Don't forget to look at [[cont-sys.tex]]!<br />
<br />
<br />
[[Category:Fonts]]</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Fonts_-_Old_Content&diff=9785Fonts - Old Content2009-06-01T07:53:43Z<p>Nicolas Girard: /* Unsorted links */ removed link to A Beginner's Guide to Using Fonts in Mark IV</p>
<hr />
<div>< [[Visuals]] | [[Symbols]] ><br />
<br />
'''The ConTeXt way of handling fonts are [[TypeScripts]].''' It’s a system of abstraction and aliases, which may seem “strange” at first for LaTeX users.<br />
* If you happen to use [[XeTeX]] then you can forget almost all the magic and start using your system fonts (see [[Fonts_in_XeTeX]]).<br />
* If you use [[LuaTeX]], see [[Fonts_in_LuaTex]]<br />
* If you want to keep using [[pdfTeX]], read on.<br />
<br />
= Unsorted links =<br />
<br />
* [http://www.pragma-ade.com/general/manuals/mtexfont.pdf font installation with texfont] by Pragma<br />
* [http://www.pragma-ade.com/general/manuals/mfonts.pdf ConTeXt's font mechanism in detail] by Pragma<br />
* [http://tug.org/TUGboat/Articles/tb28-2/tb89mahajan.pdf ConTeXt basics for users: Font styles] by Aditya Mahajan (2007)<br />
* [http://www.pragma-ade.com/general/manuals/mmakempy.pdf making outlines] by Pragma<br />
* [http://pragma-ade.com/specials/fonts/fontspecial-p.pdf Here] you can try out several TeX fonts online (PDF interface!)<br />
* Troubleshooting: solving [[TeXfont]] problems.<br />
* Character [[Protrusion]] (also known as hanging or font handling) is a more subtle typographic effect.<br />
* [[Font Handling Internals]]<br />
* [http://homepage.mac.com/atl/tex/ Adam Lindsay's page] focuses on typography (OpenType, Unicode etc.), esp. on MacOS X<br />
* [http://watershade.net/wmcclain/context-help.html Bill McClain's ConTeXt beginners page] has also a lot about fonts<br />
* [http://tug.org/pracjourn/2005-2/schmitz/schmitz.pdf Integrating TrueType Fonts into ConTeXt] by Thomas A. Schmitz (PracTeX Journal)<br />
* [[Installing a TrueType font, step by step]]. If you just need to install a TrueType font, this may be what you are looking for.<br />
* [http://dl.contextgarden.net/myway/expertfonts.pdf Installing Expert Fonts: Minion Pro] by Idris Samawi Hamid; contains step-by-step instructions, from preinstallation to writing typescripts<br />
* [[Pseudo Small Caps]] by Vit Zyka<br />
* Matt Gushee's introduction to [http://havenrock.com/textips/bookfonts.html virtual fonts], especially for getting expert fonts to work.<br />
* [[URW Garamond]]<br />
* [[otfinstall|otfinst - a sample ruby script for using OpenType fonts in ConTeXt]]<br />
* [[Understanding how fonts work in ConTeXt]]<br />
<br />
=Basic Hints=<br />
<br />
''Some hints by Taco from the mailing list on 2005-11-20:''<br />
<br />
Q: How up to date or out of date is the information in [http://www.pragma-ade.com/general/manuals/mfonts.pdf mfonts manual]?<br />
<br />
A: It looks like it is still quite up-to-date, but some of the examples it gives may no longer be the very best and latest way of doing things, and possibly there are some new developments that do not get as much attention as desired (like [http://www.pragma-ade.com/general/manuals/mtexfont.pdf texfont], and the issues arising from font map files). Overall, the document appears accurate, though.<br />
<br />
An important thing to remember is this:<br />
<br />
'''ConTeXt does not share font metric conventions with LaTeX.'''<br />
<br />
(at one point it started doing so, like supporting the ''Karl Berry naming scheme'' and the ''PSNFSS'' style font family names, but that has since been abandoned).<br />
<br />
Another important thing is that it also does not share font map files with LaTeX and, specifically,<br />
<br />
'''ConTeXt does not make pdfetex read <tt>pdftex.map</tt>.'''<br />
<br />
(this is at the root of a great many problems reported by users only familiar with PSNFSS)<br />
<br />
The preferred format for metric files in ConTeXt is<br />
<br />
<tt><vendor>/<familyname>/<encoding>-<fontname>.tfm</tt><br />
<br />
for metrics and<br />
<br />
<tt><encoding>-<vendor>-<familyname>.map</tt><br />
<br />
for the mapping files.<br />
<br />
* <fontname> is usually derived from the font source (afm or ttf),<br />
* <encoding> is a 'controlled' list, (see [[Encodings and Regimes]])<br />
* <vendor> and <familyname> are user-supplied (at install time).<br />
<br />
There are ways to trick ConTeXt into using different conventions, but if you do that you are likely to run into trouble.<br />
<br />
=Configuration=<br />
* Using [[psnfss]] metrics in ConTeXt<br />
* Matt Gushee about [http://havenrock.com/textips/bookfonts.html virtual fonts]<br />
* Fonts rely on [[Encodings and Regimes]], and it helps to know what happens underneath the hood, from time to time.<br />
* In newer distributions, map files belong in <tt>&hellip;/fonts/map/pdftex/context</tt>!<br />
* Don't forget to look at [[cont-sys.tex]]!<br />
<br />
= Available Free Fonts =<br />
* [http://ctan.tug.org/tex-archive/info/Free_Math_Font_Survey/survey.html Free Math Fonts] : overview of different free Math fonts; [http://www.geocities.com/hartke01/ links to other free fonts]<br />
* [http://greekfontsociety.org/ GFS Didot] : Latin, full set of polytonik Greek, small caps, oldstyle figures, full f-ligatures ([http://modules.contextgarden.net/gfsdidot Module for ConTeXt])<br />
* [[TeX Gyre]] : a set of great text fonts by our GUST friends, based on URW's free PostScript standard fonts for GhostScript.<br />
* [http://www.janusz.nowacki.strefa.pl/kurier.html Foto Alfa] : some TeX related fonts from Poland (Antykwa Toruńska. Antykwa Półtawskiego, Kurier, Iwona...)<br />
* [http://linuxlibertine.sourceforge.net Libertine Open Fonts Project]: GPL/OFL serif font<br />
* [http://scripts.sil.org SIL International] : great Unicode fonts for scholars by SIL (Gentium, Doulos, Charis, etc.)<br />
* [http://ist-socrates.berkeley.edu/~pinax/greekkeys/GreekKeys.html GreekKeys] : links to polytonic Greek fonts<br />
* [http://scholarsfonts.net Scholar's Fonts] : Font for Scholars (Latin, Germanic languages, Greek, Hebrew and Linguistics)<br />
* [http://www.engl.virginia.edu/OE/junicode/junicode.html Junicode] : Junius-Unicode, a font for medievalists<br />
* [http://www.freelang.net/fonts/index.html FreeLang fonts] : fonts for exotic languages<br />
* [http://www.blambot.com Blambot] : Comic fonts<br />
* [http://www.chank.com/freefonts.php Chank] : some free Chank fonts<br />
* [http://www.fontface.com/fonts/ FontFace] : free fonts<br />
* [http://www.dafont.com DaFont] : more free fonts<br />
* [http://fonts.tom7.com/fonts98.html Divide by Zero] : more fonts<br />
* [http://moorstation.org/typoasis/typoasis1.htm TypOasis] : lots of nice fonts, but a bit hard to find (have a look at designers Apostrophic Lab, Manfred Klein and Dieter Steffmann)<br />
* [http://kadyellebee.com/fonts/ Kristine's Font Organization] : find a font in a sorted directory<br />
* [http://www.fontlover.com FontLover] : font news portal site<br />
* [http://www.stormtype.com/typefaces-fonts-shop/free.php Lido] : OpenType and TrueType typeface by Storm Type Foundry, free for non-commercial use. [http://modules.contextgarden.net/stormfontsupport Support].<br />
* [http://www.alanwood.net/unicode/fontsbyrange.html Alan Wood’s Unicode Resources] : find fonts by Unicode character range<br />
* [http://www.josbuivenga.demon.nl/ exljbris] Free Quality Font Foundry by Jos Buivenga<br />
* [http://www.stixfonts.org/ STIX Fonts] Beta download of the STIX-Fonts<br />
* ''... many more to be added ...''<br />
<br />
= NonFree Font Support =<br />
* [[Lucida]] : large font family designed by Bigelow & Holmes; suitable e.g. for presentations<br />
* [http://www.stormtype.com Storm Type Foundry] : [http://modules.contextgarden.net/stormfontsupport support] of selected fonts<br />
<br />
=Hints by Language=<br />
* general: [[Encodings and Regimes]]<br />
* [[Arabic and Hebrew]] (Idris? other ArabTeX specialists?)<br />
* [[Chinese]]<br />
* [[Czech]]<br />
* [[Greek]]<br />
* [[Russian]]<br />
* [[Vietnamese]]<br />
<br />
[[Category:Fonts]]</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Old:_A_Beginner%27s_Guide_to_Using_Fonts_in_Mark_IV&diff=9783Old: A Beginner's Guide to Using Fonts in Mark IV2009-06-01T07:52:22Z<p>Nicolas Girard: A Beginner's Guide to Using Fonts in Mark IV moved to Old: A Beginner's Guide to Using Fonts in Mark IV: This page should be deleted: it is redundant with Fonts_in_LuaTex</p>
<hr />
<div>< [[Fonts]] | [[TypeScripts]] ><br />
<br />
This page tries to describe how to use preinstalled (with the [[ConTeXt Minimals]]) typescripts with [[Mark IV|ConTeXt MkIV]]. It does ''not'' explain how this works; for this, consult [http://context.aanhet.net/svn/contextman/context-reference/en/co-fonts.pdf the new manual chapter on fonts] or documents cited in [[Fonts]]. (These things are not easy. You have been warned!)<br />
<br />
Note that this page is ''in preparation''---these things are difficult and I don't understand them fully. Some of the fonts mentioned below don't work for me; I hope to clear this soon.<br />
<br />
I assume here that we have a working ConTeXt Mark IV installation, for example ConTeXt Minimals. In particular, we have LM fonts, the TeX Gyre collection and some other ones.<br />
<br />
== Available typescripts ==<br />
<br />
Each of the typescripts below defines a keyword to use with <cmd>setupbodyfont</cmd>. Usually this is the same as the name of the typescript, but there is one exception (<code>antykwa-torunska</code>)<br />
<br />
* Latin Modern (typescript name: <code>modern</code>; this is the default font set)<br />
* Latin Modern variant (ts name: <code>modernvariable</code>; LM variable typewriter for serif)<br />
* Postscript (ts name: <code>postscript</code>; Termes for serif, Heros for sans, Cursor for mono)<br />
* Antykwa Toruńska (ts name: <code>antykwa-torunska</code>; only serif; defines <tt>antykwa</tt> as keyword for <cmd>setupbodyfont</cmd>)<br />
* Iwona (ts name: <code>iwona</code>; only sans serif)<br />
* Iwona Light, Medium and Heavy (ts names: <code>iwona-light</code>, <code>iwona-medium</code>, <code>iwona-heavy</code>; only sans; the medium variant is a small bit heavier than a "regular" one)<br />
* Pagella (ts name: <code>palatino</code>; only serif)<br />
* Termes (ts name: <code>times</code>; only serif, Heros for sans)<br />
<br />
== Usage example ==<br />
<br />
<texcode><br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,18pt]<br />
<br />
\starttext<br />
Hello world, I'm Pagella!<br />
\stoptext<br />
</texcode><br />
<br />
The first line seems to order ConTeXt to "install" (for the current file) the given typescript (it accepts what I have earlier called a "typescript name"). The last one starts using it (you may omit the size if you are satisfied with the default).<br />
<br />
== Combining predefined fonts in your own typescripts ==<br />
<br />
It is also possible to combine fonts from the TeX Gyre collection in your own typescripts. The example below combines Bonum (Bookman) roman, Adventor (AvantGarde) for sans serif, Cursor (Courier) for teletype, and Euler for math. The <code>rscale=...</code> option ensures that all fonts have the same x-height. (You can lookup the relative x-heigt of a font using fontforge.)<br />
<br />
<texcode><br />
\starttypescript [Bonum]<br />
\definetypeface [Bonum] [rm] [serif] [bonum] [default]<br />
\definetypeface [Bonum] [ss] [sans] [adventor] [default] [rscale=0.887]<br />
\definetypeface [Bonum] [tt] [mono] [cursor] [default] [rscale=1.163]<br />
\definetypeface [Bonum] [mm] [math] [euler] [default] [rscale=1.050]<br />
\stoptypescript<br />
<br />
\usetypescript[Bonum]<br />
\setupbodyfont[Bonum,12pt]<br />
<br />
\starttext<br />
Hello world, I'm Bonum!<br />
\stoptext<br />
</texcode><br />
<br />
== Example typescripts ==<br />
<br />
* [[CD_Booklet#Use_Delicious_OTF_font_with_luatex_.2F_mkiv|exljbris Delicious]]</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Fonts_in_LuaTeX&diff=9782Fonts in LuaTeX2009-06-01T07:49:30Z<p>Nicolas Girard: /* The standard way: Typescripts */ Merged contents from A Beginner's Guide to Using Fonts in Mark IV</p>
<hr />
<div>{{note|This page is not finished yet}}<br />
<br />
'''Please, someone, fill this page !'''<br />
<br />
'''This page is beeing regorganized'''<br />
<br />
= Getting access to the system fonts =<br />
<br />
LuaTeX can use non-TeX fonts (in OpenType, TrueType or Type1 format) directly.<br />
<br />
The first time that you run<br />
<br />
context myfile.tex<br />
<br />
on a file that uses such non-traditional fonts (which is probably always), the actual fonts themselves have to be loaded in luatex's embedded section of fontforge to extract their metric information. This removes the need for tfm and vf files on your disk, but it is also a somewhat lengthy and often memory-hungry process.<br />
<br />
That is why the results of that internal preprocessing are also saved inside the texmf cache. Future runs using the same font (not just this file, but all files using that particular font) can then use the cached version of the metrics instead. <br />
<br />
== Building the font database ==<br />
<br />
You need to specify where the fonts should be looked for, by setting the <code>OSFONTDIR</code> environment variable. For instance,<br />
set OSFONTDIR=c:/windows/fonts/<br />
if the fonts should be found in <code>c:/windows/fonts/</code>; or<br />
export OSFONTDIR="/usr/local/share/fonts;$HOME/.fonts"<br />
if the fonts should be found in both <code>/usr/local/share/fonts</code> and <code>$HOME/.fonts</code>.<br />
<br />
The font database will then be automatically generated in the next run of <code>context</code><br />
<br />
You can also generate it manually by typing <br />
mtxrun --script font --reload<br />
or equally<br />
mtxrun --script fonts --reload<br />
<br />
The output should look like<br />
MTXrun | fontnames: identifying tree font files with suffix otf<br />
MTXrun | fontnames: identifying tree font files with suffix OTF<br />
MTXrun | fontnames: 331 tree files identified, 332 hash entries added, runtime 7.653 seconds<br />
MTXrun | fontnames: identifying tree font files with suffix ttf<br />
MTXrun | fontnames: identifying tree font files with suffix TTF<br />
MTXrun | fontnames: 17 tree files identified, 14 hash entries added, runtime 4.645 seconds<br />
...<br />
MTXrun | fontnames: 94 system files identified, 94 hash entries added, runtime 0.554 seconds<br />
MTXrun | fontnames: 3837 files read, 3342 normal and 49 extra entries added, 5 rejected, 3386 valid<br />
<br />
<br />
<br />
== Querying the font database ==<br />
<br />
The command<br />
mtxrun --script fonts --list<br />
will return the whole entries of the font database as a list, such as<br />
<br />
...<br />
warnockprobold WarnockPro-Bold E:/Fonts/Warnock Pro/WarnockPro-Bold.otf<br />
warnockproboldcapt WarnockPro-BoldCapt E:/Fonts/Warnock Pro/WarnockPro-BoldCapt.otf<br />
warnockprobolddisp WarnockPro-BoldDisp E:/Fonts/Warnock Pro/WarnockPro-BoldDisp.otf<br />
warnockproboldit WarnockPro-BoldIt E:/Fonts/Warnock Pro/WarnockPro-BoldIt.otf<br />
warnockprobolditcapt WarnockPro-BoldItCapt E:/Fonts/Warnock Pro/WarnockPro-BoldItCapt.otf<br />
warnockprobolditdisp WarnockPro-BoldItDisp E:/Fonts/Warnock Pro/WarnockPro-BoldItDisp.otf<br />
warnockprobolditsubh WarnockPro-BoldItSubh E:/Fonts/Warnock Pro/WarnockPro-BoldItSubh.otf<br />
warnockproboldsubh WarnockPro-BoldSubh E:/Fonts/Warnock Pro/WarnockPro-BoldSubh.otf<br />
...<br />
<br />
You can query the database against a particular pattern. For instance,<br />
mtxrun --script fonts --list --pattern=Delicious*<br />
will return<br />
deliciousbold Delicious-Bold /usr/local/share/fonts/d/delicious_bold.otf<br />
deliciousbolditalic Delicious-BoldItalic /usr/local/share/fonts/d/delicious_bolditalic.otf<br />
deliciousheavy Delicious-Heavy /usr/local/share/fonts/d/delicious_heavy.otf<br />
deliciousitalic Delicious-Italic /usr/local/share/fonts/d/delicious_italic.otf<br />
deliciousroman Delicious-Roman /usr/local/share/fonts/d/delicious_roman.otf<br />
delicioussmallcaps Delicious-SmallCaps /usr/local/share/fonts/d/delicious_smallcaps.otf<br />
<br />
You can get useful informations about your fonts by using the <code>--info</code> option. For instance,<br />
mtxrun --script fonts --list --info --pattern=Delicious*Roman<br />
will return<br />
MTXrun | fontname: deliciousroman<br />
MTXrun | fullname: Delicious-Roman<br />
MTXrun | filename: /usr/local/share/fonts/d/delicious_roman.otf<br />
MTXrun |<br />
MTXrun | gpos features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | kern latn dflt<br />
MTXrun |<br />
MTXrun | gsub features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | tlig all all<br />
MTXrun | trep all all<br />
<br />
== Installing new fonts ==<br />
<br />
After installing new fonts, the font database must be rebuilt for LuaTeX to access them.<br />
<br />
In current versions of Mark IV (earlier than July 2008) this is automatically done whenever a named font cannot be found.<br />
<br />
You only have to do the reload manually when you have installed updates to already installed fonts that cause the font and/or file names to change. <br />
This normally only happens for fonts that are still in development like [[TeX Gyre]] and [[Latin Modern]].<br />
<br />
You can rebuild the database manually, using the already-mentioned command<br />
mtxrun --script fonts --reload<br />
<br />
Alternatively, you can turn off the automatic rebuild of the database, by setting either of<br />
MTX.FONTS.AUTOLOAD<br />
MTX_FONTS_AUTOLOAD<br />
to "no".<br />
<br />
== References ==<br />
<br />
[http://context.aanhet.net/svn/contextman/context-reference/en/co-fonts.pdf The new manual chapter on fonts]<br />
<br />
= Using fonts =<br />
<br />
Handling fonts in LuaTeX can be done<br />
* in a simple but limited way, using the <code>simplefonts</code> module;<br />
* in the standard way, using [[Typescripts]]<br />
<br />
== With the <code>simplefonts</code> module ==<br />
<br />
<code>simplefonts</code> is a third-party module written by Wolfgang Schuster.<br />
<br />
It simplifies the use of fonts in LuaTeX by<br />
* freeing the user from writing or using [[Typescripts]];<br />
* offering an interface similar to the [http://www.ctan.org/tex-archive/macros/xetex/latex/fontspec/ fontspec package for XeTeX]<br />
<br />
For instance, assuming the [http://www.josbuivenga.demon.nl/delicious.html Delicious fonts] are properly installed and recognized by ConTeXt, you can simply write:<br />
<br />
<texcode><br />
\usemodule[simplefonts] % load the module<br />
\setmainfont[Delicious] % set Delicious as main (serif) font<br />
<br />
\starttext<br />
\rm\tf roman \it italic \bf bold \bi bolditalic \sc smallcaps<br />
\stoptext<br />
</texcode><br />
<br />
== The standard way: Typescripts ==<br />
<br />
To be continued<br />
<br />
=== Where to find existing typescripts ===<br />
<br />
Each of the typescripts below defines a keyword to use with <cmd>setupbodyfont</cmd>. Usually this is the same as the name of the typescript, but there is one exception (<code>antykwa-torunska</code>)<br />
<br />
* Latin Modern (typescript name: <code>modern</code>; this is the default font set)<br />
* Latin Modern variant (ts name: <code>modernvariable</code>; LM variable typewriter for serif)<br />
* Postscript (ts name: <code>postscript</code>; Termes for serif, Heros for sans, Cursor for mono)<br />
* Antykwa Toruńska (ts name: <code>antykwa-torunska</code>; only serif; defines <tt>antykwa</tt> as keyword for <cmd>setupbodyfont</cmd>)<br />
* Iwona (ts name: <code>iwona</code>; only sans serif)<br />
* Iwona Light, Medium and Heavy (ts names: <code>iwona-light</code>, <code>iwona-medium</code>, <code>iwona-heavy</code>; only sans; the medium variant is a small bit heavier than a "regular" one)<br />
* Pagella (ts name: <code>palatino</code>; only serif)<br />
* Termes (ts name: <code>times</code>; only serif, Heros for sans)<br />
<br />
== Usage example ==<br />
<br />
<texcode><br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,18pt]<br />
<br />
\starttext<br />
Hello world, I'm Pagella!<br />
\stoptext<br />
</texcode><br />
<br />
The first line seems to order ConTeXt to "install" (for the current file) the given typescript (it accepts what I have earlier called a "typescript name"). The last one starts using it (you may omit the size if you are satisfied with the default).<br />
<br />
== Combining predefined fonts in your own typescripts ==<br />
<br />
It is also possible to combine fonts from the TeX Gyre collection in your own typescripts. The example below combines Bonum (Bookman) roman, Adventor (AvantGarde) for sans serif, Cursor (Courier) for teletype, and Euler for math. The <code>rscale=...</code> option ensures that all fonts have the same x-height. (You can lookup the relative x-heigt of a font using fontforge.)<br />
<br />
<texcode><br />
\starttypescript [Bonum]<br />
\definetypeface [Bonum] [rm] [serif] [bonum] [default]<br />
\definetypeface [Bonum] [ss] [sans] [adventor] [default] [rscale=0.887]<br />
\definetypeface [Bonum] [tt] [mono] [cursor] [default] [rscale=1.163]<br />
\definetypeface [Bonum] [mm] [math] [euler] [default] [rscale=1.050]<br />
\stoptypescript<br />
<br />
\usetypescript[Bonum]<br />
\setupbodyfont[Bonum,12pt]<br />
<br />
\starttext<br />
Hello world, I'm Bonum!<br />
\stoptext<br />
</texcode><br />
<br />
= Old contents =<br />
<br />
==== Good ol' typescripts ====<br />
<br />
Of course, Mark IV allows you to use typescripts as you've always done; for example:<br />
<br />
<texcode><br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,12pt]<br />
effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
<br />
\sc effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
</texcode><br />
<br />
That's as simple as using a traditional ConTeXt typescript!<br />
<br />
But ... how is it any different, then? Well, the difference is that in Mark IV, we can use an Opentype font directly, so that what is done here: when we want to use Palatino, the [[TeX Gyre]] equivalent (“Pagella”) is called and we can use its Opentype “features”; read on.<br />
<br />
==== Opentype features ====<br />
<br />
A “feature”, in the Opentype jargon, is a set of rules describing changes in the appearance of the text. Hmm, that's not very precise. Let's show some examples. First of all, you have to know that features are referred to by 4-letter tags, and you will see this a lot. One of them is ‘smcp‘, for “small caps“. Let's consider the following Mark IV-only code:<br />
<br />
<texcode><br />
\definefontfeature[smallcaps][language=DFLT,script=latn,smcp=yes]<br />
\font\palasmallcaps=texgyrepagella-regular*smallcaps<br />
\palasmallcaps This is a text in small capitals.<br />
</texcode><br />
<br />
Here you basically define a (Mark IV) feature with the name ”smallcaps”, and associate it with the (Opentype) feature “smcp”. You have to specify which script you want to use it with; scripts in Opentype are also tagged with four letters, and “latn” is of course Latin.<br />
<br />
Then you define a TeX font with that feature.<br />
<br />
You can see what features are defined in a particular font with the following bit of code<br />
<br />
<texcode><br />
\ctxlua<br />
{<br />
fontname = 'texgyrepagella-regular.otf'<br />
<br />
--[[ First read the font data.<br />
This makes heavy use of some of the Mark IV code]]<br />
tfmdata = fonts.tfm.read_and_define("file:" .. fontname, 655360)<br />
font = tfmdata.shared.otfdata<br />
if font<br />
then<br />
gsubfeatures = fonts.otf.analyze_features(font.gsub)<br />
gposfeatures = fonts.otf.analyze_features(font.gpos)<br />
end<br />
<br />
if gsubfeatures then<br />
table.sort(gsubfeatures) % We want our list sorted alphabetically!<br />
tex.sprint("\\rm GSUB features: \\tt ") % Beware: you don't want \rm to be interpreted by lua (\rm would yield carriage return + letter m)!<br />
for _, feat in ipairs(gsubfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GSUB features")<br />
end<br />
tex.sprint("\\par")<br />
<br />
if gposfeatures then<br />
tex.sprint("\\rm GPOS features: \\tt ")<br />
table.sort(gposfeatures)<br />
for _, feat in ipairs(gposfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GPOS features")<br />
end<br />
}<br />
</texcode><br />
<br />
It prints the list on the page. You'll notice there are two sets of features, each one of them defined in a different table of the Opentype font: the <code>GSUB</code> table (for Glyph SUBstitution) gives rules for replacing glyphs in certains circumstances (think of ligatures: f + i -> fi); the <code>GPOS</code> table (Glyph POSititioning) gives rules for moving glyphs (think of kerning: A + V -> A <kerning> V).<br />
<br />
Incidentally, the above code gives some basic examples of LuaTeX programming, a mixture of both Lua and TeX programming with some special features (features in the general sense, not the Opentype one :-).<br />
<br />
==== A (Complete) Typescript Example ====<br />
<br />
<texcode><br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [FranklinBookRegular] [name:FranklinGothicBookITC-Regular] [features=default]<br />
\definefontsynonym [FranklinMediumRegular] [name:FranklinGothicMediumITC-Regular] [features=default]<br />
\definefontsynonym [FranklinDemiRegular] [name:FranklinGothicDemiITC-Regular] [features=default]<br />
\definefontsynonym [FranklinHeavyRegular] [name:FranklinGothicHeavyITC-Regular] [features=default]<br />
<br />
\definefontsynonym [FranklinBookItalic] [name:FranklinGothicBookITC-Italic] [features=default]<br />
\definefontsynonym [FranklinDemiItalic] [name:FranklinGothicMediumITC-Italic] [features=default]<br />
\definefontsynonym [FranklinHeavyItalic] [name:FranklinGothicDemiITC-Italic] [features=default]<br />
\definefontsynonym [FranklinMediumItalic] [name:FranklinGothicHeavyITC-Italic] [features=default]<br />
<br />
\stoptypescript<br />
<br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [Sans] [FranklinBookRegular] [features=default]<br />
\definefontsynonym [SansItalic] [FranklinBookItalic] [features=default]<br />
\definefontsynonym [SansBold] [FranklinDemiRegular] [features=default]<br />
\definefontsynonym [SansBoldItalic] [FranklinDemiItalic] [features=default]<br />
\definefontsynonym [SansSlanted] [SansItalic] [features=default]<br />
\definefontsynonym [SansBoldSlanted] [SansBoldItalic] [features=default]<br />
\definefontsynonym [SansCaps] [Sans] [features=smallcaps]<br />
<br />
\stoptypescript<br />
<br />
\definetypeface[franklin][rm][sans][franklin][default]<br />
\definetypeface[franklin][ss][sans][franklin][default]<br />
\definetypeface[franklin][tt][mono][modern] [default][rscale=1.12]<br />
\definetypeface[franklin][mm][math][iwona] [default][rscale=1.02]<br />
<br />
\setupbodyfont[franklin,ss,10pt]<br />
</texcode><br />
<br />
<br />
<br />
Just the simplest way to use an otf font — or any font that does appear in <tt>mtxrun --script font --list</tt> — in all the document.<br />
<br />
I’m stick here :<br />
<br />
\definefontfeature [myfontfeature] [method=node, kern=yes, OTHER_FEATURE_COMMA_SEPERATED]<br />
\definefontsynonym [MyFontRegular] [name:TheFontName-Regular][features=myfontfeature]<br />
\definedfont [MyFontRegular at 16pt]<br />
<br />
This doesn’t run for my title which use « \tfc », only for the body of the text.<br />
<br />
*\definefontfeature<br />
**[myfontfeature] : you can use the name you want. It will be use at the next line ;<br />
**the fonts feature can be found with <tt>otfinfo -f TheFontFile.otf</tt>.<br />
*\definefontsynonym :<br />
**[MyFontRegular] : you can use the name you want. It will be use at the next line ;<br />
**The name after <tt>name:</tt> is the name given by <tt>mtxrun --script font --list</tt><br />
**The « name: » part can be replaced by <tt>file:TheFontFile.otf</tt><br />
<br />
<br />
== Example ==<br />
<br />
<br />
Now to access, say the regular warnock font, the following are valid. And I ought to mention that Hans recommends the first http://article.gmane.org/gmane.comp.tex.context/43685.<br />
<br />
<texcode><br />
% Hans recommends this format;<br />
\definefontsynonym [WarnockPro-Regular] [name:warnockproregular] <br />
</texcode><br />
<br />
and<br />
<br />
<texcode><br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular]<br />
</texcode><br />
<br />
An entire typescript would be defined as;<br />
<br />
<texcode><br />
\definefontfeature[latin-smallcaps][smallcaps][script=latn]<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\setups[font:fallback:sans]<br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular] <br />
\definefontsynonym [WarnockPro-Bold] [name:WarnockPro-Bold] <br />
\definefontsynonym [WarnockPro-Italic] [name:WarnockPro-It] <br />
\definefontsynonym [WarnockPro-BoldItalic] [name:WarnockPro-BoldIt] <br />
\stoptypescript<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\definefontsynonym [Serif] [WarnockPro-Regular] [features=default]<br />
\definefontsynonym [SerifBold] [WarnockPro-Bold] [features=default]<br />
\definefontsynonym [SerifItalic] [WarnockPro-Italic] [features=default]<br />
\definefontsynonym [SerifBoldItalic] [WarnockPro-BoldItalic] [features=default]<br />
\definefontsynonym [SerifCaps] [Serif] [features=latin-smallcaps]<br />
\stoptypescript<br />
<br />
\definetypeface[adobe][rm][serif][warnockpro][default]<br />
\setupbodyfont[adobe,11pt]<br />
<br />
</texcode><br />
<br />
[[Category:Fonts]]<br />
[[Category:International]]</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=CD_Booklet&diff=9781CD Booklet2009-06-01T07:46:27Z<p>Nicolas Girard: /* Use Delicious OTF font with luatex / mkiv */ see exljbris_typescript#Delicious for the typescript</p>
<hr />
<div>On this page I will describe the lessons learned while setting a CD booklet.<br />
<br />
== Fit a text into a box ==<br />
<br />
[[image:CD08-Titel.png|120px]]<br />
<br />
<br />
== Float text around a picture inside a layer ==<br />
<br />
[[image:CD08-p11.png|120px]]<br />
<br />
Floating Text around a picture inside any vbox environment is not possible and so the next two examples show text that runs through the graphical element.<br />
<br />
The variant with a simple framedtext<br />
<texcode><br />
\startbuffer[text]<br />
\placefigure[left,none]{}{\framed[height=1cm]{graphic}}%<br />
\input tufte<br />
\stopbuffer<br />
<br />
\starttext<br />
\startstandardmakeup<br />
\startframedtext[width=0.8\textwidth]<br />
\getbuffer[text]<br />
\stopframedtext<br />
\stopstandardmakeup<br />
\stoptext<br />
</texcode><br />
<br />
And the variant with layers:<br />
<texcode><br />
\definelayer[test]<br />
[width=\paperwidth,height=\paperheight]<br />
<br />
\startbuffer[text]<br />
\placefigure[left,none]{}{\framed[height=1cm]{graphic}}%<br />
\input tufte<br />
\stopbuffer<br />
<br />
\setlayerframed[test]<br />
[preset=middle]<br />
[width=0.6\textwidth,align=normal]<br />
{\getbuffer[text]}<br />
<br />
\setupbackgrounds[page][background=test]<br />
<br />
\starttext<br />
\startstandardmakeup<br />
\stopstandardmakeup<br />
\stoptext<br />
</texcode><br />
<br />
But as always with ConTeXt: Hans to the rescue! He has just some time before my trials made a nice macro available in cont-new.tex with the adequate name \starthangaround. With this macro it is quite easy to float the text around the graphic. You only has to change the buffer-code:<br />
<texcode><br />
\startbuffer[text]<br />
\starthangaround{\framed[height=1cm]{graphic}}%<br />
\input tufte<br />
\stophangaround<br />
\stopbuffer<br />
</texcode><br />
<br />
== Use Delicious OTF font with luatex / mkiv ==<br />
<br />
Get the typescript for the [http://www.josbuivenga.demon.nl/delicious.html Delicious fonts]: [[exljbris_typescript#Delicious]]<br />
<br />
Then type:<br />
<br />
<texcode><br />
\usetypescript[delicious]<br />
\setupbodyfont[delicious,ss,10pt]<br />
</texcode><br />
<br />
== Protrusion with mkiv ==<br />
<br />
== Pages with layers only ==<br />
<br />
When using ConTeXt for designing some work that is not primarily focused on continuous text, it is most likely that your pages are composed of different layers only and don't contain any ''normal'' text. Only defining the layers and filling them with your content is not enough to make them appear on the page. So this easy approach doesn't work:<br />
<br />
<texcode><br />
\definelayer[test]<br />
[width=\paperwidth,height=\paperheight]<br />
<br />
\setlayerframed[test]<br />
[preset=middle]<br />
[width=0.6\textwidth,align=normal]<br />
{\input tufte }<br />
<br />
\setupbackgrounds[page][background=test]<br />
<br />
\starttext<br />
\stoptext<br />
</texcode><br />
<br />
We expect the frame with tufte just in the middle of the page. With \setupbackgrounds we have positioned our layer. But no output is generated since the OTR (Output Routine) is invoked. And because there is no content on the page (and the background is no content) an empty page will be generated.<br />
<br />
There are some possibilities to invoke the OTR. Inside <code>\starttext \stoptext</code> call one of the following:<br />
<br />
<texcode><br />
\page[empty]<br />
</texcode><br />
<br />
<texcode><br />
\startstandardmakeup<br />
\stopstandardmakeup<br />
</texcode><br />
<br />
If you haven't defined you own pagelayout, the following invocations of the OTR just use the standard layout that has a pagenumber in the headerline<br />
<texcode><br />
\dontleavehmode<br />
</texcode><br />
<br />
<texcode><br />
\null<br />
</texcode><br />
<br />
The last alternative is just to use<br />
<texcode><br />
\flushlayer[test]<br />
</texcode><br />
(You can discard the background definition then) But this places the layer relative to the textarea and not as intended to the pagearea.<br />
<br />
[[Category:Sample documents]]</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Exljbris_typescript&diff=9780Exljbris typescript2009-06-01T07:41:30Z<p>Nicolas Girard: /* Delicious */ Added \definefontsynonym [Delicious-Heavy]</p>
<hr />
<div>The Exljbris font is a collection of realy nice otf fonts, by Jos Buivenga. You can [http://www.josbuivenga.demon.nl download] them for free. Don’t forget to make links to this page when you use them.<br />
<br />
== Anniver ==<br />
<br />
<texcode><br />
\starttypescript [sans] [anivers]<br />
\setups[font:fallback:sans]<br />
\definefontsynonym [Sans] [Anivers-Regular] [features=default]<br />
\stoptypescript<br />
<br />
\starttypescript [sans] [anivers]<br />
\definefontsynonym [Anivers-Regular] [name:Anivers Regular] [features=default]<br />
\stoptypescript<br />
<br />
\starttypescript [anivers]<br />
\definetypeface [anivers] [ss] [sans] [anivers] [default]<br />
\stoptypescript<br />
</texcode><br />
<br />
== Delicious ==<br />
<br />
<texcode><br />
\starttypescript [sans] [delicious]<br />
\setups[font:fallback:sans]<br />
\definefontsynonym [Sans] [Delicious-Regular]<br />
\definefontsynonym [SansItalic] [Delicious-Italic]<br />
\definefontsynonym [SansBold] [Delicious-Bold]<br />
\definefontsynonym [SansBoldItalic] [Delicious-BoldItalic]<br />
\definefontsynonym [SansCaps] [Delicious-Caps]<br />
\stoptypescript<br />
<br />
\starttypescript [sans] [delicious]<br />
\definefontsynonym [Delicious-Regular] [name:Delicious-Roman] [features=default]<br />
\definefontsynonym [Delicious-Italic] [name:Delicious-Italic] [features=default]<br />
\definefontsynonym [Delicious-Bold] [name:Delicious-Bold] [features=default]<br />
\definefontsynonym [Delicious-BoldItalic] [name:Delicious-BoldItalic] [features=default]<br />
\definefontsynonym [Delicious-Caps] [name:Delicious-SmallCaps] [features=default]<br />
\definefontsynonym [Delicious-Heavy] [name:Delicious-Heavy] [features=default]<br />
\stoptypescript<br />
<br />
<br />
\starttypescript [delicious]<br />
\definetypeface [delicious] [ss] [sans] [delicious] [default]<br />
\stoptypescript<br />
</texcode><br />
<br />
== Diavlo ==<br />
<br />
<texcode><br />
\starttypescript [sans] [diavlo]<br />
\setups[font:fallback:sans]<br />
\definefontsynonym [Sans] [DiavloBook-Regular] [features=default]<br />
\definefontsynonym [SansBold] [DiavloMedium-Regular] [features=default] <br />
\stoptypescript<br />
<br />
\starttypescript [sans] [diavlo-light]<br />
\setups[font:fallback:sans]<br />
\definefontsynonym [Sans] [DiavloLight-Regular] [features=default]<br />
\definefontsynonym [SansBold] [DiavloBook-Regular] [features=default] <br />
\stoptypescript<br />
<br />
\starttypescript [sans] [diavlo-medium]<br />
\setups[font:fallback:sans]<br />
\definefontsynonym [Sans] [DiavloMedium-Regular] [features=default]<br />
\definefontsynonym [SansBold] [DiavloBlack-Regular] [features=default] <br />
\stoptypescript<br />
<br />
\starttypescript [sans] [diavlo-bold]<br />
\setups[font:fallback:sans]<br />
\definefontsynonym [Sans] [DiavloBold-Regular] [features=default]<br />
\definefontsynonym [SansBold] [DiavloBlack-Regular] [features=default] <br />
\stoptypescript<br />
<br />
\starttypescript [sans] [diavlo,diavlo-light,diavlo-medium,diavlo-bold]<br />
\definefontsynonym [DiavloLight-Regular] [name:Diavlo Light Regular] [features=default]<br />
\definefontsynonym [DiavloBook-Regular] [name:Diavlo Book Regular] [features=default]<br />
\definefontsynonym [DiavloMedium-Regular] [name:Diavlo Medium Regular] [features=default]<br />
\definefontsynonym [DiavloBold-Regular] [name:Diavlo Bold Regular] [features=default]<br />
\definefontsynonym [DiavloBlack-Regular] [name:Diavlo Black Regular] [features=default]<br />
\stoptypescript<br />
<br />
\starttypescript [diavlo,diavlo-light,diavlo-medium,diavlo-bold]<br />
\definetypeface [\typescriptone] [ss] [sans] [\typescriptone] [default]<br />
\stoptypescript<br />
</texcode><br />
<br />
== Fertigo Pro ==<br />
<br />
(partial typescript)<br />
<br />
<texcode><br />
\starttypescript [sans] [fertigo]<br />
\setups[font:fallback:sans]<br />
\definefontsynonym [Sans] [Fertigo-Regular]<br />
\stoptypescript<br />
<br />
\starttypescript [sans] [fertigo]<br />
\definefontsynonym [Fertigo-Regular] [name:Fertigo Pro Regular] [features=default]<br />
\stoptypescript<br />
<br />
\starttypescript [fertigo]<br />
\definetypeface [fertigo] [ss] [sans] [fertigo] [default]<br />
\stoptypescript<br />
</texcode><br />
<br />
== Fontin / Fontin Sans ==<br />
<br />
<texcode><br />
\definefontfeature [fontin] [method=node, script=latn,<br />
liga=yes, %ligatures<br />
frac=yes, %fractions<br />
pnum=yes, % <br />
tnum=yes] %<br />
<br />
\starttypescript [sans] [fontin-sans]<br />
\setups[font:fallback:sans]<br />
\definefontsynonym [Sans] [FontinSans-Regular]<br />
\definefontsynonym [SansBold] [FontinSans-Bold]<br />
\definefontsynonym [SansItalic] [FontinSans-Italic]<br />
\definefontsynonym [SansBoldItalic] [FontinSans-BoldItalic]<br />
\definefontsynonym [SansCaps] [FontinSans-Caps]<br />
\stoptypescript<br />
<br />
\starttypescript [sans] [fontin-sans]<br />
\definefontsynonym [FontinSans-Regular] [name:Fontin Sans Regular] [features=fontin]<br />
\definefontsynonym [FontinSans-Bold] [name:Fontin Sans Bold] [features=fontin]<br />
\definefontsynonym [FontinSans-Italic] [name:Fontin Sans Italic] [features=fontin]<br />
\definefontsynonym [FontinSans-BoldItalic] [name:Fontin Sans Bold Italic] [features=fontin]<br />
\definefontsynonym [FontinSans-Caps] [name:Fontin Sans Small Caps] [features=fontin]<br />
\stoptypescript<br />
<br />
\starttypescript [serif] [fontin]<br />
\setups[font:fallback:serif]<br />
\definefontsynonym [Serif] [Fontin-Regular]<br />
\definefontsynonym [SerifBold] [Fontin-Bold]<br />
\definefontsynonym [SerifItalic] [Fontin-Italic]<br />
\definefontsynonym [SerifCaps] [Fontin-Caps]<br />
\stoptypescript<br />
<br />
\starttypescript [serif] [fontin]<br />
\definefontsynonym [Fontin-Regular] [name:Fontin Regular] [features=fontin]<br />
\definefontsynonym [Fontin-Bold] [name:Fontin Bold] [features=fontin]<br />
\definefontsynonym [Fontin-Italic] [name:Fontin Italic] [features=fontin]<br />
\definefontsynonym [Fontin-Caps] [name:Fontin SmallCaps] [features=fontin]<br />
\stoptypescript<br />
<br />
\starttypescript [fontin]<br />
\definetypeface [\typescriptone] [rm] [serif] [fontin] [default]<br />
\definetypeface [\typescriptone] [ss] [sans] [fontin-sans] [default]<br />
\definetypeface [\typescriptone] [tt] [mono] [modern] [default] [rscale=1.1]<br />
\definetypeface [\typescriptone] [mm] [math] [palatino] [default]<br />
\stoptypescript<br />
<br />
</texcode><br />
<br />
== Museo / Museo Sans ==<br />
<br />
<texcode><br />
\starttypescript [serif] [museo]<br />
\setups[font:fallback:serif]<br />
\definefontsynonym [Serif] [Museo-500] [features=default]<br />
\definefontsynonym [SerifBold] [Museo-700] [features=default]<br />
\stoptypescript<br />
<br />
\starttypescript [sans] [museo]<br />
\setups[font:fallback:sans]<br />
\definefontsynonym [Sans] [MuseoSans-500] [features=default]<br />
\definefontsynonym [SansItalic] [MuseoSans-500-Italic] [features=default]<br />
\stoptypescript<br />
<br />
\starttypescript [serif] [museo]<br />
\definefontsynonym [Museo-300] [name:Museo 300] [features=default]<br />
\definefontsynonym [Museo-500] [name:Museo 500] [features=default]<br />
\definefontsynonym [Museo-700] [name:Museo 700] [features=default]<br />
\stoptypescript<br />
<br />
\starttypescript [sans] [museo]<br />
\definefontsynonym [MuseoSans-500] [name:Museo Sans 500] [features=default]<br />
\definefontsynonym [MuseoSans-500-Italic] [name:Museo Sans 500 Italic] [features=default]<br />
\stoptypescript<br />
<br />
\starttypescript [museo]<br />
\definetypeface [museo] [rm] [serif] [museo] [default]<br />
\definetypeface [museo] [ss] [sans] [museo] [default]<br />
\stoptypescript<br />
</texcode><br />
<br />
== Tallys ==<br />
<br />
<texcode><br />
\starttypescript [serif] [tallys]<br />
\setups[font:fallback:serif]<br />
\definefontsynonym [Serif] [Tallys-Regular] [features=default]<br />
\stoptypescript<br />
<br />
\starttypescript [serif] [tallys]<br />
\definefontsynonym [Tallys-Regular] [name:Tallys] [features=default]<br />
\stoptypescript<br />
<br />
\starttypescript [tallys]<br />
\definetypeface [tallys] [rm] [serif] [tallys] [default]<br />
\stoptypescript<br />
</texcode></div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Fonts_in_LuaTeX&diff=9779Fonts in LuaTeX2009-06-01T07:29:53Z<p>Nicolas Girard: /* The standard way: Typescripts */ Merged contents from A Beginner's Guide to Using Fonts in Mark IV</p>
<hr />
<div>{{note|This page is not finished yet}}<br />
<br />
'''Please, someone, fill this page !'''<br />
<br />
'''This page is beeing regorganized'''<br />
<br />
= Getting access to the system fonts =<br />
<br />
LuaTeX can use non-TeX fonts (in OpenType, TrueType or Type1 format) directly.<br />
<br />
The first time that you run<br />
<br />
context myfile.tex<br />
<br />
on a file that uses such non-traditional fonts (which is probably always), the actual fonts themselves have to be loaded in luatex's embedded section of fontforge to extract their metric information. This removes the need for tfm and vf files on your disk, but it is also a somewhat lengthy and often memory-hungry process.<br />
<br />
That is why the results of that internal preprocessing are also saved inside the texmf cache. Future runs using the same font (not just this file, but all files using that particular font) can then use the cached version of the metrics instead. <br />
<br />
== Building the font database ==<br />
<br />
You need to specify where the fonts should be looked for, by setting the <code>OSFONTDIR</code> environment variable. For instance,<br />
set OSFONTDIR=c:/windows/fonts/<br />
if the fonts should be found in <code>c:/windows/fonts/</code>; or<br />
export OSFONTDIR="/usr/local/share/fonts;$HOME/.fonts"<br />
if the fonts should be found in both <code>/usr/local/share/fonts</code> and <code>$HOME/.fonts</code>.<br />
<br />
The font database will then be automatically generated in the next run of <code>context</code><br />
<br />
You can also generate it manually by typing <br />
mtxrun --script font --reload<br />
or equally<br />
mtxrun --script fonts --reload<br />
<br />
The output should look like<br />
MTXrun | fontnames: identifying tree font files with suffix otf<br />
MTXrun | fontnames: identifying tree font files with suffix OTF<br />
MTXrun | fontnames: 331 tree files identified, 332 hash entries added, runtime 7.653 seconds<br />
MTXrun | fontnames: identifying tree font files with suffix ttf<br />
MTXrun | fontnames: identifying tree font files with suffix TTF<br />
MTXrun | fontnames: 17 tree files identified, 14 hash entries added, runtime 4.645 seconds<br />
...<br />
MTXrun | fontnames: 94 system files identified, 94 hash entries added, runtime 0.554 seconds<br />
MTXrun | fontnames: 3837 files read, 3342 normal and 49 extra entries added, 5 rejected, 3386 valid<br />
<br />
<br />
<br />
== Querying the font database ==<br />
<br />
The command<br />
mtxrun --script fonts --list<br />
will return the whole entries of the font database as a list, such as<br />
<br />
...<br />
warnockprobold WarnockPro-Bold E:/Fonts/Warnock Pro/WarnockPro-Bold.otf<br />
warnockproboldcapt WarnockPro-BoldCapt E:/Fonts/Warnock Pro/WarnockPro-BoldCapt.otf<br />
warnockprobolddisp WarnockPro-BoldDisp E:/Fonts/Warnock Pro/WarnockPro-BoldDisp.otf<br />
warnockproboldit WarnockPro-BoldIt E:/Fonts/Warnock Pro/WarnockPro-BoldIt.otf<br />
warnockprobolditcapt WarnockPro-BoldItCapt E:/Fonts/Warnock Pro/WarnockPro-BoldItCapt.otf<br />
warnockprobolditdisp WarnockPro-BoldItDisp E:/Fonts/Warnock Pro/WarnockPro-BoldItDisp.otf<br />
warnockprobolditsubh WarnockPro-BoldItSubh E:/Fonts/Warnock Pro/WarnockPro-BoldItSubh.otf<br />
warnockproboldsubh WarnockPro-BoldSubh E:/Fonts/Warnock Pro/WarnockPro-BoldSubh.otf<br />
...<br />
<br />
You can query the database against a particular pattern. For instance,<br />
mtxrun --script fonts --list --pattern=Delicious*<br />
will return<br />
deliciousbold Delicious-Bold /usr/local/share/fonts/d/delicious_bold.otf<br />
deliciousbolditalic Delicious-BoldItalic /usr/local/share/fonts/d/delicious_bolditalic.otf<br />
deliciousheavy Delicious-Heavy /usr/local/share/fonts/d/delicious_heavy.otf<br />
deliciousitalic Delicious-Italic /usr/local/share/fonts/d/delicious_italic.otf<br />
deliciousroman Delicious-Roman /usr/local/share/fonts/d/delicious_roman.otf<br />
delicioussmallcaps Delicious-SmallCaps /usr/local/share/fonts/d/delicious_smallcaps.otf<br />
<br />
You can get useful informations about your fonts by using the <code>--info</code> option. For instance,<br />
mtxrun --script fonts --list --info --pattern=Delicious*Roman<br />
will return<br />
MTXrun | fontname: deliciousroman<br />
MTXrun | fullname: Delicious-Roman<br />
MTXrun | filename: /usr/local/share/fonts/d/delicious_roman.otf<br />
MTXrun |<br />
MTXrun | gpos features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | kern latn dflt<br />
MTXrun |<br />
MTXrun | gsub features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | tlig all all<br />
MTXrun | trep all all<br />
<br />
== Installing new fonts ==<br />
<br />
After installing new fonts, the font database must be rebuilt for LuaTeX to access them.<br />
<br />
In current versions of Mark IV (earlier than July 2008) this is automatically done whenever a named font cannot be found.<br />
<br />
You only have to do the reload manually when you have installed updates to already installed fonts that cause the font and/or file names to change. <br />
This normally only happens for fonts that are still in development like [[TeX Gyre]] and [[Latin Modern]].<br />
<br />
You can rebuild the database manually, using the already-mentioned command<br />
mtxrun --script fonts --reload<br />
<br />
Alternatively, you can turn off the automatic rebuild of the database, by setting either of<br />
MTX.FONTS.AUTOLOAD<br />
MTX_FONTS_AUTOLOAD<br />
to "no".<br />
<br />
== References ==<br />
<br />
[http://context.aanhet.net/svn/contextman/context-reference/en/co-fonts.pdf The new manual chapter on fonts]<br />
<br />
= Using fonts =<br />
<br />
Handling fonts in LuaTeX can be done<br />
* in a simple but limited way, using the <code>simplefonts</code> module;<br />
* in the standard way, using [[Typescripts]]<br />
<br />
== With the <code>simplefonts</code> module ==<br />
<br />
<code>simplefonts</code> is a third-party module written by Wolfgang Schuster.<br />
<br />
It simplifies the use of fonts in LuaTeX by<br />
* freeing the user from writing or using [[Typescripts]];<br />
* offering an interface similar to the [http://www.ctan.org/tex-archive/macros/xetex/latex/fontspec/ fontspec package for XeTeX]<br />
<br />
For instance, assuming the [http://www.josbuivenga.demon.nl/delicious.html Delicious fonts] are properly installed and recognized by ConTeXt, you can simply write:<br />
<br />
<texcode><br />
\usemodule[simplefonts] % load the module<br />
\setmainfont[Delicious] % set Delicious as main (serif) font<br />
<br />
\starttext<br />
\rm\tf roman \it italic \bf bold \bi bolditalic \sc smallcaps<br />
\stoptext<br />
</texcode><br />
<br />
== The standard way: Typescripts ==<br />
<br />
To be continued<br />
<br />
=== Where to find existing typescripts ===<br />
<br />
Each of the typescripts below defines a keyword to use with <cmd>setupbodyfont</cmd>. Usually this is the same as the name of the typescript, but there is one exception (<code>antykwa-torunska</code>)<br />
<br />
* Latin Modern (typescript name: <code>modern</code>; this is the default font set)<br />
* Latin Modern variant (ts name: <code>modernvariable</code>; LM variable typewriter for serif)<br />
* Postscript (ts name: <code>postscript</code>; Termes for serif, Heros for sans, Cursor for mono)<br />
* Antykwa Toruńska (ts name: <code>antykwa-torunska</code>; only serif; defines <tt>antykwa</tt> as keyword for <cmd>setupbodyfont</cmd>)<br />
* Iwona (ts name: <code>iwona</code>; only sans serif)<br />
* Iwona Light, Medium and Heavy (ts names: <code>iwona-light</code>, <code>iwona-medium</code>, <code>iwona-heavy</code>; only sans; the medium variant is a small bit heavier than a "regular" one)<br />
* Pagella (ts name: <code>palatino</code>; only serif)<br />
* Termes (ts name: <code>times</code>; only serif, Heros for sans)<br />
<br />
= Old contents =<br />
<br />
==== Good ol' typescripts ====<br />
<br />
Of course, Mark IV allows you to use typescripts as you've always done; for example:<br />
<br />
<texcode><br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,12pt]<br />
effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
<br />
\sc effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
</texcode><br />
<br />
That's as simple as using a traditional ConTeXt typescript!<br />
<br />
But ... how is it any different, then? Well, the difference is that in Mark IV, we can use an Opentype font directly, so that what is done here: when we want to use Palatino, the [[TeX Gyre]] equivalent (“Pagella”) is called and we can use its Opentype “features”; read on.<br />
<br />
==== Opentype features ====<br />
<br />
A “feature”, in the Opentype jargon, is a set of rules describing changes in the appearance of the text. Hmm, that's not very precise. Let's show some examples. First of all, you have to know that features are referred to by 4-letter tags, and you will see this a lot. One of them is ‘smcp‘, for “small caps“. Let's consider the following Mark IV-only code:<br />
<br />
<texcode><br />
\definefontfeature[smallcaps][language=DFLT,script=latn,smcp=yes]<br />
\font\palasmallcaps=texgyrepagella-regular*smallcaps<br />
\palasmallcaps This is a text in small capitals.<br />
</texcode><br />
<br />
Here you basically define a (Mark IV) feature with the name ”smallcaps”, and associate it with the (Opentype) feature “smcp”. You have to specify which script you want to use it with; scripts in Opentype are also tagged with four letters, and “latn” is of course Latin.<br />
<br />
Then you define a TeX font with that feature.<br />
<br />
You can see what features are defined in a particular font with the following bit of code<br />
<br />
<texcode><br />
\ctxlua<br />
{<br />
fontname = 'texgyrepagella-regular.otf'<br />
<br />
--[[ First read the font data.<br />
This makes heavy use of some of the Mark IV code]]<br />
tfmdata = fonts.tfm.read_and_define("file:" .. fontname, 655360)<br />
font = tfmdata.shared.otfdata<br />
if font<br />
then<br />
gsubfeatures = fonts.otf.analyze_features(font.gsub)<br />
gposfeatures = fonts.otf.analyze_features(font.gpos)<br />
end<br />
<br />
if gsubfeatures then<br />
table.sort(gsubfeatures) % We want our list sorted alphabetically!<br />
tex.sprint("\\rm GSUB features: \\tt ") % Beware: you don't want \rm to be interpreted by lua (\rm would yield carriage return + letter m)!<br />
for _, feat in ipairs(gsubfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GSUB features")<br />
end<br />
tex.sprint("\\par")<br />
<br />
if gposfeatures then<br />
tex.sprint("\\rm GPOS features: \\tt ")<br />
table.sort(gposfeatures)<br />
for _, feat in ipairs(gposfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GPOS features")<br />
end<br />
}<br />
</texcode><br />
<br />
It prints the list on the page. You'll notice there are two sets of features, each one of them defined in a different table of the Opentype font: the <code>GSUB</code> table (for Glyph SUBstitution) gives rules for replacing glyphs in certains circumstances (think of ligatures: f + i -> fi); the <code>GPOS</code> table (Glyph POSititioning) gives rules for moving glyphs (think of kerning: A + V -> A <kerning> V).<br />
<br />
Incidentally, the above code gives some basic examples of LuaTeX programming, a mixture of both Lua and TeX programming with some special features (features in the general sense, not the Opentype one :-).<br />
<br />
==== A (Complete) Typescript Example ====<br />
<br />
<texcode><br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [FranklinBookRegular] [name:FranklinGothicBookITC-Regular] [features=default]<br />
\definefontsynonym [FranklinMediumRegular] [name:FranklinGothicMediumITC-Regular] [features=default]<br />
\definefontsynonym [FranklinDemiRegular] [name:FranklinGothicDemiITC-Regular] [features=default]<br />
\definefontsynonym [FranklinHeavyRegular] [name:FranklinGothicHeavyITC-Regular] [features=default]<br />
<br />
\definefontsynonym [FranklinBookItalic] [name:FranklinGothicBookITC-Italic] [features=default]<br />
\definefontsynonym [FranklinDemiItalic] [name:FranklinGothicMediumITC-Italic] [features=default]<br />
\definefontsynonym [FranklinHeavyItalic] [name:FranklinGothicDemiITC-Italic] [features=default]<br />
\definefontsynonym [FranklinMediumItalic] [name:FranklinGothicHeavyITC-Italic] [features=default]<br />
<br />
\stoptypescript<br />
<br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [Sans] [FranklinBookRegular] [features=default]<br />
\definefontsynonym [SansItalic] [FranklinBookItalic] [features=default]<br />
\definefontsynonym [SansBold] [FranklinDemiRegular] [features=default]<br />
\definefontsynonym [SansBoldItalic] [FranklinDemiItalic] [features=default]<br />
\definefontsynonym [SansSlanted] [SansItalic] [features=default]<br />
\definefontsynonym [SansBoldSlanted] [SansBoldItalic] [features=default]<br />
\definefontsynonym [SansCaps] [Sans] [features=smallcaps]<br />
<br />
\stoptypescript<br />
<br />
\definetypeface[franklin][rm][sans][franklin][default]<br />
\definetypeface[franklin][ss][sans][franklin][default]<br />
\definetypeface[franklin][tt][mono][modern] [default][rscale=1.12]<br />
\definetypeface[franklin][mm][math][iwona] [default][rscale=1.02]<br />
<br />
\setupbodyfont[franklin,ss,10pt]<br />
</texcode><br />
<br />
<br />
<br />
Just the simplest way to use an otf font — or any font that does appear in <tt>mtxrun --script font --list</tt> — in all the document.<br />
<br />
I’m stick here :<br />
<br />
\definefontfeature [myfontfeature] [method=node, kern=yes, OTHER_FEATURE_COMMA_SEPERATED]<br />
\definefontsynonym [MyFontRegular] [name:TheFontName-Regular][features=myfontfeature]<br />
\definedfont [MyFontRegular at 16pt]<br />
<br />
This doesn’t run for my title which use « \tfc », only for the body of the text.<br />
<br />
*\definefontfeature<br />
**[myfontfeature] : you can use the name you want. It will be use at the next line ;<br />
**the fonts feature can be found with <tt>otfinfo -f TheFontFile.otf</tt>.<br />
*\definefontsynonym :<br />
**[MyFontRegular] : you can use the name you want. It will be use at the next line ;<br />
**The name after <tt>name:</tt> is the name given by <tt>mtxrun --script font --list</tt><br />
**The « name: » part can be replaced by <tt>file:TheFontFile.otf</tt><br />
<br />
<br />
== Example ==<br />
<br />
<br />
Now to access, say the regular warnock font, the following are valid. And I ought to mention that Hans recommends the first http://article.gmane.org/gmane.comp.tex.context/43685.<br />
<br />
<texcode><br />
% Hans recommends this format;<br />
\definefontsynonym [WarnockPro-Regular] [name:warnockproregular] <br />
</texcode><br />
<br />
and<br />
<br />
<texcode><br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular]<br />
</texcode><br />
<br />
An entire typescript would be defined as;<br />
<br />
<texcode><br />
\definefontfeature[latin-smallcaps][smallcaps][script=latn]<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\setups[font:fallback:sans]<br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular] <br />
\definefontsynonym [WarnockPro-Bold] [name:WarnockPro-Bold] <br />
\definefontsynonym [WarnockPro-Italic] [name:WarnockPro-It] <br />
\definefontsynonym [WarnockPro-BoldItalic] [name:WarnockPro-BoldIt] <br />
\stoptypescript<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\definefontsynonym [Serif] [WarnockPro-Regular] [features=default]<br />
\definefontsynonym [SerifBold] [WarnockPro-Bold] [features=default]<br />
\definefontsynonym [SerifItalic] [WarnockPro-Italic] [features=default]<br />
\definefontsynonym [SerifBoldItalic] [WarnockPro-BoldItalic] [features=default]<br />
\definefontsynonym [SerifCaps] [Serif] [features=latin-smallcaps]<br />
\stoptypescript<br />
<br />
\definetypeface[adobe][rm][serif][warnockpro][default]<br />
\setupbodyfont[adobe,11pt]<br />
<br />
</texcode><br />
<br />
[[Category:Fonts]]<br />
[[Category:International]]</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Fonts_in_LuaTeX&diff=9778Fonts in LuaTeX2009-06-01T00:29:34Z<p>Nicolas Girard: /* Using fonts */ Added contents</p>
<hr />
<div>{{note|This page is not finished yet}}<br />
<br />
'''Please, someone, fill this page !'''<br />
<br />
'''This page is beeing regorganized'''<br />
<br />
= Getting access to the system fonts =<br />
<br />
LuaTeX can use non-TeX fonts (in OpenType, TrueType or Type1 format) directly.<br />
<br />
The first time that you run<br />
<br />
context myfile.tex<br />
<br />
on a file that uses such non-traditional fonts (which is probably always), the actual fonts themselves have to be loaded in luatex's embedded section of fontforge to extract their metric information. This removes the need for tfm and vf files on your disk, but it is also a somewhat lengthy and often memory-hungry process.<br />
<br />
That is why the results of that internal preprocessing are also saved inside the texmf cache. Future runs using the same font (not just this file, but all files using that particular font) can then use the cached version of the metrics instead. <br />
<br />
== Building the font database ==<br />
<br />
You need to specify where the fonts should be looked for, by setting the <code>OSFONTDIR</code> environment variable. For instance,<br />
set OSFONTDIR=c:/windows/fonts/<br />
if the fonts should be found in <code>c:/windows/fonts/</code>; or<br />
export OSFONTDIR="/usr/local/share/fonts;$HOME/.fonts"<br />
if the fonts should be found in both <code>/usr/local/share/fonts</code> and <code>$HOME/.fonts</code>.<br />
<br />
The font database will then be automatically generated in the next run of <code>context</code><br />
<br />
You can also generate it manually by typing <br />
mtxrun --script font --reload<br />
or equally<br />
mtxrun --script fonts --reload<br />
<br />
The output should look like<br />
MTXrun | fontnames: identifying tree font files with suffix otf<br />
MTXrun | fontnames: identifying tree font files with suffix OTF<br />
MTXrun | fontnames: 331 tree files identified, 332 hash entries added, runtime 7.653 seconds<br />
MTXrun | fontnames: identifying tree font files with suffix ttf<br />
MTXrun | fontnames: identifying tree font files with suffix TTF<br />
MTXrun | fontnames: 17 tree files identified, 14 hash entries added, runtime 4.645 seconds<br />
...<br />
MTXrun | fontnames: 94 system files identified, 94 hash entries added, runtime 0.554 seconds<br />
MTXrun | fontnames: 3837 files read, 3342 normal and 49 extra entries added, 5 rejected, 3386 valid<br />
<br />
<br />
<br />
== Querying the font database ==<br />
<br />
The command<br />
mtxrun --script fonts --list<br />
will return the whole entries of the font database as a list, such as<br />
<br />
...<br />
warnockprobold WarnockPro-Bold E:/Fonts/Warnock Pro/WarnockPro-Bold.otf<br />
warnockproboldcapt WarnockPro-BoldCapt E:/Fonts/Warnock Pro/WarnockPro-BoldCapt.otf<br />
warnockprobolddisp WarnockPro-BoldDisp E:/Fonts/Warnock Pro/WarnockPro-BoldDisp.otf<br />
warnockproboldit WarnockPro-BoldIt E:/Fonts/Warnock Pro/WarnockPro-BoldIt.otf<br />
warnockprobolditcapt WarnockPro-BoldItCapt E:/Fonts/Warnock Pro/WarnockPro-BoldItCapt.otf<br />
warnockprobolditdisp WarnockPro-BoldItDisp E:/Fonts/Warnock Pro/WarnockPro-BoldItDisp.otf<br />
warnockprobolditsubh WarnockPro-BoldItSubh E:/Fonts/Warnock Pro/WarnockPro-BoldItSubh.otf<br />
warnockproboldsubh WarnockPro-BoldSubh E:/Fonts/Warnock Pro/WarnockPro-BoldSubh.otf<br />
...<br />
<br />
You can query the database against a particular pattern. For instance,<br />
mtxrun --script fonts --list --pattern=Delicious*<br />
will return<br />
deliciousbold Delicious-Bold /usr/local/share/fonts/d/delicious_bold.otf<br />
deliciousbolditalic Delicious-BoldItalic /usr/local/share/fonts/d/delicious_bolditalic.otf<br />
deliciousheavy Delicious-Heavy /usr/local/share/fonts/d/delicious_heavy.otf<br />
deliciousitalic Delicious-Italic /usr/local/share/fonts/d/delicious_italic.otf<br />
deliciousroman Delicious-Roman /usr/local/share/fonts/d/delicious_roman.otf<br />
delicioussmallcaps Delicious-SmallCaps /usr/local/share/fonts/d/delicious_smallcaps.otf<br />
<br />
You can get useful informations about your fonts by using the <code>--info</code> option. For instance,<br />
mtxrun --script fonts --list --info --pattern=Delicious*Roman<br />
will return<br />
MTXrun | fontname: deliciousroman<br />
MTXrun | fullname: Delicious-Roman<br />
MTXrun | filename: /usr/local/share/fonts/d/delicious_roman.otf<br />
MTXrun |<br />
MTXrun | gpos features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | kern latn dflt<br />
MTXrun |<br />
MTXrun | gsub features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | tlig all all<br />
MTXrun | trep all all<br />
<br />
== Installing new fonts ==<br />
<br />
After installing new fonts, the font database must be rebuilt for LuaTeX to access them.<br />
<br />
In current versions of Mark IV (earlier than July 2008) this is automatically done whenever a named font cannot be found.<br />
<br />
You only have to do the reload manually when you have installed updates to already installed fonts that cause the font and/or file names to change. <br />
This normally only happens for fonts that are still in development like [[TeX Gyre]] and [[Latin Modern]].<br />
<br />
You can rebuild the database manually, using the already-mentioned command<br />
mtxrun --script fonts --reload<br />
<br />
Alternatively, you can turn off the automatic rebuild of the database, by setting either of<br />
MTX.FONTS.AUTOLOAD<br />
MTX_FONTS_AUTOLOAD<br />
to "no".<br />
<br />
== References ==<br />
<br />
[http://context.aanhet.net/svn/contextman/context-reference/en/co-fonts.pdf The new manual chapter on fonts]<br />
<br />
= Using fonts =<br />
<br />
Handling fonts in LuaTeX can be done<br />
* in a simple but limited way, using the <code>simplefonts</code> module;<br />
* in the standard way, using [[Typescripts]]<br />
<br />
== With the <code>simplefonts</code> module ==<br />
<br />
<code>simplefonts</code> is a third-party module written by Wolfgang Schuster.<br />
<br />
It simplifies the use of fonts in LuaTeX by<br />
* freeing the user from writing or using [[Typescripts]];<br />
* offering an interface similar to the [http://www.ctan.org/tex-archive/macros/xetex/latex/fontspec/ fontspec package for XeTeX]<br />
<br />
For instance, assuming the [http://www.josbuivenga.demon.nl/delicious.html Delicious fonts] are properly installed and recognized by ConTeXt, you can simply write:<br />
<br />
<texcode><br />
\usemodule[simplefonts] % load the module<br />
\setmainfont[Delicious] % set Delicious as main (serif) font<br />
<br />
\starttext<br />
\rm\tf roman \it italic \bf bold \bi bolditalic \sc smallcaps<br />
\stoptext<br />
</texcode><br />
<br />
== The standard way: Typescripts ==<br />
<br />
To be continued<br />
<br />
= Old contents =<br />
<br />
==== Good ol' typescripts ====<br />
<br />
Of course, Mark IV allows you to use typescripts as you've always done; for example:<br />
<br />
<texcode><br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,12pt]<br />
effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
<br />
\sc effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
</texcode><br />
<br />
That's as simple as using a traditional ConTeXt typescript!<br />
<br />
But ... how is it any different, then? Well, the difference is that in Mark IV, we can use an Opentype font directly, so that what is done here: when we want to use Palatino, the [[TeX Gyre]] equivalent (“Pagella”) is called and we can use its Opentype “features”; read on.<br />
<br />
==== Opentype features ====<br />
<br />
A “feature”, in the Opentype jargon, is a set of rules describing changes in the appearance of the text. Hmm, that's not very precise. Let's show some examples. First of all, you have to know that features are referred to by 4-letter tags, and you will see this a lot. One of them is ‘smcp‘, for “small caps“. Let's consider the following Mark IV-only code:<br />
<br />
<texcode><br />
\definefontfeature[smallcaps][language=DFLT,script=latn,smcp=yes]<br />
\font\palasmallcaps=texgyrepagella-regular*smallcaps<br />
\palasmallcaps This is a text in small capitals.<br />
</texcode><br />
<br />
Here you basically define a (Mark IV) feature with the name ”smallcaps”, and associate it with the (Opentype) feature “smcp”. You have to specify which script you want to use it with; scripts in Opentype are also tagged with four letters, and “latn” is of course Latin.<br />
<br />
Then you define a TeX font with that feature.<br />
<br />
You can see what features are defined in a particular font with the following bit of code<br />
<br />
<texcode><br />
\ctxlua<br />
{<br />
fontname = 'texgyrepagella-regular.otf'<br />
<br />
--[[ First read the font data.<br />
This makes heavy use of some of the Mark IV code]]<br />
tfmdata = fonts.tfm.read_and_define("file:" .. fontname, 655360)<br />
font = tfmdata.shared.otfdata<br />
if font<br />
then<br />
gsubfeatures = fonts.otf.analyze_features(font.gsub)<br />
gposfeatures = fonts.otf.analyze_features(font.gpos)<br />
end<br />
<br />
if gsubfeatures then<br />
table.sort(gsubfeatures) % We want our list sorted alphabetically!<br />
tex.sprint("\\rm GSUB features: \\tt ") % Beware: you don't want \rm to be interpreted by lua (\rm would yield carriage return + letter m)!<br />
for _, feat in ipairs(gsubfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GSUB features")<br />
end<br />
tex.sprint("\\par")<br />
<br />
if gposfeatures then<br />
tex.sprint("\\rm GPOS features: \\tt ")<br />
table.sort(gposfeatures)<br />
for _, feat in ipairs(gposfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GPOS features")<br />
end<br />
}<br />
</texcode><br />
<br />
It prints the list on the page. You'll notice there are two sets of features, each one of them defined in a different table of the Opentype font: the <code>GSUB</code> table (for Glyph SUBstitution) gives rules for replacing glyphs in certains circumstances (think of ligatures: f + i -> fi); the <code>GPOS</code> table (Glyph POSititioning) gives rules for moving glyphs (think of kerning: A + V -> A <kerning> V).<br />
<br />
Incidentally, the above code gives some basic examples of LuaTeX programming, a mixture of both Lua and TeX programming with some special features (features in the general sense, not the Opentype one :-).<br />
<br />
==== A (Complete) Typescript Example ====<br />
<br />
<texcode><br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [FranklinBookRegular] [name:FranklinGothicBookITC-Regular] [features=default]<br />
\definefontsynonym [FranklinMediumRegular] [name:FranklinGothicMediumITC-Regular] [features=default]<br />
\definefontsynonym [FranklinDemiRegular] [name:FranklinGothicDemiITC-Regular] [features=default]<br />
\definefontsynonym [FranklinHeavyRegular] [name:FranklinGothicHeavyITC-Regular] [features=default]<br />
<br />
\definefontsynonym [FranklinBookItalic] [name:FranklinGothicBookITC-Italic] [features=default]<br />
\definefontsynonym [FranklinDemiItalic] [name:FranklinGothicMediumITC-Italic] [features=default]<br />
\definefontsynonym [FranklinHeavyItalic] [name:FranklinGothicDemiITC-Italic] [features=default]<br />
\definefontsynonym [FranklinMediumItalic] [name:FranklinGothicHeavyITC-Italic] [features=default]<br />
<br />
\stoptypescript<br />
<br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [Sans] [FranklinBookRegular] [features=default]<br />
\definefontsynonym [SansItalic] [FranklinBookItalic] [features=default]<br />
\definefontsynonym [SansBold] [FranklinDemiRegular] [features=default]<br />
\definefontsynonym [SansBoldItalic] [FranklinDemiItalic] [features=default]<br />
\definefontsynonym [SansSlanted] [SansItalic] [features=default]<br />
\definefontsynonym [SansBoldSlanted] [SansBoldItalic] [features=default]<br />
\definefontsynonym [SansCaps] [Sans] [features=smallcaps]<br />
<br />
\stoptypescript<br />
<br />
\definetypeface[franklin][rm][sans][franklin][default]<br />
\definetypeface[franklin][ss][sans][franklin][default]<br />
\definetypeface[franklin][tt][mono][modern] [default][rscale=1.12]<br />
\definetypeface[franklin][mm][math][iwona] [default][rscale=1.02]<br />
<br />
\setupbodyfont[franklin,ss,10pt]<br />
</texcode><br />
<br />
<br />
<br />
Just the simplest way to use an otf font — or any font that does appear in <tt>mtxrun --script font --list</tt> — in all the document.<br />
<br />
I’m stick here :<br />
<br />
\definefontfeature [myfontfeature] [method=node, kern=yes, OTHER_FEATURE_COMMA_SEPERATED]<br />
\definefontsynonym [MyFontRegular] [name:TheFontName-Regular][features=myfontfeature]<br />
\definedfont [MyFontRegular at 16pt]<br />
<br />
This doesn’t run for my title which use « \tfc », only for the body of the text.<br />
<br />
*\definefontfeature<br />
**[myfontfeature] : you can use the name you want. It will be use at the next line ;<br />
**the fonts feature can be found with <tt>otfinfo -f TheFontFile.otf</tt>.<br />
*\definefontsynonym :<br />
**[MyFontRegular] : you can use the name you want. It will be use at the next line ;<br />
**The name after <tt>name:</tt> is the name given by <tt>mtxrun --script font --list</tt><br />
**The « name: » part can be replaced by <tt>file:TheFontFile.otf</tt><br />
<br />
<br />
== Example ==<br />
<br />
<br />
Now to access, say the regular warnock font, the following are valid. And I ought to mention that Hans recommends the first http://article.gmane.org/gmane.comp.tex.context/43685.<br />
<br />
<texcode><br />
% Hans recommends this format;<br />
\definefontsynonym [WarnockPro-Regular] [name:warnockproregular] <br />
</texcode><br />
<br />
and<br />
<br />
<texcode><br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular]<br />
</texcode><br />
<br />
An entire typescript would be defined as;<br />
<br />
<texcode><br />
\definefontfeature[latin-smallcaps][smallcaps][script=latn]<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\setups[font:fallback:sans]<br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular] <br />
\definefontsynonym [WarnockPro-Bold] [name:WarnockPro-Bold] <br />
\definefontsynonym [WarnockPro-Italic] [name:WarnockPro-It] <br />
\definefontsynonym [WarnockPro-BoldItalic] [name:WarnockPro-BoldIt] <br />
\stoptypescript<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\definefontsynonym [Serif] [WarnockPro-Regular] [features=default]<br />
\definefontsynonym [SerifBold] [WarnockPro-Bold] [features=default]<br />
\definefontsynonym [SerifItalic] [WarnockPro-Italic] [features=default]<br />
\definefontsynonym [SerifBoldItalic] [WarnockPro-BoldItalic] [features=default]<br />
\definefontsynonym [SerifCaps] [Serif] [features=latin-smallcaps]<br />
\stoptypescript<br />
<br />
\definetypeface[adobe][rm][serif][warnockpro][default]<br />
\setupbodyfont[adobe,11pt]<br />
<br />
</texcode><br />
<br />
[[Category:Fonts]]<br />
[[Category:International]]</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Fonts_in_LuaTeX&diff=9777Fonts in LuaTeX2009-06-01T00:02:08Z<p>Nicolas Girard: </p>
<hr />
<div>{{note|This page is not finished yet}}<br />
<br />
'''Please, someone, fill this page !'''<br />
<br />
'''This page is beeing regorganized'''<br />
<br />
= Getting access to the system fonts =<br />
<br />
LuaTeX can use non-TeX fonts (in OpenType, TrueType or Type1 format) directly.<br />
<br />
The first time that you run<br />
<br />
context myfile.tex<br />
<br />
on a file that uses such non-traditional fonts (which is probably always), the actual fonts themselves have to be loaded in luatex's embedded section of fontforge to extract their metric information. This removes the need for tfm and vf files on your disk, but it is also a somewhat lengthy and often memory-hungry process.<br />
<br />
That is why the results of that internal preprocessing are also saved inside the texmf cache. Future runs using the same font (not just this file, but all files using that particular font) can then use the cached version of the metrics instead. <br />
<br />
== Building the font database ==<br />
<br />
You need to specify where the fonts should be looked for, by setting the <code>OSFONTDIR</code> environment variable. For instance,<br />
set OSFONTDIR=c:/windows/fonts/<br />
if the fonts should be found in <code>c:/windows/fonts/</code>; or<br />
export OSFONTDIR="/usr/local/share/fonts;$HOME/.fonts"<br />
if the fonts should be found in both <code>/usr/local/share/fonts</code> and <code>$HOME/.fonts</code>.<br />
<br />
The font database will then be automatically generated in the next run of <code>context</code><br />
<br />
You can also generate it manually by typing <br />
mtxrun --script font --reload<br />
or equally<br />
mtxrun --script fonts --reload<br />
<br />
The output should look like<br />
MTXrun | fontnames: identifying tree font files with suffix otf<br />
MTXrun | fontnames: identifying tree font files with suffix OTF<br />
MTXrun | fontnames: 331 tree files identified, 332 hash entries added, runtime 7.653 seconds<br />
MTXrun | fontnames: identifying tree font files with suffix ttf<br />
MTXrun | fontnames: identifying tree font files with suffix TTF<br />
MTXrun | fontnames: 17 tree files identified, 14 hash entries added, runtime 4.645 seconds<br />
...<br />
MTXrun | fontnames: 94 system files identified, 94 hash entries added, runtime 0.554 seconds<br />
MTXrun | fontnames: 3837 files read, 3342 normal and 49 extra entries added, 5 rejected, 3386 valid<br />
<br />
<br />
<br />
== Querying the font database ==<br />
<br />
The command<br />
mtxrun --script fonts --list<br />
will return the whole entries of the font database as a list, such as<br />
<br />
...<br />
warnockprobold WarnockPro-Bold E:/Fonts/Warnock Pro/WarnockPro-Bold.otf<br />
warnockproboldcapt WarnockPro-BoldCapt E:/Fonts/Warnock Pro/WarnockPro-BoldCapt.otf<br />
warnockprobolddisp WarnockPro-BoldDisp E:/Fonts/Warnock Pro/WarnockPro-BoldDisp.otf<br />
warnockproboldit WarnockPro-BoldIt E:/Fonts/Warnock Pro/WarnockPro-BoldIt.otf<br />
warnockprobolditcapt WarnockPro-BoldItCapt E:/Fonts/Warnock Pro/WarnockPro-BoldItCapt.otf<br />
warnockprobolditdisp WarnockPro-BoldItDisp E:/Fonts/Warnock Pro/WarnockPro-BoldItDisp.otf<br />
warnockprobolditsubh WarnockPro-BoldItSubh E:/Fonts/Warnock Pro/WarnockPro-BoldItSubh.otf<br />
warnockproboldsubh WarnockPro-BoldSubh E:/Fonts/Warnock Pro/WarnockPro-BoldSubh.otf<br />
...<br />
<br />
You can query the database against a particular pattern. For instance,<br />
mtxrun --script fonts --list --pattern=Delicious*<br />
will return<br />
deliciousbold Delicious-Bold /usr/local/share/fonts/d/delicious_bold.otf<br />
deliciousbolditalic Delicious-BoldItalic /usr/local/share/fonts/d/delicious_bolditalic.otf<br />
deliciousheavy Delicious-Heavy /usr/local/share/fonts/d/delicious_heavy.otf<br />
deliciousitalic Delicious-Italic /usr/local/share/fonts/d/delicious_italic.otf<br />
deliciousroman Delicious-Roman /usr/local/share/fonts/d/delicious_roman.otf<br />
delicioussmallcaps Delicious-SmallCaps /usr/local/share/fonts/d/delicious_smallcaps.otf<br />
<br />
You can get useful informations about your fonts by using the <code>--info</code> option. For instance,<br />
mtxrun --script fonts --list --info --pattern=Delicious*Roman<br />
will return<br />
MTXrun | fontname: deliciousroman<br />
MTXrun | fullname: Delicious-Roman<br />
MTXrun | filename: /usr/local/share/fonts/d/delicious_roman.otf<br />
MTXrun |<br />
MTXrun | gpos features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | kern latn dflt<br />
MTXrun |<br />
MTXrun | gsub features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | tlig all all<br />
MTXrun | trep all all<br />
<br />
== Installing new fonts ==<br />
<br />
After installing new fonts, the font database must be rebuilt for LuaTeX to access them.<br />
<br />
In current versions of Mark IV (earlier than July 2008) this is automatically done whenever a named font cannot be found.<br />
<br />
You only have to do the reload manually when you have installed updates to already installed fonts that cause the font and/or file names to change. <br />
This normally only happens for fonts that are still in development like [[TeX Gyre]] and [[Latin Modern]].<br />
<br />
You can rebuild the database manually, using the already-mentioned command<br />
mtxrun --script fonts --reload<br />
<br />
Alternatively, you can turn off the automatic rebuild of the database, by setting either of<br />
MTX.FONTS.AUTOLOAD<br />
MTX_FONTS_AUTOLOAD<br />
to "no".<br />
<br />
== References ==<br />
<br />
[http://context.aanhet.net/svn/contextman/context-reference/en/co-fonts.pdf The new manual chapter on fonts]<br />
<br />
= Using fonts =<br />
<br />
= Old contents =<br />
<br />
==== Good ol' typescripts ====<br />
<br />
Of course, Mark IV allows you to use typescripts as you've always done; for example:<br />
<br />
<texcode><br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,12pt]<br />
effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
<br />
\sc effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
</texcode><br />
<br />
That's as simple as using a traditional ConTeXt typescript!<br />
<br />
But ... how is it any different, then? Well, the difference is that in Mark IV, we can use an Opentype font directly, so that what is done here: when we want to use Palatino, the [[TeX Gyre]] equivalent (“Pagella”) is called and we can use its Opentype “features”; read on.<br />
<br />
==== Opentype features ====<br />
<br />
A “feature”, in the Opentype jargon, is a set of rules describing changes in the appearance of the text. Hmm, that's not very precise. Let's show some examples. First of all, you have to know that features are referred to by 4-letter tags, and you will see this a lot. One of them is ‘smcp‘, for “small caps“. Let's consider the following Mark IV-only code:<br />
<br />
<texcode><br />
\definefontfeature[smallcaps][language=DFLT,script=latn,smcp=yes]<br />
\font\palasmallcaps=texgyrepagella-regular*smallcaps<br />
\palasmallcaps This is a text in small capitals.<br />
</texcode><br />
<br />
Here you basically define a (Mark IV) feature with the name ”smallcaps”, and associate it with the (Opentype) feature “smcp”. You have to specify which script you want to use it with; scripts in Opentype are also tagged with four letters, and “latn” is of course Latin.<br />
<br />
Then you define a TeX font with that feature.<br />
<br />
You can see what features are defined in a particular font with the following bit of code<br />
<br />
<texcode><br />
\ctxlua<br />
{<br />
fontname = 'texgyrepagella-regular.otf'<br />
<br />
--[[ First read the font data.<br />
This makes heavy use of some of the Mark IV code]]<br />
tfmdata = fonts.tfm.read_and_define("file:" .. fontname, 655360)<br />
font = tfmdata.shared.otfdata<br />
if font<br />
then<br />
gsubfeatures = fonts.otf.analyze_features(font.gsub)<br />
gposfeatures = fonts.otf.analyze_features(font.gpos)<br />
end<br />
<br />
if gsubfeatures then<br />
table.sort(gsubfeatures) % We want our list sorted alphabetically!<br />
tex.sprint("\\rm GSUB features: \\tt ") % Beware: you don't want \rm to be interpreted by lua (\rm would yield carriage return + letter m)!<br />
for _, feat in ipairs(gsubfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GSUB features")<br />
end<br />
tex.sprint("\\par")<br />
<br />
if gposfeatures then<br />
tex.sprint("\\rm GPOS features: \\tt ")<br />
table.sort(gposfeatures)<br />
for _, feat in ipairs(gposfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GPOS features")<br />
end<br />
}<br />
</texcode><br />
<br />
It prints the list on the page. You'll notice there are two sets of features, each one of them defined in a different table of the Opentype font: the <code>GSUB</code> table (for Glyph SUBstitution) gives rules for replacing glyphs in certains circumstances (think of ligatures: f + i -> fi); the <code>GPOS</code> table (Glyph POSititioning) gives rules for moving glyphs (think of kerning: A + V -> A <kerning> V).<br />
<br />
Incidentally, the above code gives some basic examples of LuaTeX programming, a mixture of both Lua and TeX programming with some special features (features in the general sense, not the Opentype one :-).<br />
<br />
==== A (Complete) Typescript Example ====<br />
<br />
<texcode><br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [FranklinBookRegular] [name:FranklinGothicBookITC-Regular] [features=default]<br />
\definefontsynonym [FranklinMediumRegular] [name:FranklinGothicMediumITC-Regular] [features=default]<br />
\definefontsynonym [FranklinDemiRegular] [name:FranklinGothicDemiITC-Regular] [features=default]<br />
\definefontsynonym [FranklinHeavyRegular] [name:FranklinGothicHeavyITC-Regular] [features=default]<br />
<br />
\definefontsynonym [FranklinBookItalic] [name:FranklinGothicBookITC-Italic] [features=default]<br />
\definefontsynonym [FranklinDemiItalic] [name:FranklinGothicMediumITC-Italic] [features=default]<br />
\definefontsynonym [FranklinHeavyItalic] [name:FranklinGothicDemiITC-Italic] [features=default]<br />
\definefontsynonym [FranklinMediumItalic] [name:FranklinGothicHeavyITC-Italic] [features=default]<br />
<br />
\stoptypescript<br />
<br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [Sans] [FranklinBookRegular] [features=default]<br />
\definefontsynonym [SansItalic] [FranklinBookItalic] [features=default]<br />
\definefontsynonym [SansBold] [FranklinDemiRegular] [features=default]<br />
\definefontsynonym [SansBoldItalic] [FranklinDemiItalic] [features=default]<br />
\definefontsynonym [SansSlanted] [SansItalic] [features=default]<br />
\definefontsynonym [SansBoldSlanted] [SansBoldItalic] [features=default]<br />
\definefontsynonym [SansCaps] [Sans] [features=smallcaps]<br />
<br />
\stoptypescript<br />
<br />
\definetypeface[franklin][rm][sans][franklin][default]<br />
\definetypeface[franklin][ss][sans][franklin][default]<br />
\definetypeface[franklin][tt][mono][modern] [default][rscale=1.12]<br />
\definetypeface[franklin][mm][math][iwona] [default][rscale=1.02]<br />
<br />
\setupbodyfont[franklin,ss,10pt]<br />
</texcode><br />
<br />
<br />
<br />
Just the simplest way to use an otf font — or any font that does appear in <tt>mtxrun --script font --list</tt> — in all the document.<br />
<br />
I’m stick here :<br />
<br />
\definefontfeature [myfontfeature] [method=node, kern=yes, OTHER_FEATURE_COMMA_SEPERATED]<br />
\definefontsynonym [MyFontRegular] [name:TheFontName-Regular][features=myfontfeature]<br />
\definedfont [MyFontRegular at 16pt]<br />
<br />
This doesn’t run for my title which use « \tfc », only for the body of the text.<br />
<br />
*\definefontfeature<br />
**[myfontfeature] : you can use the name you want. It will be use at the next line ;<br />
**the fonts feature can be found with <tt>otfinfo -f TheFontFile.otf</tt>.<br />
*\definefontsynonym :<br />
**[MyFontRegular] : you can use the name you want. It will be use at the next line ;<br />
**The name after <tt>name:</tt> is the name given by <tt>mtxrun --script font --list</tt><br />
**The « name: » part can be replaced by <tt>file:TheFontFile.otf</tt><br />
<br />
<br />
== Example ==<br />
<br />
<br />
Now to access, say the regular warnock font, the following are valid. And I ought to mention that Hans recommends the first http://article.gmane.org/gmane.comp.tex.context/43685.<br />
<br />
<texcode><br />
% Hans recommends this format;<br />
\definefontsynonym [WarnockPro-Regular] [name:warnockproregular] <br />
</texcode><br />
<br />
and<br />
<br />
<texcode><br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular]<br />
</texcode><br />
<br />
An entire typescript would be defined as;<br />
<br />
<texcode><br />
\definefontfeature[latin-smallcaps][smallcaps][script=latn]<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\setups[font:fallback:sans]<br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular] <br />
\definefontsynonym [WarnockPro-Bold] [name:WarnockPro-Bold] <br />
\definefontsynonym [WarnockPro-Italic] [name:WarnockPro-It] <br />
\definefontsynonym [WarnockPro-BoldItalic] [name:WarnockPro-BoldIt] <br />
\stoptypescript<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\definefontsynonym [Serif] [WarnockPro-Regular] [features=default]<br />
\definefontsynonym [SerifBold] [WarnockPro-Bold] [features=default]<br />
\definefontsynonym [SerifItalic] [WarnockPro-Italic] [features=default]<br />
\definefontsynonym [SerifBoldItalic] [WarnockPro-BoldItalic] [features=default]<br />
\definefontsynonym [SerifCaps] [Serif] [features=latin-smallcaps]<br />
\stoptypescript<br />
<br />
\definetypeface[adobe][rm][serif][warnockpro][default]<br />
\setupbodyfont[adobe,11pt]<br />
<br />
</texcode><br />
<br />
[[Category:Fonts]]<br />
[[Category:International]]</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Fonts_in_LuaTeX&diff=9776Fonts in LuaTeX2009-06-01T00:00:39Z<p>Nicolas Girard: /* Getting access to the system fonts */ +Section: References</p>
<hr />
<div>{{note|This page is not finished yet}}<br />
<br />
'''Please, someone, fill this page !'''<br />
<br />
'''This page is beeing regorganized'''<br />
<br />
= Getting access to the system fonts =<br />
<br />
LuaTeX can use non-TeX fonts (in OpenType, TrueType or Type1 format) directly.<br />
<br />
The first time that you run<br />
<br />
context myfile.tex<br />
<br />
on a file that uses such non-traditional fonts (which is probably always), the actual fonts themselves have to be loaded in luatex's embedded section of fontforge to extract their metric information. This removes the need for tfm and vf files on your disk, but it is also a somewhat lengthy and often memory-hungry process.<br />
<br />
That is why the results of that internal preprocessing are also saved inside the texmf cache. Future runs using the same font (not just this file, but all files using that particular font) can then use the cached version of the metrics instead. <br />
<br />
== Building the font database ==<br />
<br />
You need to specify where the fonts should be looked for, by setting the <code>OSFONTDIR</code> environment variable. For instance,<br />
set OSFONTDIR=c:/windows/fonts/<br />
if the fonts should be found in <code>c:/windows/fonts/</code>; or<br />
export OSFONTDIR="/usr/local/share/fonts;$HOME/.fonts"<br />
if the fonts should be found in both <code>/usr/local/share/fonts</code> and <code>$HOME/.fonts</code>.<br />
<br />
The font database will then be automatically generated in the next run of <code>context</code><br />
<br />
You can also generate it manually by typing <br />
mtxrun --script font --reload<br />
or equally<br />
mtxrun --script fonts --reload<br />
<br />
The output should look like<br />
MTXrun | fontnames: identifying tree font files with suffix otf<br />
MTXrun | fontnames: identifying tree font files with suffix OTF<br />
MTXrun | fontnames: 331 tree files identified, 332 hash entries added, runtime 7.653 seconds<br />
MTXrun | fontnames: identifying tree font files with suffix ttf<br />
MTXrun | fontnames: identifying tree font files with suffix TTF<br />
MTXrun | fontnames: 17 tree files identified, 14 hash entries added, runtime 4.645 seconds<br />
...<br />
MTXrun | fontnames: 94 system files identified, 94 hash entries added, runtime 0.554 seconds<br />
MTXrun | fontnames: 3837 files read, 3342 normal and 49 extra entries added, 5 rejected, 3386 valid<br />
<br />
<br />
<br />
== Querying the font database ==<br />
<br />
The command<br />
mtxrun --script fonts --list<br />
will return the whole entries of the font database as a list, such as<br />
<br />
...<br />
warnockprobold WarnockPro-Bold E:/Fonts/Warnock Pro/WarnockPro-Bold.otf<br />
warnockproboldcapt WarnockPro-BoldCapt E:/Fonts/Warnock Pro/WarnockPro-BoldCapt.otf<br />
warnockprobolddisp WarnockPro-BoldDisp E:/Fonts/Warnock Pro/WarnockPro-BoldDisp.otf<br />
warnockproboldit WarnockPro-BoldIt E:/Fonts/Warnock Pro/WarnockPro-BoldIt.otf<br />
warnockprobolditcapt WarnockPro-BoldItCapt E:/Fonts/Warnock Pro/WarnockPro-BoldItCapt.otf<br />
warnockprobolditdisp WarnockPro-BoldItDisp E:/Fonts/Warnock Pro/WarnockPro-BoldItDisp.otf<br />
warnockprobolditsubh WarnockPro-BoldItSubh E:/Fonts/Warnock Pro/WarnockPro-BoldItSubh.otf<br />
warnockproboldsubh WarnockPro-BoldSubh E:/Fonts/Warnock Pro/WarnockPro-BoldSubh.otf<br />
...<br />
<br />
You can query the database against a particular pattern. For instance,<br />
mtxrun --script fonts --list --pattern=Delicious*<br />
will return<br />
deliciousbold Delicious-Bold /usr/local/share/fonts/d/delicious_bold.otf<br />
deliciousbolditalic Delicious-BoldItalic /usr/local/share/fonts/d/delicious_bolditalic.otf<br />
deliciousheavy Delicious-Heavy /usr/local/share/fonts/d/delicious_heavy.otf<br />
deliciousitalic Delicious-Italic /usr/local/share/fonts/d/delicious_italic.otf<br />
deliciousroman Delicious-Roman /usr/local/share/fonts/d/delicious_roman.otf<br />
delicioussmallcaps Delicious-SmallCaps /usr/local/share/fonts/d/delicious_smallcaps.otf<br />
<br />
You can get useful informations about your fonts by using the <code>--info</code> option. For instance,<br />
mtxrun --script fonts --list --info --pattern=Delicious*Roman<br />
will return<br />
MTXrun | fontname: deliciousroman<br />
MTXrun | fullname: Delicious-Roman<br />
MTXrun | filename: /usr/local/share/fonts/d/delicious_roman.otf<br />
MTXrun |<br />
MTXrun | gpos features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | kern latn dflt<br />
MTXrun |<br />
MTXrun | gsub features:<br />
MTXrun |<br />
MTXrun | feature script languages<br />
MTXrun |<br />
MTXrun | tlig all all<br />
MTXrun | trep all all<br />
<br />
== Installing new fonts ==<br />
<br />
After installing new fonts, the font database must be rebuilt for LuaTeX to access them.<br />
<br />
In current versions of Mark IV (earlier than July 2008) this is automatically done whenever a named font cannot be found.<br />
<br />
You only have to do the reload manually when you have installed updates to already installed fonts that cause the font and/or file names to change. <br />
This normally only happens for fonts that are still in development like [[TeX Gyre]] and [[Latin Modern]].<br />
<br />
You can rebuild the database manually, using the already-mentioned command<br />
mtxrun --script fonts --reload<br />
<br />
Alternatively, you can turn off the automatic rebuild of the database, by setting either of<br />
MTX.FONTS.AUTOLOAD<br />
MTX_FONTS_AUTOLOAD<br />
to "no".<br />
<br />
== References ==<br />
<br />
[http://context.aanhet.net/svn/contextman/context-reference/en/co-fonts.pdf The new manual chapter on fonts]<br />
<br />
= Old contents =<br />
<br />
==== Good ol' typescripts ====<br />
<br />
Of course, Mark IV allows you to use typescripts as you've always done; for example:<br />
<br />
<texcode><br />
\usetypescript[palatino]<br />
\setupbodyfont[palatino,12pt]<br />
effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
<br />
\sc effe fietsen 2: \input tufte $\sqrt{2}$ \eogonek<br />
</texcode><br />
<br />
That's as simple as using a traditional ConTeXt typescript!<br />
<br />
But ... how is it any different, then? Well, the difference is that in Mark IV, we can use an Opentype font directly, so that what is done here: when we want to use Palatino, the [[TeX Gyre]] equivalent (“Pagella”) is called and we can use its Opentype “features”; read on.<br />
<br />
==== Opentype features ====<br />
<br />
A “feature”, in the Opentype jargon, is a set of rules describing changes in the appearance of the text. Hmm, that's not very precise. Let's show some examples. First of all, you have to know that features are referred to by 4-letter tags, and you will see this a lot. One of them is ‘smcp‘, for “small caps“. Let's consider the following Mark IV-only code:<br />
<br />
<texcode><br />
\definefontfeature[smallcaps][language=DFLT,script=latn,smcp=yes]<br />
\font\palasmallcaps=texgyrepagella-regular*smallcaps<br />
\palasmallcaps This is a text in small capitals.<br />
</texcode><br />
<br />
Here you basically define a (Mark IV) feature with the name ”smallcaps”, and associate it with the (Opentype) feature “smcp”. You have to specify which script you want to use it with; scripts in Opentype are also tagged with four letters, and “latn” is of course Latin.<br />
<br />
Then you define a TeX font with that feature.<br />
<br />
You can see what features are defined in a particular font with the following bit of code<br />
<br />
<texcode><br />
\ctxlua<br />
{<br />
fontname = 'texgyrepagella-regular.otf'<br />
<br />
--[[ First read the font data.<br />
This makes heavy use of some of the Mark IV code]]<br />
tfmdata = fonts.tfm.read_and_define("file:" .. fontname, 655360)<br />
font = tfmdata.shared.otfdata<br />
if font<br />
then<br />
gsubfeatures = fonts.otf.analyze_features(font.gsub)<br />
gposfeatures = fonts.otf.analyze_features(font.gpos)<br />
end<br />
<br />
if gsubfeatures then<br />
table.sort(gsubfeatures) % We want our list sorted alphabetically!<br />
tex.sprint("\\rm GSUB features: \\tt ") % Beware: you don't want \rm to be interpreted by lua (\rm would yield carriage return + letter m)!<br />
for _, feat in ipairs(gsubfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GSUB features")<br />
end<br />
tex.sprint("\\par")<br />
<br />
if gposfeatures then<br />
tex.sprint("\\rm GPOS features: \\tt ")<br />
table.sort(gposfeatures)<br />
for _, feat in ipairs(gposfeatures)<br />
do tex.sprint(feat) tex.sprint(' ')<br />
end<br />
else tex.sprint("\\rm No GPOS features")<br />
end<br />
}<br />
</texcode><br />
<br />
It prints the list on the page. You'll notice there are two sets of features, each one of them defined in a different table of the Opentype font: the <code>GSUB</code> table (for Glyph SUBstitution) gives rules for replacing glyphs in certains circumstances (think of ligatures: f + i -> fi); the <code>GPOS</code> table (Glyph POSititioning) gives rules for moving glyphs (think of kerning: A + V -> A <kerning> V).<br />
<br />
Incidentally, the above code gives some basic examples of LuaTeX programming, a mixture of both Lua and TeX programming with some special features (features in the general sense, not the Opentype one :-).<br />
<br />
==== A (Complete) Typescript Example ====<br />
<br />
<texcode><br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [FranklinBookRegular] [name:FranklinGothicBookITC-Regular] [features=default]<br />
\definefontsynonym [FranklinMediumRegular] [name:FranklinGothicMediumITC-Regular] [features=default]<br />
\definefontsynonym [FranklinDemiRegular] [name:FranklinGothicDemiITC-Regular] [features=default]<br />
\definefontsynonym [FranklinHeavyRegular] [name:FranklinGothicHeavyITC-Regular] [features=default]<br />
<br />
\definefontsynonym [FranklinBookItalic] [name:FranklinGothicBookITC-Italic] [features=default]<br />
\definefontsynonym [FranklinDemiItalic] [name:FranklinGothicMediumITC-Italic] [features=default]<br />
\definefontsynonym [FranklinHeavyItalic] [name:FranklinGothicDemiITC-Italic] [features=default]<br />
\definefontsynonym [FranklinMediumItalic] [name:FranklinGothicHeavyITC-Italic] [features=default]<br />
<br />
\stoptypescript<br />
<br />
\starttypescript [sans] [franklin]<br />
<br />
\definefontsynonym [Sans] [FranklinBookRegular] [features=default]<br />
\definefontsynonym [SansItalic] [FranklinBookItalic] [features=default]<br />
\definefontsynonym [SansBold] [FranklinDemiRegular] [features=default]<br />
\definefontsynonym [SansBoldItalic] [FranklinDemiItalic] [features=default]<br />
\definefontsynonym [SansSlanted] [SansItalic] [features=default]<br />
\definefontsynonym [SansBoldSlanted] [SansBoldItalic] [features=default]<br />
\definefontsynonym [SansCaps] [Sans] [features=smallcaps]<br />
<br />
\stoptypescript<br />
<br />
\definetypeface[franklin][rm][sans][franklin][default]<br />
\definetypeface[franklin][ss][sans][franklin][default]<br />
\definetypeface[franklin][tt][mono][modern] [default][rscale=1.12]<br />
\definetypeface[franklin][mm][math][iwona] [default][rscale=1.02]<br />
<br />
\setupbodyfont[franklin,ss,10pt]<br />
</texcode><br />
<br />
<br />
<br />
Just the simplest way to use an otf font — or any font that does appear in <tt>mtxrun --script font --list</tt> — in all the document.<br />
<br />
I’m stick here :<br />
<br />
\definefontfeature [myfontfeature] [method=node, kern=yes, OTHER_FEATURE_COMMA_SEPERATED]<br />
\definefontsynonym [MyFontRegular] [name:TheFontName-Regular][features=myfontfeature]<br />
\definedfont [MyFontRegular at 16pt]<br />
<br />
This doesn’t run for my title which use « \tfc », only for the body of the text.<br />
<br />
*\definefontfeature<br />
**[myfontfeature] : you can use the name you want. It will be use at the next line ;<br />
**the fonts feature can be found with <tt>otfinfo -f TheFontFile.otf</tt>.<br />
*\definefontsynonym :<br />
**[MyFontRegular] : you can use the name you want. It will be use at the next line ;<br />
**The name after <tt>name:</tt> is the name given by <tt>mtxrun --script font --list</tt><br />
**The « name: » part can be replaced by <tt>file:TheFontFile.otf</tt><br />
<br />
<br />
== Example ==<br />
<br />
<br />
Now to access, say the regular warnock font, the following are valid. And I ought to mention that Hans recommends the first http://article.gmane.org/gmane.comp.tex.context/43685.<br />
<br />
<texcode><br />
% Hans recommends this format;<br />
\definefontsynonym [WarnockPro-Regular] [name:warnockproregular] <br />
</texcode><br />
<br />
and<br />
<br />
<texcode><br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular]<br />
</texcode><br />
<br />
An entire typescript would be defined as;<br />
<br />
<texcode><br />
\definefontfeature[latin-smallcaps][smallcaps][script=latn]<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\setups[font:fallback:sans]<br />
\definefontsynonym [WarnockPro-Regular] [name:WarnockPro-Regular] <br />
\definefontsynonym [WarnockPro-Bold] [name:WarnockPro-Bold] <br />
\definefontsynonym [WarnockPro-Italic] [name:WarnockPro-It] <br />
\definefontsynonym [WarnockPro-BoldItalic] [name:WarnockPro-BoldIt] <br />
\stoptypescript<br />
<br />
\starttypescript [serif] [warnockpro]<br />
\definefontsynonym [Serif] [WarnockPro-Regular] [features=default]<br />
\definefontsynonym [SerifBold] [WarnockPro-Bold] [features=default]<br />
\definefontsynonym [SerifItalic] [WarnockPro-Italic] [features=default]<br />
\definefontsynonym [SerifBoldItalic] [WarnockPro-BoldItalic] [features=default]<br />
\definefontsynonym [SerifCaps] [Serif] [features=latin-smallcaps]<br />
\stoptypescript<br />
<br />
\definetypeface[adobe][rm][serif][warnockpro][default]<br />
\setupbodyfont[adobe,11pt]<br />
<br />
</texcode><br />
<br />
[[Category:Fonts]]<br />
[[Category:International]]</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Fonts_-_Old_Content&diff=9775Fonts - Old Content2009-05-31T23:46:20Z<p>Nicolas Girard: Added Fonts_in_LuaTex on top of the page</p>
<hr />
<div>< [[Visuals]] | [[Symbols]] ><br />
<br />
'''The ConTeXt way of handling fonts are [[TypeScripts]].''' It’s a system of abstraction and aliases, which may seem “strange” at first for LaTeX users.<br />
* If you happen to use [[XeTeX]] then you can forget almost all the magic and start using your system fonts (see [[Fonts_in_XeTeX]]).<br />
* If you use [[LuaTeX]], see [[Fonts_in_LuaTex]]<br />
* If you want to keep using [[pdfTeX]], read on.<br />
<br />
= Unsorted links =<br />
<br />
* [http://www.pragma-ade.com/general/manuals/mtexfont.pdf font installation with texfont] by Pragma<br />
* [http://www.pragma-ade.com/general/manuals/mfonts.pdf ConTeXt's font mechanism in detail] by Pragma<br />
* [http://tug.org/TUGboat/Articles/tb28-2/tb89mahajan.pdf ConTeXt basics for users: Font styles] by Aditya Mahajan (2007)<br />
* [http://www.pragma-ade.com/general/manuals/mmakempy.pdf making outlines] by Pragma<br />
* [http://pragma-ade.com/specials/fonts/fontspecial-p.pdf Here] you can try out several TeX fonts online (PDF interface!)<br />
* Troubleshooting: solving [[TeXfont]] problems.<br />
* Character [[Protrusion]] (also known as hanging or font handling) is a more subtle typographic effect.<br />
* [[Font Handling Internals]]<br />
* [http://homepage.mac.com/atl/tex/ Adam Lindsay's page] focuses on typography (OpenType, Unicode etc.), esp. on MacOS X<br />
* [http://watershade.net/wmcclain/context-help.html Bill McClain's ConTeXt beginners page] has also a lot about fonts<br />
* [http://tug.org/pracjourn/2005-2/schmitz/schmitz.pdf Integrating TrueType Fonts into ConTeXt] by Thomas A. Schmitz (PracTeX Journal)<br />
* [[Installing a TrueType font, step by step]]. If you just need to install a TrueType font, this may be what you are looking for.<br />
* [http://dl.contextgarden.net/myway/expertfonts.pdf Installing Expert Fonts: Minion Pro] by Idris Samawi Hamid; contains step-by-step instructions, from preinstallation to writing typescripts<br />
* [[Pseudo Small Caps]] by Vit Zyka<br />
* Matt Gushee's introduction to [http://havenrock.com/textips/bookfonts.html virtual fonts], especially for getting expert fonts to work.<br />
* [[URW Garamond]]<br />
* [[otfinstall|otfinst - a sample ruby script for using OpenType fonts in ConTeXt]]<br />
* [[Understanding how fonts work in ConTeXt]]<br />
* [[A Beginner's Guide to Using Fonts in Mark IV]]<br />
<br />
=Basic Hints=<br />
<br />
''Some hints by Taco from the mailing list on 2005-11-20:''<br />
<br />
Q: How up to date or out of date is the information in [http://www.pragma-ade.com/general/manuals/mfonts.pdf mfonts manual]?<br />
<br />
A: It looks like it is still quite up-to-date, but some of the examples it gives may no longer be the very best and latest way of doing things, and possibly there are some new developments that do not get as much attention as desired (like [http://www.pragma-ade.com/general/manuals/mtexfont.pdf texfont], and the issues arising from font map files). Overall, the document appears accurate, though.<br />
<br />
An important thing to remember is this:<br />
<br />
'''ConTeXt does not share font metric conventions with LaTeX.'''<br />
<br />
(at one point it started doing so, like supporting the ''Karl Berry naming scheme'' and the ''PSNFSS'' style font family names, but that has since been abandoned).<br />
<br />
Another important thing is that it also does not share font map files with LaTeX and, specifically,<br />
<br />
'''ConTeXt does not make pdfetex read <tt>pdftex.map</tt>.'''<br />
<br />
(this is at the root of a great many problems reported by users only familiar with PSNFSS)<br />
<br />
The preferred format for metric files in ConTeXt is<br />
<br />
<tt><vendor>/<familyname>/<encoding>-<fontname>.tfm</tt><br />
<br />
for metrics and<br />
<br />
<tt><encoding>-<vendor>-<familyname>.map</tt><br />
<br />
for the mapping files.<br />
<br />
* <fontname> is usually derived from the font source (afm or ttf),<br />
* <encoding> is a 'controlled' list, (see [[Encodings and Regimes]])<br />
* <vendor> and <familyname> are user-supplied (at install time).<br />
<br />
There are ways to trick ConTeXt into using different conventions, but if you do that you are likely to run into trouble.<br />
<br />
=Configuration=<br />
* Using [[psnfss]] metrics in ConTeXt<br />
* Matt Gushee about [http://havenrock.com/textips/bookfonts.html virtual fonts]<br />
* Fonts rely on [[Encodings and Regimes]], and it helps to know what happens underneath the hood, from time to time.<br />
* In newer distributions, map files belong in <tt>&hellip;/fonts/map/pdftex/context</tt>!<br />
* Don't forget to look at [[cont-sys.tex]]!<br />
<br />
= Available Free Fonts =<br />
* [http://ctan.tug.org/tex-archive/info/Free_Math_Font_Survey/survey.html Free Math Fonts] : overview of different free Math fonts; [http://www.geocities.com/hartke01/ links to other free fonts]<br />
* [http://greekfontsociety.org/ GFS Didot] : Latin, full set of polytonik Greek, small caps, oldstyle figures, full f-ligatures ([http://modules.contextgarden.net/gfsdidot Module for ConTeXt])<br />
* [[TeX Gyre]] : a set of great text fonts by our GUST friends, based on URW's free PostScript standard fonts for GhostScript.<br />
* [http://www.janusz.nowacki.strefa.pl/kurier.html Foto Alfa] : some TeX related fonts from Poland (Antykwa Toruńska. Antykwa Półtawskiego, Kurier, Iwona...)<br />
* [http://linuxlibertine.sourceforge.net Libertine Open Fonts Project]: GPL/OFL serif font<br />
* [http://scripts.sil.org SIL International] : great Unicode fonts for scholars by SIL (Gentium, Doulos, Charis, etc.)<br />
* [http://ist-socrates.berkeley.edu/~pinax/greekkeys/GreekKeys.html GreekKeys] : links to polytonic Greek fonts<br />
* [http://scholarsfonts.net Scholar's Fonts] : Font for Scholars (Latin, Germanic languages, Greek, Hebrew and Linguistics)<br />
* [http://www.engl.virginia.edu/OE/junicode/junicode.html Junicode] : Junius-Unicode, a font for medievalists<br />
* [http://www.freelang.net/fonts/index.html FreeLang fonts] : fonts for exotic languages<br />
* [http://www.blambot.com Blambot] : Comic fonts<br />
* [http://www.chank.com/freefonts.php Chank] : some free Chank fonts<br />
* [http://www.fontface.com/fonts/ FontFace] : free fonts<br />
* [http://www.dafont.com DaFont] : more free fonts<br />
* [http://fonts.tom7.com/fonts98.html Divide by Zero] : more fonts<br />
* [http://moorstation.org/typoasis/typoasis1.htm TypOasis] : lots of nice fonts, but a bit hard to find (have a look at designers Apostrophic Lab, Manfred Klein and Dieter Steffmann)<br />
* [http://kadyellebee.com/fonts/ Kristine's Font Organization] : find a font in a sorted directory<br />
* [http://www.fontlover.com FontLover] : font news portal site<br />
* [http://www.stormtype.com/typefaces-fonts-shop/free.php Lido] : OpenType and TrueType typeface by Storm Type Foundry, free for non-commercial use. [http://modules.contextgarden.net/stormfontsupport Support].<br />
* [http://www.alanwood.net/unicode/fontsbyrange.html Alan Wood’s Unicode Resources] : find fonts by Unicode character range<br />
* [http://www.josbuivenga.demon.nl/ exljbris] Free Quality Font Foundry by Jos Buivenga<br />
* [http://www.stixfonts.org/ STIX Fonts] Beta download of the STIX-Fonts<br />
* ''... many more to be added ...''<br />
<br />
= NonFree Font Support =<br />
* [[Lucida]] : large font family designed by Bigelow & Holmes; suitable e.g. for presentations<br />
* [http://www.stormtype.com Storm Type Foundry] : [http://modules.contextgarden.net/stormfontsupport support] of selected fonts<br />
<br />
=Hints by Language=<br />
* general: [[Encodings and Regimes]]<br />
* [[Arabic and Hebrew]] (Idris? other ArabTeX specialists?)<br />
* [[Chinese]]<br />
* [[Czech]]<br />
* [[Greek]]<br />
* [[Russian]]<br />
* [[Vietnamese]]<br />
<br />
[[Category:Fonts]]</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=LuaTeX&diff=9774LuaTeX2009-05-31T23:32:08Z<p>Nicolas Girard: Suppressed contents, either outdated or explained in Fonts in LuaTex. Correct me if i'm wrong !</p>
<hr />
<div>LuaTeX is an extended version of [[PdfTeX]] using [http://www.lua.org Lua], as an embedded scripting language. The LuaTeX project's main objective is to provide an open and configurable variant of TeX while at the same time offering downward compatibility.<br />
<br />
The project started in the summer of 2005, and has since progressed into a first official early beta that was released during the TUG2007 conference in San Diego. Development is supported by a grant from Colorado State University and the TeX User groups.<br />
<br />
The [http://www.luatex.org official website] offers some more information.<br />
<br />
== Links ==<br />
<br />
* http://luanet.net/lua<br />
<br />
== Some tricks ==<br />
<br />
=== Testing for UTF-8-aware TeX ===<br />
<br />
<i>(By [[User:Taco|Taco]]); this hint should be place to a better location on the wiki</i><br />
<br />
For luatex, one may test if <code>\luatexrevision</code> is defined.<br />
<br />
The next weird macro definition should work for testing xetex/luatex, because only xetex and luatex accept 5- and 6-byte caret notation (hex 22 == double quote):<br />
<texcode><br />
\def\"{0}\expandafter\def\csname^^^^^00022\endcsname{1}<br />
\ifnum\"=0 \message{tex82}\else\message{newstuff}\fi<br />
</texcode><br />
<br />
But that is not quite the same as testing for native UTF-8. Better is a trick like this:<br />
<br />
<texcode><br />
\def\test#1#2!{\def\secondarg{#2}}<br />
\test χ!\relax % That's Chi, a 2-byte utf-8 sequence<br />
\ifx\secondarg\empty \message{newstuff}\else \message{tex82}\fi<br />
</texcode><br />
<br />
ConTeXt offers <code>\beginNEWTEX ... \endNEWTEX</code> to test if one is using LuaTeX or XeTeX.<br />
<br />
<br />
== Fonts ==<br />
<br />
See [[Fonts in LuaTex]]</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=LuaTeX&diff=9773LuaTeX2009-05-31T23:30:02Z<p>Nicolas Girard: /* Fonts */ wrong link</p>
<hr />
<div>LuaTeX is an extended version of [[PdfTeX]] using [http://www.lua.org Lua], as an embedded scripting language. The LuaTeX project's main objective is to provide an open and configurable variant of TeX while at the same time offering downward compatibility.<br />
<br />
The project started in the summer of 2005, and has since progressed into a first official early beta that was released during the TUG2007 conference in San Diego. Development is supported by a grant from Colorado State University and the TeX User groups.<br />
<br />
The [http://www.luatex.org official website] offers some more information.<br />
<br />
== Links ==<br />
<br />
* http://luanet.net/lua<br />
<br />
== Some tricks ==<br />
<br />
=== Testing for UTF-8-aware TeX ===<br />
<br />
<i>(By [[User:Taco|Taco]]); this hint should be place to a better location on the wiki</i><br />
<br />
For luatex, one may test if <code>\luatexrevision</code> is defined.<br />
<br />
The next weird macro definition should work for testing xetex/luatex, because only xetex and luatex accept 5- and 6-byte caret notation (hex 22 == double quote):<br />
<texcode><br />
\def\"{0}\expandafter\def\csname^^^^^00022\endcsname{1}<br />
\ifnum\"=0 \message{tex82}\else\message{newstuff}\fi<br />
</texcode><br />
<br />
But that is not quite the same as testing for native UTF-8. Better is a trick like this:<br />
<br />
<texcode><br />
\def\test#1#2!{\def\secondarg{#2}}<br />
\test χ!\relax % That's Chi, a 2-byte utf-8 sequence<br />
\ifx\secondarg\empty \message{newstuff}\else \message{tex82}\fi<br />
</texcode><br />
<br />
ConTeXt offers <code>\beginNEWTEX ... \endNEWTEX</code> to test if one is using LuaTeX or XeTeX.<br />
<br />
== Environmental variables ==<br />
<br />
''(move to some more appropriate place)''<br />
<br />
=== TEXMFCACHE ===<br />
<br />
=== OSFONTDIR ===<br />
export OSFONTDIR=/Library/Fonts<br />
<br />
=== reloading font database when fonts are not found ===<br />
If you want your font database to be reloaded whenever a non-existing font is asked for in LuaTeX, you need to set one of the variables:<br />
MTX.FONTS.AUTOLOAD<br />
MTX_FONTS_AUTOLOAD<br />
<br />
== Fonts ==<br />
<br />
See [[Fonts in LuaTex]]</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Running_Mark_IV&diff=9772Running Mark IV2009-05-31T23:27:42Z<p>Nicolas Girard: /* Using fonts */ OSFONTDIR</p>
<hr />
<div>== Introduction ==<br />
<br />
ConTeXt [[Mark IV]] does not use the kpathsea library to find files and configuration settings. It follows that running mktexlsr or fmtutil has no effect. This page explains the details of <br />
setting up and maintaining [[Mark IV]].<br />
<br />
The most important motivation for this page is that the [[TeX Live]] 2008 edition contains Mark IV, but it is only copied to the installed system, no post-install setup takes place at all. This year, the post-install setup has to be done manually.<br />
<br />
If you have trouble following these instructions, please direct you questions or complaints on the [http://www.ntg.nl/mailman/listinfo/ntg-context ntg-context mailing list], '''not''' the tex-live list.<br />
<br />
<br />
Special notes:<br />
* '''Windows''': Running Mark IV under Windows is the same as on Unix, but see [[Running_Mark_IV#In_case_of_trouble|below]] for a installation hints for the 'spaces in names' problem that seem to affect Windows users more often than other platforms.<br />
* '''[[MacTeX]]''': You need to [[Running_Mark_IV#Updating_ConTeXt|update]] ConTeXt first.<br />
* '''Debian''': Mark IV suggests the tex-gyre package ([[TeX Gyre]]), not distributed currently under Debian due to licensing issues (see [[Debian installation]] )<br />
<br />
== Quickstart ==<br />
<br />
Just for the extremely impatient unix user that knows how to deal with a web2c-based TeX distribution and has a simple, private (single-user) installation, this is the only absolutely required extra knowledge:<br />
<br />
luatools --generate<br />
<br />
is the Mark IV replacement for mktexlsr.<br />
<br />
context --make<br />
<br />
is the Mark IV replacement for fmtutil.<br />
<br />
context myfile.tex<br />
<br />
typesets a file.<br />
<br />
Everybody else should read on.<br />
<br />
'''A note for windows users:''' the luatex executable doest not accept filenames with spaces in their name. This means that if you are on windows you will at least have to set up a texmfcnf.lua as explained below, and you likely will even have to reinstall texlive, because the default texlive installation directory itself contains spaces. [[Running_Mark_IV#File_not_found | Details]].<br />
<br />
== Updating ConTeXt ==<br />
<br />
Updating is not absolutely necessary unless you use [[MacTeX]], but most MKIV users will probably want to play with latest & greatest features.<br />
<br />
There's a work-in-progress to create a TL repository on the garden with the latest ConTeXt and LuaTeX, so that TeX Live users should be able to upgrade ConTeXt automatically.<br />
<br />
Until then you can update ConTeXt in different ways, for example with:<br />
rsync -av rsync://contextgarden.net/minimals/current/context/current/ /usr/local/texlive/2008/texmf-dist/<br />
<br />
To update LuaTeX you may use the following line (depending on your platform):<br />
rsync -av rsync://contextgarden.net/minimals/current/bin/luatex/<i><font color="#F00">platform-garden</font></i>/bin/luatex \<br />
/usr/local/texlive/2008/bin/<i><font color="#F00">platform-TL</font></i>/<br />
Which resolves to one of the following lines:<br />
rsync -av rsync://contextgarden.net/minimals/current/bin/luatex/freebsd/bin/luatex /usr/local/texlive/2008/bin/i386-freebsd/<br />
rsync -av rsync://contextgarden.net/minimals/current/bin/luatex/linux/bin/luatex /usr/local/texlive/2008/bin/i386-linux/<br />
rsync -av rsync://contextgarden.net/minimals/current/bin/luatex/linux-64/bin/luatex /usr/local/texlive/2008/bin/x86_64-linux/<br />
rsync -av rsync://contextgarden.net/minimals/current/bin/luatex/osx-universal/bin/luatex /usr/local/texlive/2008/bin/universal-darwin/<br />
<br />
You can upgrade XeTeX or metapost in the same way as LuaTeX.<br />
<br />
Of course you need to repeat all the steps mentioned above, for MKIV:<br />
luatools --generate<br />
context --make<br />
and for MKII:<br />
mktexlsr<br />
texexec --make --all<br />
texexec --make --xtx --all<br />
<br />
Note that this is a quick-and-dirty way to upgrade TL. Use at your own risk. One should be able to update in a more elegant way.<br />
<br />
== Generating and updating formats ==<br />
<br />
Before first use and after each update to either the [[context]] distribution or the [[luatex]] executable you will have to regenerate the formats. The command for that is:<br />
<br />
context --make cont-en<br />
<br />
This will generate a new Mark IV format with the English interface. Without an explicit format argument, it will generate four formats: Mark IV cont-en, Matk IV cont-nl, luatex+mptopdf, and luatex+plain.<br />
<br />
The generated formats are stored inside the texmf cache.<br />
<br />
== Using fonts ==<br />
<br />
The <code>OSFONTDIR</code> environment variable should contain the paths where the system fonts must be looked for.<br />
<br />
See [[Fonts in LuaTex#Getting access to the system fonts]]<br />
<br />
== Downloaded files ==<br />
<br />
If you have the program 'curl' installed, then your input file can contain e.g.<br />
<br />
<texcode><br />
\externalfigure<br />
[http://www.pragma-ade.com/show-gra.pdf]<br />
</texcode><br />
<br />
and the referenced file will be downloaded automatically and placed in the 'texmf cache' if is not found in the cache already.<br />
<br />
== In case of trouble ==<br />
<br />
=== File not found ===<br />
<br />
* You may get errors like<br />
I can't find file `C:/Program.tex'.<br />
This is likely caused by the luatex executable not handling filename quoting properly yet. If filenames with spaces work at all, you are just lucky.<br />
<br />
This problem is most likely to happen on Windows. There two steps to deal with it:<br />
* You must put the main texmf tree in path without spaces. If you're installing Mark IV via TeXLive 2008, then simply change the top installation path at install time.<br />
* If you're running XP or Server 2003 (and not Vista or Server 2008), you must also set the TeX user home and the Lua cache to paths without spaces. <code>C:/tlhome</code> is a good candidate.<br />
** In <code>texmf.cnf</code> set HOMETEXMF to <code>C:/tlhome/$USERNAME</code> or to something similar of your liking. Using $USERNAME in the path will still give a per-user directory, just not under "Documents and Settings". This assumes that the user name doesn't have spaces of course...<br />
** As mentioned above, create/edit <code>texmfcnf.lua</code> and put a line like <code>return { TEXMFCACHE = 'C:/tlhome/$USERNAME/.texlive2008/texmf-var' }</code>, which sets each user's cache inside his space-free TeX home path.<br />
<br />
== Cache internals ==<br />
<br />
(this paragraph is for developers and power-users only)<br />
<br />
If you look at the folder that TEXMFCACHE points to, you will see a folder named luatex-cache. Inside that, there is the folder context. Inside the context folder, there usually is a single subfolder with a hexadecimal name. This is the md5sum of the name of the 'tex root' folder (aka SELFAUTOPARENT). Below this, there are currently four folders:<br />
<br />
* '''curl''' contains downloaded files. The url is converted to something that can be represented on disk by replacing problematic characters by dashes<br />
* '''fonts''' contains the file data/names.tma, this is the 'font name database' (and the derived names.tmc, tmc files are byte-compiled lua code for faster loading). There are also subdirectories containing the preprocessed metrics for non-tex fonts, one folder for each font type. <br />
* '''formats''' contains the Mark IV format file<br />
* '''trees''' has a small set of files with hexadecimal names, one for each of the top-level constituents of TEXMF (containing the filename database for that tree), and one for each of the found texmf.cnf files (containing in preprocessed form all the variables defined by that file). The filenames are md5sums of the contained directory or filename.</div>Nicolas Girardhttps://wiki.contextgarden.net/index.php?title=Running_Mark_IV&diff=9771Running Mark IV2009-05-31T23:23:20Z<p>Nicolas Girard: /* Using fonts */ Contents moved to a dedicated page</p>
<hr />
<div>== Introduction ==<br />
<br />
ConTeXt [[Mark IV]] does not use the kpathsea library to find files and configuration settings. It follows that running mktexlsr or fmtutil has no effect. This page explains the details of <br />
setting up and maintaining [[Mark IV]].<br />
<br />
The most important motivation for this page is that the [[TeX Live]] 2008 edition contains Mark IV, but it is only copied to the installed system, no post-install setup takes place at all. This year, the post-install setup has to be done manually.<br />
<br />
If you have trouble following these instructions, please direct you questions or complaints on the [http://www.ntg.nl/mailman/listinfo/ntg-context ntg-context mailing list], '''not''' the tex-live list.<br />
<br />
<br />
Special notes:<br />
* '''Windows''': Running Mark IV under Windows is the same as on Unix, but see [[Running_Mark_IV#In_case_of_trouble|below]] for a installation hints for the 'spaces in names' problem that seem to affect Windows users more often than other platforms.<br />
* '''[[MacTeX]]''': You need to [[Running_Mark_IV#Updating_ConTeXt|update]] ConTeXt first.<br />
* '''Debian''': Mark IV suggests the tex-gyre package ([[TeX Gyre]]), not distributed currently under Debian due to licensing issues (see [[Debian installation]] )<br />
<br />
== Quickstart ==<br />
<br />
Just for the extremely impatient unix user that knows how to deal with a web2c-based TeX distribution and has a simple, private (single-user) installation, this is the only absolutely required extra knowledge:<br />
<br />
luatools --generate<br />
<br />
is the Mark IV replacement for mktexlsr.<br />
<br />
context --make<br />
<br />
is the Mark IV replacement for fmtutil.<br />
<br />
context myfile.tex<br />
<br />
typesets a file.<br />
<br />
Everybody else should read on.<br />
<br />
'''A note for windows users:''' the luatex executable doest not accept filenames with spaces in their name. This means that if you are on windows you will at least have to set up a texmfcnf.lua as explained below, and you likely will even have to reinstall texlive, because the default texlive installation directory itself contains spaces. [[Running_Mark_IV#File_not_found | Details]].<br />
<br />
== Updating ConTeXt ==<br />
<br />
Updating is not absolutely necessary unless you use [[MacTeX]], but most MKIV users will probably want to play with latest & greatest features.<br />
<br />
There's a work-in-progress to create a TL repository on the garden with the latest ConTeXt and LuaTeX, so that TeX Live users should be able to upgrade ConTeXt automatically.<br />
<br />
Until then you can update ConTeXt in different ways, for example with:<br />
rsync -av rsync://contextgarden.net/minimals/current/context/current/ /usr/local/texlive/2008/texmf-dist/<br />
<br />
To update LuaTeX you may use the following line (depending on your platform):<br />
rsync -av rsync://contextgarden.net/minimals/current/bin/luatex/<i><font color="#F00">platform-garden</font></i>/bin/luatex \<br />
/usr/local/texlive/2008/bin/<i><font color="#F00">platform-TL</font></i>/<br />
Which resolves to one of the following lines:<br />
rsync -av rsync://contextgarden.net/minimals/current/bin/luatex/freebsd/bin/luatex /usr/local/texlive/2008/bin/i386-freebsd/<br />
rsync -av rsync://contextgarden.net/minimals/current/bin/luatex/linux/bin/luatex /usr/local/texlive/2008/bin/i386-linux/<br />
rsync -av rsync://contextgarden.net/minimals/current/bin/luatex/linux-64/bin/luatex /usr/local/texlive/2008/bin/x86_64-linux/<br />
rsync -av rsync://contextgarden.net/minimals/current/bin/luatex/osx-universal/bin/luatex /usr/local/texlive/2008/bin/universal-darwin/<br />
<br />
You can upgrade XeTeX or metapost in the same way as LuaTeX.<br />
<br />
Of course you need to repeat all the steps mentioned above, for MKIV:<br />
luatools --generate<br />
context --make<br />
and for MKII:<br />
mktexlsr<br />
texexec --make --all<br />
texexec --make --xtx --all<br />
<br />
Note that this is a quick-and-dirty way to upgrade TL. Use at your own risk. One should be able to update in a more elegant way.<br />
<br />
== Generating and updating formats ==<br />
<br />
Before first use and after each update to either the [[context]] distribution or the [[luatex]] executable you will have to regenerate the formats. The command for that is:<br />
<br />
context --make cont-en<br />
<br />
This will generate a new Mark IV format with the English interface. Without an explicit format argument, it will generate four formats: Mark IV cont-en, Matk IV cont-nl, luatex+mptopdf, and luatex+plain.<br />
<br />
The generated formats are stored inside the texmf cache.<br />
<br />
== Using fonts ==<br />
<br />
See [[Fonts in LuaTex#Getting access to the system fonts]]<br />
<br />
== Downloaded files ==<br />
<br />
If you have the program 'curl' installed, then your input file can contain e.g.<br />
<br />
<texcode><br />
\externalfigure<br />
[http://www.pragma-ade.com/show-gra.pdf]<br />
</texcode><br />
<br />
and the referenced file will be downloaded automatically and placed in the 'texmf cache' if is not found in the cache already.<br />
<br />
== In case of trouble ==<br />
<br />
=== File not found ===<br />
<br />
* You may get errors like<br />
I can't find file `C:/Program.tex'.<br />
This is likely caused by the luatex executable not handling filename quoting properly yet. If filenames with spaces work at all, you are just lucky.<br />
<br />
This problem is most likely to happen on Windows. There two steps to deal with it:<br />
* You must put the main texmf tree in path without spaces. If you're installing Mark IV via TeXLive 2008, then simply change the top installation path at install time.<br />
* If you're running XP or Server 2003 (and not Vista or Server 2008), you must also set the TeX user home and the Lua cache to paths without spaces. <code>C:/tlhome</code> is a good candidate.<br />
** In <code>texmf.cnf</code> set HOMETEXMF to <code>C:/tlhome/$USERNAME</code> or to something similar of your liking. Using $USERNAME in the path will still give a per-user directory, just not under "Documents and Settings". This assumes that the user name doesn't have spaces of course...<br />
** As mentioned above, create/edit <code>texmfcnf.lua</code> and put a line like <code>return { TEXMFCACHE = 'C:/tlhome/$USERNAME/.texlive2008/texmf-var' }</code>, which sets each user's cache inside his space-free TeX home path.<br />
<br />
== Cache internals ==<br />
<br />
(this paragraph is for developers and power-users only)<br />
<br />
If you look at the folder that TEXMFCACHE points to, you will see a folder named luatex-cache. Inside that, there is the folder context. Inside the context folder, there usually is a single subfolder with a hexadecimal name. This is the md5sum of the name of the 'tex root' folder (aka SELFAUTOPARENT). Below this, there are currently four folders:<br />
<br />
* '''curl''' contains downloaded files. The url is converted to something that can be represented on disk by replacing problematic characters by dashes<br />
* '''fonts''' contains the file data/names.tma, this is the 'font name database' (and the derived names.tmc, tmc files are byte-compiled lua code for faster loading). There are also subdirectories containing the preprocessed metrics for non-tex fonts, one folder for each font type. <br />
* '''formats''' contains the Mark IV format file<br />
* '''trees''' has a small set of files with hexadecimal names, one for each of the top-level constituents of TEXMF (containing the filename database for that tree), and one for each of the found texmf.cnf files (containing in preprocessed form all the variables defined by that file). The filenames are md5sums of the contained directory or filename.</div>Nicolas Girard