Changes

Jump to navigation Jump to search
5,100 bytes added ,  14:36, 21 March 2013
no edit summary
In MkIV there are two kinds of font feature directly visible to the user: ''meta-feature'' and ''open-type feature''.
== Open-type features ==
The open-type features are specified in the font and are composed of individual "lookups" which specify each substitution and positioning action to be performed in the processing. These open-type features are plugged in and out of the "stack" of lookups to be processed in the MkIV open type handler. These features are represented by a 4-character name (<i>onum</i>, <i>smcp</i>, etc.) and in MkIV are associated with a keyval that turns it on ("yes") or off ("no"). For example, '[onum== Openyes]'. Here the key 'yes' means "include open-type feature ''onum'' into the processed stack"; the key 'no' means "do not include open-type feature ==''onum'' in the processed stack".
== Meta-features ==
The openA meta-type features are specified in the font and are feature is a composed of individual "lookups" which specify each substitution and positioning action to be performed in the processing. These a set of open-type features are plugged in and out of the "stack" of lookups to be processed in the MkIV open type handler. These Meta-features are represented by a 4-character name (specified using <icmd>onum\definefontfeature</icmd>, . For each given body font in the typeface we specify the ''global'' default set of <i>smcpopen-type</i>, etcfeatures to be used for that font.) and This is usually done in MkIV are associated with the preamble to our document, an environment file, or a keyval that turns it on ("yes") typescript file, or off ("no"). For example, '[onum=yes]'. Here the key 'yes' means "include open-type feature ''onum'' into the processed stack"; the key 'no' means "do not include open-type feature ''onum'' in the processed stack"like.
Meta-features are specified using <cmd>\definefontfeature</cmd>. In the preamble to our document, an environment file, or even in a typescript file; we specify the default set of <i>open-type</i> features to be used. For example, using TeX-Gyre Schola we can specify the following default , global set open-type featuresin the preamble:
<texcode>
<cmd>definefontfeature</cmd>
All other open-type features in the font are not included in the processing. Now when we want to change the default, we use <cmd>\definefontfeature</cmd> to specify local meta-features. The command <cmd>feature</cmd> and its siblings is then used to control the action of those meta-features. Here are the commands: <texcode>\addfeature [f:mine] \feature [more][f:mine] \feature[+][f:mine]\subtractfeature [f:mine] \feature [less][f:mine] \feature[-][f:mine]\replacefeature [f:mine] \feature [new][f:mine] \feature[=][f:mine]\resetandaddfeature[f:mine] \feature[local][f:mine] \feature[!][f:mine]\revivefeature [f:mine] \feature [old][f:mine] \feature[>][f:mine]\resetfeature \feature[reset] \feature[<]</texcode> There are actually only six commands: Each row includes a set of three synonyms for one command. = Sample file with examples = Let us now go through a complete sample file with examples. Let us first define our global default meta-feature and activate it with a typescript: <texcode>\definefontfeature [schola-preset] [mode=node,script=latn,language=dflt,kern=yes,liga=yes,lnum=yes]   \starttypescript [serif] [schola-preset] [name]\definefontsynonym [Serif] [name:texgyreschola-regular.otf][features=schola-preset]\stoptypescript  \starttypescript [serif] [schola-preset] [size] \definebodyfont [35.8pt,29.8pt,24.8pt,20.7pt,17.3pt,14.4pt,12pt,11pt,10pt,9pt,8pt] [rm] [tf=Serif sa 1] \stoptypescript  \starttypescript [schola-default] \definebodyfontenvironment [schola-default] [default] [interlinespace= Stacking 2.7ex]\definetypeface [schola-default] [rm] [serif] [schola-preset] [schola-preset] % [default] \stoptypescript \usetypescript[schola-default] \setupbodyfont[schola-default,12pt]</texcode> In the above note that we start with just a global, default feature set of kerns, ligatures, and line numerals. Now when we want to change the default, we use <cmd>\definefontfeature</cmd> to specify meta-features. The command <cmd>feature</cmd> and unstacking its siblings is then used to control the action of those meta-features. At this stage which open-type feature is being plugged into or unplugged from the stack is invisible to the user. We just speak in terms of meta-features. TeX-Gyre Schola has a decent set of open-type features. Using a few of them, let us set up a few meta-features : <texcode>\definefontfeature[f:smallcaps] [smcp=yes]\definefontfeature[f:thinimacron] [ss04=yes]\definefontfeature[f:upsidedown] [dlig=yes]</texcode> Above, all of our meta-features are mapped to open-type features that plug into the stack. <texcode>\definefontfeature[f:newstyle] [onum=no]\definefontfeature[f:nocaps] [smcp=no]\definefontfeature[f:wideimacron] [ss04=no]\definefontfeature[f:rightsideup] [dlig=no]</texcode> We can also be redundant to the default open-type feature set: <texcode>\definefontfeature[f:ligatures] [liga=yes]\definefontfeature[f:noligatures] [liga=no]</texcode>
<cmd>Of course, a meta-feature</cmd><cmd>addfeature</cmd><cmd>subtractfeature</cmd><cmd>replacefeature</cmd><cmd>resetandaddfeature</cmd><cmd>revivefeature</cmd><cmd>resetfeature</cmd>set can include more than one open-type feature. In advanced applications this will be the norm:
<texcode>
\addfeature definefontfeature[f:mineoldstyle] \feature [more][f:mine] \feature[+][f:mine]\subtractfeature [f:mine] \feature [less][f:mine] \feature[-][f:mine]\replacefeature [f:mine] \feature [new][f:mine] \feature [onum=yes,lnum=][f:mine]\resetandaddfeature[f:mine] \feature[local][f:mine] \feature[!][f:mine]\revivefeature [f:mine] \feature [old][f:mine] \feature[>][f:mine]\resetfeature \feature[reset] \feature[<no]
</texcode>
 
NOTE: In this case we have to specify 'lnum=no' because it is already defined in our default feature set in the preamble etc. Depending on the order of lookups in the font one has to watch out for this.
 
<texcode>
\definefontfeature[f:oldstyleupsidedown] [onum=yes,dlig=yes]
\definefontfeature[f:newstylerightsideup] [onum=no,dlig=no]
</texcode>
 
Above, each meta-feature is mapped to an open-type feature set that plugs into or unplugs from the stack. But we can mix things up:
 
<texcode>
\definefontfeature[f:oldstylewmacron] [ss04=no,onum=yes]
\definefontfeature[f:newstylesmallcaps] [smcp=yes,onum=no]
</texcode>
 
The above two illustrate the point that meta-features hide from the user which actual open-type features are being plugged into or unplugged from the stack.
 
Now let's put some of the above meta-features in action. Note the use of synonyms in both the activated code and in the comments:
 
<texcode>
\startTEXpage[offset=10pt]
 
\define\SAMPLE{123 Idrīs ?` !` VA fi}
 
\SAMPLE\blank
 
% Adding
 
\feature[+][f:oldstyle] \SAMPLE \blank
\feature[more][f:thinimacron] \SAMPLE \blank
\addfeature[f:upsidedown] \SAMPLE \blank
 
\feature[+][f:smallcaps] \SAMPLE \blank
% \feature[more][f:smallcaps] \SAMPLE \blank
\addfeature[f:wideimacron] \SAMPLE \blank
 
% Subtracting
 
\feature[-][f:upsidedown] \SAMPLE \blank
% \feature[less][f:upsidedown] \SAMPLE \blank
% \subtractfeature[f:upsidedown] \SAMPLE \blank
 
% Replace all features, including the default set defined in the preamble. Note that kerning is now gone!
 
\feature[=][f:oldstyleupsidedown] \SAMPLE \blank
% \feature[new][f:oldstyleupsidedown] \SAMPLE \blank
% \replacefeature[=][f:oldstyleupsidedown] \SAMPLE \blank
 
% Let's reset and get the original default set back and add smallcaps:
 
\feature[!][f:smallcaps] \SAMPLE \blank
% \feature[!][f:noligatures] \SAMPLE \blank
% \resetandaddfeature[!][f:noligatures] \SAMPLE \blank
 
% Let's revive one of the old meta-features
 
\feature[>][f:upsidedown] \SAMPLE \blank
% \feature[old][f:upsidedown] \SAMPLE \blank
% \revivefeature[f:upsidedown] \SAMPLE \blank
 
% Let's get the original default set back.
 
\feature[<] \SAMPLE \blank
% \feature[reset] \SAMPLE \blank
% \resetfeature \SAMPLE \blank
 
\stopTEXpage
</texcode>
 
Now let us review the results:
 
 
= References =
[[Category:Fonts]]
[[Category:InternationalFonts in LuaTeX]]
[[Category:LuaTeX]]
{{note|This page is NOT finished yet}}
67

edits

Navigation menu