Changes

Jump to navigation Jump to search
3,446 bytes added ,  06:10, 23 March 2012
m
Text replace - "\[\[cmd:(.*)\|(.*)\]\]" to "{{cmd|$1}}"
< [[Fonts]]
Character protrusion is a somewhat subtle advanced typographic effect in which some characters (often punctuation) are moved partially or fully into the margin in order to give it an optically smoother appearance. In ConTeXt, this is achieved via the font mechanisms within pdfTeXand LuaTeX. Much of the difficult work is done in some presets by Hans, but there are a few tricks needed in order to activate the feature.
This feature is also commonly called "Handling" after the font handling feature that enables it, and "Hanging" after what hyphens do into the margin. The microtype LaTeX package also includes a protrusion feature, and may be known by that name to a certain audience.
 
There are some differences between enabling character protrusion and the related font expansion feature between
MkII and MkIV, so the following discusses both separately.
 
= MkII =
Font handling is documented in the [[article:89|Fonts in ConTeXt]] manual.
Switch the font that we setup, and show an example with lots of punctuation. The illustration has '''normal''' hanging enabled:
 
<context>
\usetypescript[postscript][ec]
== Details ==
The [[{{cmd:usetypescript|\usetypescript]] }} command has three arguments above . The definitions that we use are in [[source:type-exa.tex| type-exa.tex]], and there reference the low-level definitions in [[source:hand-def.tex| hand-def.tex]]. There are different possible values for eachargument, which, by convention, are:
\usetypescript [''family''] [''trigger''] [''type'']
{| border="1" cellspacing="0"
| ''family''
| colspan="2" | '''serif''', '''sans''', and/or '''mono'''
|-
| ''trigger''
| colspan="2" | '''handling''', or '''hanging''', for protrusion; '''handling''' or '''hz''' (makes no difference--it's just a trigger)for font expansion
|-
| rowspan="45" | ''type''
| '''pure'''
| full protrusion of only selected punctuation
| '''quality'''
| combination of '''hz''' and '''pure'''
|-
| '''highquality'''
| combination of '''hz''' and '''normal'''
|}
</context>
==Hz adjustments==For more radical effects, where you need to fit to a fixed, narrow measure, you can enable Hz-style font adjustments, wherein individual characters are adjusted by miniscule amounts as necessary. These are enabled by the '''hz''', '''quality''', and '''highquality''' options listed above. Usage is with such lines as: <texcode>\usetypescript[serif][hz][quality] % this creates the 'handling' synonyms\setupalign[hanging,hz] % this turns on the hanging and hz features</texcode> The example shows how slight font expansion improves the fitting to the margin without changing the tolerance on the inter-word spacing. The left passage is with ''hanging'' alone enabled, and the right is with ''hanging'' and ''hz'' both enabled. It's not for everyone, as the process can distort letter shapes.  <context>\usetypescript[postscript][Categoryec]\usetypescript[adobekb][ec]\setupfonthandling[hz][min=30,max=30,step=10]\usetypescript[serif][hz][quality] % this creates the 'handling' synonyms\setupalign[hanging] % this actually triggers the feature\setupbodyfont[postscript]\setupcolors[state=start]\setupframedtexts[width=4.6cm,rightframe=on,frame=off,offset=none,framecolor=middlegray,tolerance=verystrict]\starttext\startcombination[2*1]{\startframedtext[none][align=hanging] \input ward \stopframedtext}{\it hanging alone}{\startframedtext[none][align={hanging,hz}] \input ward \stopframedtext}{\it hanging + hz}\stopcombination\stoptext</context> = MkIV = In MkIV, protrusion and expansion are integrated into the font feature subsystem that is also used for OpenType features. Unless you are creating a totally new typescript, the easiest way to enable protrusion is to redefinethe already existing 'default' font feature: <texcode>\definefontfeature [default] [default] [protrusion=quality,expansion=quality] \setupalign[hz,hanging] \setupbodyfont[times]</texcode> The values for the protrusion and expansion keys are defined in [[source:Fontsfont-ext.lua| font-ext.lua]].  {| border="1" cellspacing="0"| rowspan="4" | ''protrusion''| '''pure''' | full protrusion of only selected punctuation|-| '''punctuation'''| partial protrusion of punctuation and some asymmetrical letters|-| '''alpha'''| variable correction of character widths|-| '''quality'''| combination of '''punctuation''' and '''alpha'''|-| rowspan="2" | ''expansion''| '''default''' | variable glyph expansions for plain ascii text (alphabetics + numerals)|-| '''quality'''| same as '''default'''|}  Just like in MkII, a reset trick is needed to get proper output from latin-modern fonts: <texcode>\definefontfeature[default][default][expansion=quality,protrusion=quality] \usetypescript[modern-base]\setupbodyfont[reset,modern] \setupalign[hz,hanging] \showframe \starttext\input tufte\stoptext</texcode> However in the current version (at least the beta 2011.02.25) there is no need to reset the bodyfont as loading is delayed till starttext anyway.

Navigation menu