1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
|
<HTML>
<HEAD>
<!-- Created with AOLpress/2.0 -->
<!-- AP: Created on: 27-Sep-2003 -->
<!-- AP: Last modified: 11-Nov-2009 -->
<TITLE>The Mac State Machine dialog</TITLE>
<LINK REL="icon" href="ffanvil16.png">
<LINK REL="stylesheet" TYPE="text/css" HREF="FontForge.css">
</HEAD>
<BODY>
<DIV id="in">
<H1 ALIGN=Center>
The Mac State Machine Dialog
</H1>
<P>
<IMG SRC="statemachine-context.png" WIDTH="490" HEIGHT="566" ALIGN="Right">The
mac uses state machines where opentype would use a contextual lookup. The
example at right (with appropriate substitutions attached to it) will convert
an initial or medial short-s into a long-s (for doing renaissance printing).
<P>
FontForge currently supports 4 types of state machines: contextual glyph
substitution, indic rearrangement, contextual glyph insertion, and contextual
kerning. The example at right is of contextual glyph substitution.
<P>
An example conditional substitution state machine is provided in the
<A HREF="editexample6-5.html#Apple">tutorial</A>.
<P>
On the mac there are four predefined classes, one meaning the end of input,
one for all glyphs not specified elsewhere, one for the magic "deleted" glyph
(Apple does not always delete a glyph when asked to do so, instead it retains
a special mark in the glyph stream indicating that the glyph should be deleted
later), and finally a class for the end of a line of text. Any classes after
this are user defined. In the example at right there are many user defined
classes representing various groupings of arabic letters. Any other glyphs
in the font (the digits for example) will automatically be assigned to class
1 ("{Everything Else}").
<P>
The state machine itself is shown as a two dimensional matrix of transitions,
one transition for every state and class. Classes are shown at the top of
the matrix, and states down the side. The transition from state 0 when given
input from class 0 is shown in the upper left corner of the matrix, and so
on.
<P>
When the state machine starts up it will be in one of the first two states.
It will be in state 0 at the beginning of input, and in state1 when it starts
at the beginning of a new line.
<P>
The <A NAME="transitions">transitions</A> look slightly differently depending
on the type of state machine:
<TABLE BORDER CELLPADDING="2">
<TR>
<TH>Indic</TH>
<TH>Contextual</TH>
<TH>Insertion</TH>
<TH>Kerning</TH>
</TR>
<TR>
<TD><P ALIGN=Center>
<IMG SRC="transition-indic.png" WIDTH="54" HEIGHT="64"></TD>
<TD><P ALIGN=Center>
<IMG SRC="transition-context.png" WIDTH="54" HEIGHT="64"></TD>
<TD><P ALIGN=Center>
<IMG SRC="transition-insert.png" WIDTH="54" HEIGHT="64"></TD>
<TD><P ALIGN=Center>
<IMG SRC="transition-kern.png" WIDTH="54" HEIGHT="64"></TD>
</TR>
</TABLE>
<P>
The first line of all transitions shows the next state. The next line contains
a set of flags where "M" => the current glyph should be marked (the meaning
of this becomes apparent later), "A" => processing should advance to the
next glyph. For indic tables there is a third flag shown, "L" => the current
glyph is the last glyph of the indic rearrangement, while for kerning tables
there is a "P" flag indicating that the current glyph should be pushed onto
the kerning stack.
<P>
The last two lines have varied meanings depending on the type of the state
machine.
<UL>
<LI>
For Indic transitions the two lines should be appended to get the indic
rearrangement verb (in the example above that would be "Ax => xA" meaning
that the first glyph marked should be moved after the last glyph marked)
<LI>
For contextual transitions the two lines specify the lookup names of simple
substitutions. The first one is applied to the last glyph marked and the
second one to the current glyph (if a line is blank, no substitution is applied
to that glyph here).<BR>
If a transition has both a "marked substitution" and the "mark current glyph"
flag, I believe the substitution applies to the glyph that was previously
marked, and not to the current glyph. (Apple doesn't document
this)<FONT COLOR="Red"><BR>
<STRONG>Caveat: </STRONG></FONT>Apple's 'mort' format was not designed to
allow fonteditors to figure out what a state machine did. FontForge can usually
make a good guess of what substitutions do which apply to the current glyph,
but it will often include extraneous glyph substitutions when a substitution
applies to a marked glyph. These should not be harmful (they should never
get invoked) but they are annoying ('morx' tables should not have this problem).
<LI>
For insertion transitions the lines specify the glyphs that are to be inserted.
The first line applies to the marked glyph, the second line to current glyph
(there may not be room enough to show all the inserted glyphs, in which case
the glyph list is truncated). There are additional flags here that are also
not shown because of lack of room. They may be viewed by clicking on a
transition.
<LI>
For kerning transitions the first line shows the first (few) kerning values,
the second line shows either "..." if there are more kerning values, or
nothing.<BR>
Note: The number of kerning values
<FONT COLOR="Red"><STRONG>MUST</STRONG></FONT> match the number of glyphs
pushed on the kern stack, or your application crashes.
</UL>
<P>
For a complete description of what these state machines can do you should
read Apple's documentation
<UL>
<LI>
On the
<A HREF="http://developer.apple.com/fonts/TTRefMan/RM06/Chap6morx.html">'morx'</A>
and
<A HREF="http://developer.apple.com/fonts/TTRefMan/RM06/Chap6mort.html">'mort'</A>
tables
<LI>
On the
<A HREF="http://developer.apple.com/fonts/TTRefMan/RM06/Chap6kern.html">'kern'</A>
table (format 1)
<LI>
<A HREF="http://developer.apple.com/fonts/TTRefMan/RM06/Chap6Tables.html#StateTables">On
state machines in general</A>
<LI>
<A HREF="http://developer.apple.com/fonts/TTRefMan/RM06/Chap6feat.html">The
'feat' (feature) table</A>
<LI>
<A HREF="http://developer.apple.com/fonts/Registry/index.html">Apple's Font
Feature registry</A>
</UL>
<P>
The general idea is that a word processor converts text into a string of
glyphs, and then the state machine is applied to that string. The state machine
starts in state 0 or 1, it figures out what class the first glyph belongs
to, and indexes into the current state by that class. The transition at that
location provides a new state to move to (which might be the same as the
current one), it will usually advance to the next glyph (so the new state
will be indexed by a different glyph) but sometimes you will want to continue
processing the current glyph in the new state. Also it will perform a set
of operations which differ depending on the type of state machine.
<P>
Many of the state machines have the concept of a "marked" glyph. This is
important if the desired change for a given glyph depends on what glyphs
follow it. In that case when we reach an interesting glyph we "mark" it,
and then, after reading a few more glyphs when we know what to do, we apply
a transformation to the marked glyph.
<TABLE BORDER CELLPADDING="2">
<TR>
<TH>Indic</TH>
<TH>Contextual</TH>
<TH>Insertion</TH>
<TH>Kerning</TH>
</TR>
<TR VALIGN="Top">
<TD><P ALIGN=Left>
In addition to a "mark"ed glyph, indic transformations also have a the concept
of a "last" glyph. There are 16 transformations which may be applied the
the glyphs between the "mark"ed and "last" glyphs. Suppose the glyph stream
looks like<BR>
abcdef<BR>
And "a" was "mark"ed and "d" was "last" then a transition "AxD => DxA"
refers to the marked glyph as "A", the last glyph as "D" and everything in
between as "x", so this would change the glyph stream to<BR>
dbcaef</TD>
<TD>This can apply a substitution to the current glyph, a different substitution
to the marked glyph, and it may mark the current glyph. The substitutions
are indicated by 4 character tags and should be "Nested" substitutions which
may be created by the Element->Char Info dialog.</TD>
<TD>This can insert a string (up to 31 glyphs) before or after the current
and the marked glyphs.</TD>
<TD>Kerning does not have a single "mark"ed glyph, instead it can push up
to 8 glyphs onto a stack, and at a later point a set of kerning values may
be applied to those glyphs (so the flag which is usually indicated as "M"
for mark, is here "P" for push). Once all the glyphs have been pushed, a
set of kerning values may be applied. One value for each pushed glyph. This
is a number which indicates how much the glyph in question should be kerned.
If the glyph stream looks like:<BR>
F."<BR>
and you want to kern "." by -300, and """ by 0 em-units, then you would
enter<BR>
-300 0<BR>
as kerning values.</TD>
</TR>
</TABLE>
<H2>
Editing <A NAME="EditTransition">Transitions</A>
</H2>
<P>
To edit a transition, simply click on it and a dialog will pop up, appropriate
to the type of state machine.
<TABLE BORDER CELLPADDING="2">
<TR>
<TH>Indic</TH>
<TH>Contextual</TH>
<TH>Insertion</TH>
<TH>Kerning</TH>
</TR>
<TR>
<TD><P ALIGN=Center>
<IMG SRC="edittransition-indic.png" WIDTH="282" HEIGHT="431"></TD>
<TD><P ALIGN=Center>
<IMG SRC="edittransition-context.png" WIDTH="282" HEIGHT="431"></TD>
<TD><P ALIGN=Center>
<IMG SRC="edittransition-insert.png" WIDTH="282" HEIGHT="431"></TD>
<TD><P ALIGN=Center>
<IMG SRC="edittransition-kern.png" WIDTH="282" HEIGHT="431"></TD>
</TR>
</TABLE>
<P>
See <A HREF="statemachine.html#transitions">above</A> for a description of
what the fields mean.
<P>
If you wish to add a new state, simply edit a transition so that its next
state field is the state number desired. FontForge will automatically create
the state for you.<BR Clear=ALL>
<P>
<P ALIGN=Center>
-- <A HREF="fontinfo.html">Up</A> -- <A HREF="overview.html">TOC</A> --
</DIV>
</BODY></HTML>
|