Difference between revisions of "Fonts/Featuresets"
(A description of the new \feature commands) |
|||
(19 intermediate revisions by 7 users not shown) | |||
Line 1: | Line 1: | ||
− | |||
− | |||
[[LuaTeX]] and [[MkIV]] allow advanced usage and manipulation of [[Open Type]] <i>open-type features</i>. Some features, such as <i>onum</i> (oldstyle) and <i>smcp</i> (smallcaps) are known to most users of Open Type fonts, and virtually every open type font has default features for kerning (<i>kern</i>) and ligatures (<i>liga</i>). More advanced OT fonts can have lots more, including the Stylistic Set feature <i>ss<nn></i> (where <i>nn</i> stands for any numeral between 01 and 99). | [[LuaTeX]] and [[MkIV]] allow advanced usage and manipulation of [[Open Type]] <i>open-type features</i>. Some features, such as <i>onum</i> (oldstyle) and <i>smcp</i> (smallcaps) are known to most users of Open Type fonts, and virtually every open type font has default features for kerning (<i>kern</i>) and ligatures (<i>liga</i>). More advanced OT fonts can have lots more, including the Stylistic Set feature <i>ss<nn></i> (where <i>nn</i> stands for any numeral between 01 and 99). | ||
= Features in general = | = Features in general = | ||
− | In MkIV there are two kinds of font feature directly visible to the user: '' | + | In MkIV there are two kinds of font feature directly visible to the user: ''featureset'' and ''open-type feature''. |
== Open-type features == | == 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=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". | + | 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=yes]' turns on the lookup substitutions in the font which replace a line numeral with an oldstyle one. 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". |
+ | |||
+ | === Adding features on the fly === | ||
+ | |||
+ | Sometimes you want to provisionally add OpenType features to a font. There are at least three ways to do this. | ||
+ | # Use a low-level `font.handlers.otf.addfeature` callback function to define new OTF features. See Section 8.14 of [https://www.pragma-ade.nl/general/manuals/fonts-mkiv.pdf fonts-mkiv manual] for details of the syntax, or refer to the examples [http://minimals.metatex.org/current/context/test/doc/context/tests/mkiv/fonts/extensions-001.tex here]. | ||
+ | # Define the new features in an `lfg` "goodies" file and load it with the `goodies` key. See [http://minimals.metatex.org/current/context/test/doc/context/tests/mkiv/fonts/greek-001.tex this example] with the corresponding [http://minimals.metatex.org/current/context/test/doc/context/tests/mkiv/fonts/oxoniensis.lfg lfg] file. | ||
+ | # Use a feature file (in the `fea` format) and load it with the `featurefile` key. See [[Fontfeaturefiles]]. | ||
+ | |||
+ | === Debugging features === | ||
+ | |||
+ | For an OpenType to work properly, all the relevant glyphs must come from the same font (either the original font or one of the fallbacks). For example, the font [https://github.com/aminabedi68/Mikhak/tree/master/Font/ttf Mikhak] now misses glyphs for en dash and em dash, hence the `tlig` feature does not work to automatically change double or triple dashes to en and em dashes. This would not work even if we added fallbacks for those two characters. However, if we also create a fallback for the dash character, then this will work. | ||
+ | |||
+ | <texcode> | ||
+ | \starttext | ||
+ | |||
+ | \definefontfallback[myfallback][dejavuserif*default][0x02d,0x2013,0x2014][check=yes,force=yes] | ||
+ | |||
+ | \definefontsynonym[mytestfont][file:Mikhak-Medium.ttf][fallbacks=myfallback] | ||
+ | \definedfont[mytestfont*arabic] | ||
+ | foo--ofo---oof [\char"002D] [\char"2013] [\char"2014] | ||
+ | |||
+ | \stoptext | ||
+ | </texcode> | ||
+ | |||
+ | |||
+ | OpenType features can be complicated to understand or debug. One useful command to see how they are working is {{cmd|showotfcomposition}}. | ||
+ | |||
+ | <texcode> | ||
+ | \starttext | ||
+ | % -1 for the second argument means RTL. Leave it out for LTR text. | ||
+ | \showotfcomposition{mikhak-medium*arabic}{-1}{سلام علیکم} | ||
+ | \stoptext | ||
+ | </texcode> | ||
+ | |||
− | == | + | == Featuresets == |
− | A | + | A featureset is a composed of a set of open-type features. Featuresets are specified using {{cmd|definefontfeature}}. For each given body font in the typeface we specify the ''global'' default set of <i>open-type</i> features to be used for that font. This is usually done in the preamble to our document, an environment file, or a typescript file, or the like. |
For example, using TeX-Gyre Schola we can specify the following default, global set open-type features in the preamble: | For example, using TeX-Gyre Schola we can specify the following default, global set open-type features in the preamble: | ||
Line 23: | Line 55: | ||
</texcode> | </texcode> | ||
− | + | {{cmd|definefontfeature}} | |
All other open-type features in the font are not included in the processing. | All other open-type features in the font are not included in the processing. | ||
− | Now when we want to change the default, we use | + | Now when we want to change the default, we use {{cmd|definefontfeature}} to specify local featuresets. The command {{cmd|feature}} and its siblings is then used to control the action of those featuresets. Here are the commands: |
<texcode> | <texcode> | ||
Line 34: | Line 66: | ||
\replacefeature [f:mine] \feature [new][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] | \resetandaddfeature[f:mine] \feature[local][f:mine] \feature[!][f:mine] | ||
− | \revivefeature [f:mine] \feature [old][f:mine] \feature[> | + | \revivefeature [f:mine] \feature [old][f:mine] \feature[>] |
\resetfeature \feature[reset] \feature[<] | \resetfeature \feature[reset] \feature[<] | ||
</texcode> | </texcode> | ||
Line 42: | Line 74: | ||
= Sample file with examples = | = Sample file with examples = | ||
− | Let us now go through a complete sample file with examples. Let us first define our global default | + | Let us now go through a complete sample file with examples. Let us first define our global default featureset and activate it with a typescript: |
<texcode> | <texcode> | ||
Line 75: | Line 107: | ||
In the above note that we start with just a global, default feature set of kerns, ligatures, and line numerals. | 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 | + | Now when we want to change the default, we use {{cmd|definefontfeature}} to specify featuresets. The command {{cmd|feature}} and its siblings is then used to control the action of those featuresets. |
− | 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 | + | 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 featuresets. TeX-Gyre Schola has a decent set of open-type features. Using a few of them, let us set up a few featuresets: |
<texcode> | <texcode> | ||
Line 85: | Line 117: | ||
</texcode> | </texcode> | ||
− | Above, all of our | + | Above, all of our featuresets are mapped to open-type features that plug into the stack. |
<texcode> | <texcode> | ||
Line 101: | Line 133: | ||
</texcode> | </texcode> | ||
− | Of course, a | + | Of course, a featureset set can include more than one open-type feature. In advanced applications this will be the norm: |
<texcode> | <texcode> | ||
Line 107: | Line 139: | ||
</texcode> | </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. | + | NOTE: In this case we have to specify 'lnum=no' because it is already defined in our default feature set in the preamble etc. The order of lookups in the font itself could conceivably have an impact as well. |
<texcode> | <texcode> | ||
Line 114: | Line 146: | ||
</texcode> | </texcode> | ||
− | Above, each | + | Above, each featureset is mapped to an open-type feature set that plugs into or unplugs from the stack. But we can mix things up: |
<texcode> | <texcode> | ||
Line 121: | Line 153: | ||
</texcode> | </texcode> | ||
− | The above two illustrate the point that | + | The above two illustrate the point that featuresets 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 | + | Now let's put some of the above featuresets in action. Note the use of synonyms in both the activated code and in the comments: |
<texcode> | <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=2.7ex] | ||
+ | \definetypeface [schola-default] [rm] [serif] [schola-preset] [schola-preset] % [default] | ||
+ | \stoptypescript | ||
+ | |||
+ | \usetypescript[schola-default] | ||
+ | \setupbodyfont[schola-default,12pt] | ||
− | \ | + | \definefontfeature[f:smallcaps] [smcp=yes] |
+ | \definefontfeature[f:thinimacron] [ss04=yes] | ||
+ | \definefontfeature[f:upsidedown] [dlig=yes] | ||
− | |||
− | + | \definefontfeature[f:newstyle] [onum=no] | |
+ | \definefontfeature[f:nocaps] [smcp=no] | ||
+ | \definefontfeature[f:wideimacron] [ss04=no] | ||
+ | \definefontfeature[f:rightsideup] [dlig=no] | ||
− | |||
− | |||
− | |||
− | \ | + | \definefontfeature[f:ligatures] [liga=yes] |
− | + | \definefontfeature[f:noligatures] [liga=no] | |
− | |||
− | + | \definefontfeature[f:oldstyle] [onum=yes,lnum=no] | |
− | \ | + | \definefontfeature[f:oldstyleupsidedown] [onum=yes,dlig=yes] |
− | + | \definefontfeature[f:newstylerightsideup] [onum=no,dlig=no] | |
− | |||
− | + | \definefontfeature[f:oldstylewmacron] [ss04=no,onum=yes] | |
+ | \definefontfeature[f:newstylesmallcaps] [smcp=yes,onum=no] | ||
− | \ | + | \defineparagraphs[X][n=2, rule=on, width=10cm] |
− | |||
− | |||
− | + | \startTEXpage[offset=10pt] | |
− | \ | + | \define\SAMPLE{123 Idrīs ?` !` VA fi} |
− | |||
− | |||
− | + | \startX | |
+ | A) \SAMPLE\blank | ||
− | \feature[ | + | \feature[+][f:oldstyle] B) \SAMPLE \blank |
− | + | \feature[more][f:thinimacron] C) \SAMPLE \blank | |
− | + | \addfeature[f:upsidedown] D) \SAMPLE \blank | |
− | + | \feature[+][f:smallcaps] E) \SAMPLE \blank | |
+ | \nextX | ||
+ | \addfeature[f:wideimacron] F) \SAMPLE \blank | ||
− | \feature[ | + | \feature[-][f:upsidedown] G) \SAMPLE \blank |
− | |||
− | |||
− | \stopTEXpage | + | \feature[=][f:oldstyleupsidedown] H) \SAMPLE \blank |
+ | |||
+ | \feature[!][f:smallcaps] I) \SAMPLE \blank | ||
+ | |||
+ | \feature[<] J) \SAMPLE \blank | ||
+ | \stopX | ||
+ | \stopTEXpage | ||
</texcode> | </texcode> | ||
Now let us review the results: | Now let us review the results: | ||
+ | [[Image:Adding-featuresets.png]] | ||
+ | |||
+ | Finally, we can mix featuresets using comma-separated lists. Here is an example: | ||
+ | |||
+ | <texcode> | ||
+ | \setupbodyfont[pagella] | ||
+ | |||
+ | \starttext | ||
+ | |||
+ | test 123 {\feature[+][smallcaps,oldstyle] test 123} | ||
+ | |||
+ | \stoptext | ||
+ | </texcode> | ||
+ | |||
+ | You will also note that context already has some common featuresets predefined. | ||
== Note == | == Note == | ||
Line 182: | Line 256: | ||
<texcode> | <texcode> | ||
− | \addff{ | + | \addff{featureset} % Add absolute font-feature set -- replaces default set |
+ | \subff{featureset} % Subtract absolute font-feature set -- replaces default set | ||
+ | \addfs{featureset} % Add font-feature set on top of current stack | ||
+ | \subfs{featureset} % Subtract font-feature set from current stack | ||
</texcode> | </texcode> | ||
− | These have now been deprecated and presumably will | + | These have now been deprecated and, presumably, will eventually disappear. |
+ | |||
+ | = List of syntax for OpenType features= | ||
+ | * Ligatures | ||
+ | ** Common/standard ligatures <code>liga</code> | ||
+ | ** Contextual alternates <code>calt</code> | ||
+ | ** Discretionary ligatures <code>dlig</code> | ||
+ | * Letters | ||
+ | ** Small caps <code>smcp</code> | ||
+ | ** Capitals to small caps <code>c2sc</code> | ||
+ | ** Swashes <code>swsh</code> | ||
+ | ** Stylistic alternates <code>salt</code> | ||
+ | * Numbers | ||
+ | ** Lining figures <code>lnum</code> | ||
+ | ** Oldstyle figures <code>onum</code> | ||
+ | ** Proportional figures <code>pnum</code> | ||
+ | ** Tabular figures <code>tnum</code> | ||
+ | ** Fractions <code>frac</code> | ||
+ | ** Ordinals <code>ordn</code> | ||
+ | * Stylistic sets | ||
+ | ** Stylistic sets 01–20 <code>ss##</code> | ||
+ | * East Asian script | ||
+ | ** Width variants | ||
+ | *** Proportional Widths <code>pwid</code> | ||
+ | *** Proportional Alternate Widths <code>palt</code> | ||
+ | *** Proportional Kana <code>pkna</code> | ||
+ | *** Full Widths <code>fwid</code> | ||
+ | *** Half Widths <code>hwid</code> | ||
+ | *** Alternate Half Widths <code>halt</code> | ||
+ | *** Third Widths <code>twid</code> | ||
+ | *** Quarter Widths <code>qwid</code> | ||
+ | ** Cultural variants | ||
+ | *** JIS78 Forms <code>jp78</code> | ||
+ | *** JIS83 Forms <code>jp83</code> | ||
+ | *** JIS90 Forms <code>jp90</code> | ||
+ | *** JIS2004 Forms <code>jp04</code> | ||
+ | *** Traditional Forms <code>trad</code> | ||
+ | *** Ruby Notation Forms <code>ruby</code> | ||
+ | *** Horizontal Kana Alternates <code>hkna</code> | ||
+ | *** NLC Kanji Forms <code>nlck</code> | ||
+ | *** Alternate Annotation Forms <code>nalt</code> | ||
+ | *** Italics <code>ital</code> | ||
+ | ** Vertical features | ||
+ | *** Vertical Kerning <code>vkrn</code> | ||
+ | *** Vertical Alternates <code>vert</code> | ||
+ | *** Proportional Alternate Vertical Metrics <code>vpal</code> | ||
+ | *** Alternate Vertical Half Metrics <code>vhal</code> | ||
+ | *** Vertical Kana Alternates <code>vkna</code> | ||
+ | |||
+ | |||
= References = | = References = | ||
− | See also [[Fonts in LuaTeX]] | + | See also [[Fonts/Fonts in LuaTeX]] |
<references/> | <references/> | ||
[[Category:Fonts]] | [[Category:Fonts]] | ||
− | [[Category: | + | [[Category:Tools]] |
Latest revision as of 20:14, 17 May 2024
LuaTeX and MkIV allow advanced usage and manipulation of Open Type open-type features. Some features, such as onum (oldstyle) and smcp (smallcaps) are known to most users of Open Type fonts, and virtually every open type font has default features for kerning (kern) and ligatures (liga). More advanced OT fonts can have lots more, including the Stylistic Set feature ss<nn> (where nn stands for any numeral between 01 and 99).
Contents
Features in general
In MkIV there are two kinds of font feature directly visible to the user: featureset 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 (onum, smcp, etc.) and in MkIV are associated with a keyval that turns it on ("yes") or off ("no"). For example, '[onum=yes]' turns on the lookup substitutions in the font which replace a line numeral with an oldstyle one. 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".
Adding features on the fly
Sometimes you want to provisionally add OpenType features to a font. There are at least three ways to do this.
- Use a low-level
font.handlers.otf.addfeature
callback function to define new OTF features. See Section 8.14 of fonts-mkiv manual for details of the syntax, or refer to the examples here. - Define the new features in an
lfg
"goodies" file and load it with thegoodies
key. See this example with the corresponding lfg file. - Use a feature file (in the
fea
format) and load it with thefeaturefile
key. See Fontfeaturefiles.
Debugging features
For an OpenType to work properly, all the relevant glyphs must come from the same font (either the original font or one of the fallbacks). For example, the font Mikhak now misses glyphs for en dash and em dash, hence the tlig
feature does not work to automatically change double or triple dashes to en and em dashes. This would not work even if we added fallbacks for those two characters. However, if we also create a fallback for the dash character, then this will work.
\starttext \definefontfallback[myfallback][dejavuserif*default][0x02d,0x2013,0x2014][check=yes,force=yes] \definefontsynonym[mytestfont][file:Mikhak-Medium.ttf][fallbacks=myfallback] \definedfont[mytestfont*arabic] foo--ofo---oof [\char"002D] [\char"2013] [\char"2014] \stoptext
OpenType features can be complicated to understand or debug. One useful command to see how they are working is \showotfcomposition.
\starttext % -1 for the second argument means RTL. Leave it out for LTR text. \showotfcomposition{mikhak-medium*arabic}{-1}{سلام علیکم} \stoptext
Featuresets
A featureset is a composed of a set of open-type features. Featuresets are specified using \definefontfeature. For each given body font in the typeface we specify the global default set of open-type features to be used for that font. This is usually done in the preamble to our document, an environment file, or a typescript file, or the like.
For example, using TeX-Gyre Schola we can specify the following default, global set open-type features in the preamble:
\definefontfeature [schola-preset] [mode=node,script=latn,language=dflt,kern=yes,liga=yes,lnum=yes]
All other open-type features in the font are not included in the processing.
Now when we want to change the default, we use \definefontfeature to specify local featuresets. The command \feature and its siblings is then used to control the action of those featuresets. Here are the commands:
\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[>] \resetfeature \feature[reset] \feature[<]
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 featureset and activate it with a typescript:
\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=2.7ex] \definetypeface [schola-default] [rm] [serif] [schola-preset] [schola-preset] % [default] \stoptypescript \usetypescript[schola-default] \setupbodyfont[schola-default,12pt]
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 \definefontfeature to specify featuresets. The command \feature and its siblings is then used to control the action of those featuresets.
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 featuresets. TeX-Gyre Schola has a decent set of open-type features. Using a few of them, let us set up a few featuresets:
\definefontfeature[f:smallcaps] [smcp=yes] \definefontfeature[f:thinimacron] [ss04=yes] \definefontfeature[f:upsidedown] [dlig=yes]
Above, all of our featuresets are mapped to open-type features that plug into the stack.
\definefontfeature[f:newstyle] [onum=no] \definefontfeature[f:nocaps] [smcp=no] \definefontfeature[f:wideimacron] [ss04=no] \definefontfeature[f:rightsideup] [dlig=no]
We can also be redundant to the default open-type feature set:
\definefontfeature[f:ligatures] [liga=yes] \definefontfeature[f:noligatures] [liga=no]
Of course, a featureset set can include more than one open-type feature. In advanced applications this will be the norm:
\definefontfeature[f:oldstyle] [onum=yes,lnum=no]
NOTE: In this case we have to specify 'lnum=no' because it is already defined in our default feature set in the preamble etc. The order of lookups in the font itself could conceivably have an impact as well.
\definefontfeature[f:oldstyleupsidedown] [onum=yes,dlig=yes] \definefontfeature[f:newstylerightsideup] [onum=no,dlig=no]
Above, each featureset is mapped to an open-type feature set that plugs into or unplugs from the stack. But we can mix things up:
\definefontfeature[f:oldstylewmacron] [ss04=no,onum=yes] \definefontfeature[f:newstylesmallcaps] [smcp=yes,onum=no]
The above two illustrate the point that featuresets 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 featuresets in action. Note the use of synonyms in both the activated code and in the comments:
\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=2.7ex] \definetypeface [schola-default] [rm] [serif] [schola-preset] [schola-preset] % [default] \stoptypescript \usetypescript[schola-default] \setupbodyfont[schola-default,12pt] \definefontfeature[f:smallcaps] [smcp=yes] \definefontfeature[f:thinimacron] [ss04=yes] \definefontfeature[f:upsidedown] [dlig=yes] \definefontfeature[f:newstyle] [onum=no] \definefontfeature[f:nocaps] [smcp=no] \definefontfeature[f:wideimacron] [ss04=no] \definefontfeature[f:rightsideup] [dlig=no] \definefontfeature[f:ligatures] [liga=yes] \definefontfeature[f:noligatures] [liga=no] \definefontfeature[f:oldstyle] [onum=yes,lnum=no] \definefontfeature[f:oldstyleupsidedown] [onum=yes,dlig=yes] \definefontfeature[f:newstylerightsideup] [onum=no,dlig=no] \definefontfeature[f:oldstylewmacron] [ss04=no,onum=yes] \definefontfeature[f:newstylesmallcaps] [smcp=yes,onum=no] \defineparagraphs[X][n=2, rule=on, width=10cm] \startTEXpage[offset=10pt] \define\SAMPLE{123 Idrīs ?` !` VA fi} \startX A) \SAMPLE\blank \feature[+][f:oldstyle] B) \SAMPLE \blank \feature[more][f:thinimacron] C) \SAMPLE \blank \addfeature[f:upsidedown] D) \SAMPLE \blank \feature[+][f:smallcaps] E) \SAMPLE \blank \nextX \addfeature[f:wideimacron] F) \SAMPLE \blank \feature[-][f:upsidedown] G) \SAMPLE \blank \feature[=][f:oldstyleupsidedown] H) \SAMPLE \blank \feature[!][f:smallcaps] I) \SAMPLE \blank \feature[<] J) \SAMPLE \blank \stopX \stopTEXpage
Now let us review the results:
Finally, we can mix featuresets using comma-separated lists. Here is an example:
\setupbodyfont[pagella] \starttext test 123 {\feature[+][smallcaps,oldstyle] test 123} \stoptext
You will also note that context already has some common featuresets predefined.
Note
An earlier version of this functionality was contained in the commands
\addff{featureset} % Add absolute font-feature set -- replaces default set \subff{featureset} % Subtract absolute font-feature set -- replaces default set \addfs{featureset} % Add font-feature set on top of current stack \subfs{featureset} % Subtract font-feature set from current stack
These have now been deprecated and, presumably, will eventually disappear.
List of syntax for OpenType features
- Ligatures
- Common/standard ligatures
liga
- Contextual alternates
calt
- Discretionary ligatures
dlig
- Common/standard ligatures
- Letters
- Small caps
smcp
- Capitals to small caps
c2sc
- Swashes
swsh
- Stylistic alternates
salt
- Small caps
- Numbers
- Lining figures
lnum
- Oldstyle figures
onum
- Proportional figures
pnum
- Tabular figures
tnum
- Fractions
frac
- Ordinals
ordn
- Lining figures
- Stylistic sets
- Stylistic sets 01–20
ss##
- Stylistic sets 01–20
- East Asian script
- Width variants
- Proportional Widths
pwid
- Proportional Alternate Widths
palt
- Proportional Kana
pkna
- Full Widths
fwid
- Half Widths
hwid
- Alternate Half Widths
halt
- Third Widths
twid
- Quarter Widths
qwid
- Proportional Widths
- Cultural variants
- JIS78 Forms
jp78
- JIS83 Forms
jp83
- JIS90 Forms
jp90
- JIS2004 Forms
jp04
- Traditional Forms
trad
- Ruby Notation Forms
ruby
- Horizontal Kana Alternates
hkna
- NLC Kanji Forms
nlck
- Alternate Annotation Forms
nalt
- Italics
ital
- JIS78 Forms
- Vertical features
- Vertical Kerning
vkrn
- Vertical Alternates
vert
- Proportional Alternate Vertical Metrics
vpal
- Alternate Vertical Half Metrics
vhal
- Vertical Kana Alternates
vkna
- Vertical Kerning
- Width variants
References
See also Fonts/Fonts in LuaTeX