Changes

Jump to navigation Jump to search
904 bytes added ,  13:26, 9 August 2020
m
Text replacement - "</cmd>" to "}}"
{{note|This page is NOT finished yet}}
 
[[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).
== Featuresets ==
A featureset is a composed of a set of open-type features. Featuresets are specified using <{{cmd>|definefontfeature</cmd>}}. 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:
</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 featuresets. The command <{{cmd>|feature</cmd> }} and its siblings is then used to control the action of those featuresets. Here are the commands:
<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 featuresets. The command <{{cmd>|feature</cmd> }} 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:
<texcode>
\startTEXpagedefinefontfeature [offsetschola-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
\definedefinefontfeature[f:newstyle] [onum=no]\SAMPLE{123 Idrīs ?` !` VA fi}definefontfeature[f:nocaps] [smcp=no]\definefontfeature[f:wideimacron] [ss04=no]\definefontfeature[f:rightsideup] [dlig=no]
\SAMPLE\blank
% Adding\definefontfeature[f:ligatures] [liga=yes]\definefontfeature[f:noligatures] [liga=no]
\feature[+]definefontfeature[f:oldstyle] \SAMPLE \blank\feature[more][f:thinimacron] \SAMPLE \blank\addfeature [f:upsidedownonum=yes,lnum=no] \SAMPLE \blank
\featuredefinefontfeature[+f:oldstyleupsidedown] [f:smallcapsonum=yes,dlig=yes] \SAMPLE \blank% \feature[more]definefontfeature[f:smallcapsnewstylerightsideup] \SAMPLE \blank\addfeature [f:wideimacrononum=no,dlig=no] \SAMPLE \blank
% Subtracting\definefontfeature[f:oldstylewmacron] [ss04=no,onum=yes]\definefontfeature[f:newstylesmallcaps] [smcp=yes,onum=no]
\featuredefineparagraphs[-X][f:upsidedownn=2, rule=on, width=10cm] \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!\startTEXpage[offset=10pt]
\feature[=][f:oldstyleupsidedown] define\SAMPLE \blank% \feature[new][f:oldstyleupsidedown] \SAMPLE \blank% \replacefeature[=][f:oldstyleupsidedown] \SAMPLE \blank{123 Idrīs ?` !` VA fi}
% Let's reset and get the original default set back and add smallcaps:\startX A) \SAMPLE\blank
\feature[!+][f:smallcapsoldstyle] B) \SAMPLE \blank% \feature[!more][f:noligaturesthinimacron] C) \SAMPLE \blank% \resetandaddfeature[!]addfeature[f:noligaturesupsidedown] D) \SAMPLE \blank
% Let's revive one of the old featuresets\feature[+][f:smallcaps] E) \SAMPLE \blank\nextX\addfeature[f:wideimacron] F) \SAMPLE \blank
\feature[>-][f:upsidedown] \SAMPLE \blank% \feature[old][f:upsidedown] \SAMPLE \blank% \revivefeature[f:upsidedown] G) \SAMPLE \blank
% Let's get the original default set back.\feature[=][f:oldstyleupsidedown] H) \SAMPLE \blank
\feature[<!] \SAMPLE \blank % \feature[resetf:smallcaps] \SAMPLE \blank % \resetfeature I) \SAMPLE \blank
\feature[<] J) \SAMPLE \blank\stopX\stopTEXpage
</texcode>
[[Category:Fonts]]
[[Category:LuaTeXTools]]

Navigation menu