<HTML> <HEAD> <!-- Created with AOLpress/2.0 --> <!-- AP: Created on: 16-Aug-2003 --> <!-- AP: Last modified: 11-Nov-2009 --> <TITLE>The dialog for editing Contextual or Chaining Contextual features</TITLE> <LINK REL="icon" href="ffanvil16.png"> <LINK REL="stylesheet" TYPE="text/css" HREF="FontForge.css"> </HEAD> <BODY> <DIV id="in"> <H1> Editing Contextual or Chaining Contextual features </H1> <H2> What is a Contextual Positioning feature? </H2> <P> There are two types of contextual positioning modes: Contextual Positioning and Chained Contextual Positioning. In the simplest form of the first you may specify a list glyphs and specify repositioning to occur if that sequence is matched. For example you might specify (in English)<BR> <CODE> 5 t h</CODE><BR> and if that sequence were found raise the "t" and "h" to 5<SUP>th</SUP>. You can also specify classes of glyphs so you could say something like:<BR> <CODE> [0-9] t h</CODE><BR> to raise "t" and "h" after any digit. <P> After applying this lookup, a word processor will skip over the three glyphs matched by the pattern, at least it will in a simple "Contextual Positioning" lookup. The "Chained Contextual Positioning" lookup is a bit more general and allows you to divide the pattern into three parts: A part before the current glyph (called backtracking), a part including the current glyph, and a part after the current glyph (called lookahead). Positioning changes may only be made to the part including the current glyph, and the word processor will advance by the number of glyphs in that subset of the pattern. <H2> What is a Contextual Substitution feature? </H2> <P> Substitutions come in three types. The first two are similar to the two types for positioning, the third is designed to handle a very specific case of arabic typography and is applied backwards. <P> Suppose you had a script font where most letters join at the base line, but after some letters (b,o,v,w) the join is near the x-height, so a special version of each lower case letter needs to be created designed for a left side join near the x-height. You would want to be able to say:<BR> <CODE> [bovw] [a-z]</CODE><BR> Note that this just specifies the cases in which the substitution may be applied. It does not specify the substitution itself, that is done in a separate lookup. <P> You may pull down an example script font with this substitution from <A HREF="http://fontforge.sf.net/sfds/FormalScript.tgz">FormalScript.tgz</A>, this example is worked out in detail in the <A HREF="editexample6-5.html#Conditional">tutorial</A>. <H2> More complete descriptions </H2> <P> For more information on contextual features see Adobe's Docs: <UL> <LI> <A HREF="http://partners.adobe.com/public/developer/opentype/index_table_formats2.html">The GPOS table</A>, for positioning glyphs <LI> <A HREF="http://partners.adobe.com/public/developer/opentype/index_table_formats1.html">The GSUB table</A>, for substituting glyphs <LI> <A HREF="http://partners.adobe.com/public/developer/opentype/index_tag3.html">The feature tag registry</A>. </UL> <H2> How do these relate to Apple Advanced Typography features? </H2> <P> In some cases a contextual or chaining contextual substitution can be converted into one of Apple's contextual glyph substitution subtables. See the page on <A HREF="gposgsub.html#sometimes">Apple Advanced Typography </A>for more information as to when and caveats about how. <H2> Creating a contextual feature </H2> <P> Before you can edit one of these features you must create it from the <A HREF="fontinfo.html#Contextual">Element->Font Info->Contextual dialog</A>. <H2> Editing a feature </H2> <H3> <IMG SRC="contextchain-format.png" WIDTH="476" HEIGHT="503" ALIGN="Right">Format </H3> <P> Except for the reverse chaining features, any of these may come in one of three formats. <P> The simplest format is a list of <A HREF="#Glyphs">glyphs</A>. You may specify several glyph sequences in a single feature. So the script example above could be specified (quite inefficiently) by 4*26 lines like:<BR> <CODE> b a</CODE><BR> <CODE> b b</CODE><BR> <CODE> ...<BR> o a</CODE><BR> <CODE> ...</CODE> <P> The next format allows you to specify a list of <A HREF="#Classes">classes</A>. In the script example we would define 2 classes:<BR> <CODE> [bovw]</CODE><BR> <CODE> [ac-np-ux-z]</CODE><BR> and define two patterns as:<BR> <CODE> class1 [class2]<BR> class1 [class1]</CODE> <P> The third format is the most general and allows you to specify your pattern by a <A HREF="#Coverage">separate list of glyphs</A> for each glyph position:<BR> <CODE> [bovw] [a-z]</CODE><BR> <BR CLEAR=ALL> <H3> <IMG SRC="contextchain-coverage.png" WIDTH="476" HEIGHT="503" ALIGN="Right"><A NAME="Coverage">Coverage</A> </H3> <P> This display shows a list whose entries are coverage tables -- that is lists of glyphs. A match occurs if the current glyph matches one of the glyphs named in the current coverage table. <P> In the example at right there is only a single coverage table here (but there could be more). <P> In a Chaining Contextual feature it is also possible to specify a list of coverage tables to match glyphs before the current glyph, and another list to match glyphs after. <P> This feature does not directly describe how transformations are to happen to the glyphs, instead it invokes a list of nested lookups that are to be applied to specific positions in the match string (positions in the backtrack and lookahead lists may not be transformed). <P> In the example at right, the lookup 'high' will be applied to any glyph that matches the coverage table at the top of the list. Again the buttons under the sequence lookup list allow you to add, change, remove or reorder these transformations. (And yes, the order the transformations are applied can matter in complex situations). <H4> Creating or editing a lookup position pair </H4> <P> You can change a lookup by clicking on it, this will produce a pull down menu of all lookups that can be applied. You can change the position by editing it. <P> You can add a new entry by pressing the <New> button, and then selecting a lookup. <H3> Setting a coverage table </H3> <P> You can change a coverage table by editing it. You may enter either glyph names or unicode characters (which will be converted to a glyph name -- a few characters which have special meaning: space, right parenthesis, asterix; must have their names typed in full). If you click on the little box on the right you will get a dialog containing a font view. In this view you may select glyphs to your heart's content, when you press OK these glyphs become your table.<BR CLEAR=ALL> <H3> <IMG SRC="contextchain-glyphlists.png" WIDTH="476" HEIGHT="498" ALIGN="Right"><A NAME="Glyphs">Glyphs</A> </H3> <P> This format allows you to specify several glyph lists to match. In the example at right the string "A,B,C" will be matched in the glyphs before the current glyph, then "D E" starting at the current location, and finally "F G H" after them. If everything matched then the lookup "Smallcaps" will be applied to location 0 (in this case "D") , and "superscript" to location 1 (here, "E"). <P> The order is significant, word processors will stop at the first match they find so in the following pattern strings:<BR> <CODE> b a</CODE><BR> <CODE> b a f</CODE><BR> the second entry would never be matched because "b a" would be applied first. While:<BR> <CODE> b a f</CODE><BR> <CODE> b a</CODE><BR> would apply match "b a f" when an "f" was present, and "b a" otherwise.<BR CLEAR=ALL> <H3> <IMG SRC="contextchain-pickglyph.png" WIDTH="476" HEIGHT="503" ALIGN="Right">Selecting glyphs </H3> <P> The text field may be manipulated as above. However here we are specifying a string of glyphs each of which must be matched, rather than a class of glyphs any of which could match. So in the example at right, "DE" would match, but "E" would not. <P> As above a set of lookups can be applied after the match occurs.<BR CLEAR=ALL> <H3> <IMG SRC="contextchain-class.png" WIDTH="476" HEIGHT="503" ALIGN="Right"><A NAME="Classes">Classes</A> </H3> <P> When specifying a class match, you must specify at least one set of glyph classes. (you may also specify separate sets of classes for the backtrack and lookahead lists, or you use the same set for everything). You must also specify a list of patterns where each pattern is a list of numbers and each number is the index of the class into the class list. <P> Every set of classes has a magic class at index 0 which matches whatever glyphs are not explicitly mentioned in another class. FontForge displays this by calling it "{Everything Else}". You may not delete, edit nor reorder this class. Other classes are just unordered lists of glyph names (rather like coverage tables above), however any specific glyph may belong to at most one class at a time (whereas a glyph may occur in as many coverage tables as desired).<BR CLEAR=ALL> <H3> <IMG SRC="contextchain-classlist.png" WIDTH="476" HEIGHT="503" ALIGN="Right">A list of Class numbers </H3> <P> Once you have set up your classes, you may then edit the patterns you want to match. To remind you of what your classes are, FontForge displays the class list underneath the pattern. Clicking on a class will insert that class's index into the pattern. <P> Finally you must set the nested lookups. This is exactly the same as previous sequence / lookup settings.<BR CLEAR=ALL> <P ALIGN=Center> -- <A HREF="fontinfo.html">Up</A> -- <A HREF="overview.html">TOC</A> -- </DIV> </BODY></HTML>