Fix the handling of LAM-ALEF.
[m17n/m17n-db.git] / FORMATS / FLT.txt
index bf7ea15..a90be42 100644 (file)
@@ -41,8 +41,9 @@ glyph code.
 
 <li> category
 
-This is the category code defined in the @c CATEGORY-TABLE
-of the current stage.
+The category code defined in the @c CATEGORY-TABLE of the current
+stage, or defined in the one of the former stages and not overwritten
+by later stages.
 
 <li> combining-spec
 
@@ -65,21 +66,20 @@ overlap with the next one.
 
 When the layout engine draws text, it at first determines a font and
 an FLT for each character in the text.  For each subsequence of
-characters that use use the same font and FLT, the layout engine
-generates an intermediate glyph sequence from the character
-subsequence.  Each element in the intermediate glyph sequence
-has the corresponding character code as the code attribute and zeroes
-for other attributes.  This sequence is processed in the
+characters that use the same font and FLT, the layout engine generates
+a corresponding intermediate glyph sequence.  The code attribute of
+each element in the intermediate glyph sequence is its character code,
+and all other attributes are zeros.  This sequence is processed in the
 first stage of FLT as the current @e run (substring).
 
 Each stage works as follows.
 
-At first, if the stage has a @c CATEGORY-TABLE, the category of each glyph
-in the current run is updated.  If there is a glyph that has no category,
-the current run ends before that glyph.
+At first, if the stage has a @c CATEGORY-TABLE, the category of each
+glyph in the current run is updated.  If there is a glyph that has no
+category, the current run ends before that glyph.
 
-Then, the default values of code-offset, combining-spec, and left-padding-flag
-of this stage are initialized to zero.
+Then, the default values of code-offset, combining-spec, and
+left-padding-flag of this stage are initialized to zero.
 
 Next, the initial conversion rule of the stage is applied to the
 current run.
@@ -93,7 +93,18 @@ The m17n library loads an FLT from the m17n database using the tag
 \<font, layouter, FLT-NAME\>.  The date format of an FLT is as follows:
 
 @verbatim
-FONT-LAYOUT-TABLE ::= STAGE0 STAGE *
+FONT-LAYOUT-TABLE ::= FLT-DECLARATION ? STAGE0 STAGE *
+
+FLT-DECLARATION ::= '(' 'font' 'layouter' FLT-NAME nil PROP * ')'
+FLT-NAME ::= SYMBOL
+PROP :: = VERSION | FONT
+VERSION ::= '(' 'version' MTEXT ')'
+FONT ::= '(' 'font' FONT-SPEC ')'
+FONT-SPEC ::=
+     '(' [[ FOUNDRY FAMILY
+           [ WEIGHT [ STYLE [ STRETCH [ ADSTYLE ]]]]]
+         REGISTRY ]
+        [ OTF-SPEC ] [ LANG-SPEC ] ')'
 
 STAGE0 ::= CATEGORY-TABLE GENERATOR
 
@@ -114,23 +125,23 @@ CATEGORY is ASCII code of an upper or lower letter, i.e. one of 'A',
 ... 'Z', 'a', .. 'z'.
 
 The first form of @c CATEGORY-SPEC assigns @c CATEGORY to a glyph
-whose code @c CODE.  The second form assigns @c CATEGORY to glyphs
+whose code is @c CODE.  The second form assigns @c CATEGORY to glyphs
 whose code falls between the two @c CODEs.
 
 @verbatim
 GENERATOR ::= '(' 'generator' RULE MACRO-DEF * ')'
 
 RULE ::= REGEXP-BLOCK | MATCH-BLOCK | SUBST-BLOCK | COND-BLOCK
-         | DIRECT-CODE | COMBINING-SPEC | OTF-SPEC
+         FONT-FACILITY-BLOCK | DIRECT-CODE | COMBINING-SPEC | OTF-SPEC
          | PREDEFINED-RULE | MACRO-NAME
 
 MACOR-DEF ::= '(' MACRO-NAME RULE + ')'
 @endverbatim
 
-Each @c RULE specifies glyphs to be consumed and glyphs to be produced.  When
-some glyphs are consumed, they are taken away from the current run.  A
-rule may fail in some condition.  If not described explicitly to
-fail, it should be regarded that the rule succeeds.
+Each @c RULE specifies glyphs to be consumed and glyphs to be
+produced.  When some glyphs are consumed, they are taken away from the
+current run.  A rule may fail in some condition.  If not described
+explicitly to fail, it should be regarded that the rule succeeds.
 
 @verbatim
 DIRECT-CODE ::= INTEGER
@@ -181,15 +192,14 @@ No glyph is consumed.  No glyph is produced.
 
 <li> @c @]
 
-This rule changes the right-padding-flag of the lastly generated
-glyph to 1.
-No glyph is consumed.  No glyph is produced.
+This rule changes the right-padding-flag of the lastly generated glyph
+to 1.  No glyph is consumed.  No glyph is produced.
 
 <li> @c |
 
 This rule consumes no glyph and produces a special glyph whose
-category is ' ' and other attributes are zero.  
-This is the only rule that produces that special glyph.
+category is ' ' and other attributes are zero.  This is the only rule
+that produces that special glyph.
 
 </ul>
 
@@ -246,16 +256,26 @@ glyph code of the code sequence.  In this case, this rule sets the
 default code-offset to the first glyph code minus the first @c CODE
 specifying the range.
 
-
 If no match is found, this rule fails.
 
 @verbatim
+FONT-FACILITY-BLOCK ::= '(' FONT-FACILITY RULE * ')'
+FONT-FACILITY = '(' 'font-facility' CODE * ')'
+               | '(' 'font-facility' FONT-SPEC ')'
+@endverbatim
+
+If the current font has glyphs for @c CODEs or matches with @c
+FONT-SPEC, this rule succeeds and @c RULEs are executed.  Otherwise,
+this rule fails.
+
+@verbatim
 COND-BLOCK ::= '(' 'cond' RULE + ')'
 @endverbatim
 
 This rule sequentially executes @c RULEs until one succeeds.  If no
 rule succeeds, this rule fails.  Otherwise, it succeeds.
 
+@anchor OTF-SPEC
 @verbatim
 OTF-SPEC ::= SYMBOL
 @endverbatim
@@ -264,7 +284,7 @@ OTF-SPEC ::= SYMBOL
 driver.  The name has the following syntax.
 
 @verbatim
-  OTF-SPEC-NAME ::= 'otf:' SCRIPT LANGSYS ? GSUB-FEATURES ? GPOS-FEATURES ?
+  OTF-SPEC-NAME ::= ':otf=' SCRIPT LANGSYS ? GSUB-FEATURES ? GPOS-FEATURES ?
 
   SCRIPT ::= SYMBOL
 
@@ -288,16 +308,22 @@ For @c LANGSYS, @c SYMBOL specifies a Language System tag name.  If @c
 LANGSYS is omitted, the Default Language System
 table is used.
 
-For @c GSUB-FEATURES, each @c SYMBOL in @c FEATURE LIST specifies a GSUB Feature tag name
-to apply.  '*' is allowed as the last item to specify all remaining
-features.  If @c SYMBOL is preceded by '~' and the last item is '*',
-@c SYMBOL is excluded from the features to apply.  If no @c SYMBOL is
-specified, no GSUB feature is applied.  If @c GSUB-FEATURES itself is
-omitted, all GSUB features are applied.
+For @c GSUB-FEATURES, each @c SYMBOL in @c FEATURE-LIST specifies 
+a GSUB Feature tag name to apply.  '*' is allowed as the last item to
+specify all remaining features.  If @c SYMBOL is preceded by '~' and
+the last item is '*', @c SYMBOL is excluded from the features to
+apply.  If no @c SYMBOL is specified, no GSUB feature is applied.  If
+@c GSUB-FEATURES itself is omitted, all GSUB features are applied.
+
+When @c OTF-SPEC appears in a @c FONT-SPEC, @c FEATURE-LIST specifies
+features that the font must have (or must not have if preceded by
+'~'), and the last'*', even if exists, has no meaning.
 
 The specification of @c GPOS-FEATURES is analogous to that of @c
 GSUB-FEATURES.
 
+Please note that all the tags above must be 4 ASCII printable characters.
+
 See the following page for the OpenType specification.\n
     <http://www.microsoft.com/typography/otspec/default.htm>
 
@@ -305,10 +331,10 @@ See the following page for the OpenType specification.\n
 COMBINING ::= SYMBOL
 @endverbatim
 
-@c COMBINING is a symbol whose name specifies how
-to combine the next glyph with the previous one.  This rule sets the
-default combining-spec to an integer code that is unique to the symbol
-name.  The name has the following syntax.
+@c COMBINING is a symbol whose name specifies how to combine the next
+glyph with the previous one.  This rule sets the default
+combining-spec to an integer code that is unique to the symbol name.
+The name has the following syntax.
 
 @verbatim
   COMBINING-NAME ::= VPOS HPOS OFFSET VPOS HPOS
@@ -346,9 +372,10 @@ as described below.
 
 The left figure shows 12 reference points of a glyph by numbers 0 to
 11.  The rectangle 0-6-8-2 is the bounding box of the glyph, the
-positions 3, 4, and 5 are on the baseline, 9 and 11 are on the center
-of the lines 0-6 and 2-8 respectively, 1, 10, 4, and 7 are on the
-center of the lines 1-2, 3-5, 9-11, and 6-8 respectively.
+positions 3, 4, and 5 are on the baseline, 9-11 are on the vertical
+center of the box, 0-2 and 6-8 are on the top and on the bottom
+respectively.  1, 10, 4, and 7 are on the horizontal center of the
+box.
 
 The right table shows how those reference points are specified by a
 pair of @c VPOS and @c HPOS.
@@ -363,11 +390,11 @@ The next glyph is drawn so that these two reference points align.
 reference points are on the same position.
 
 @c XOFF specifies how much the X position of the reference point of
-the next glyph should be shifted to the right ('<') or left ('>') from
+the next glyph should be shifted to the left ('<') or right ('>') from
 the previous reference point.
 
 @c YOFF specifies how much the Y position of the reference point the
-next glyphshould be shifted upward ('+') or downward ('-') from the
+next glyph should be shifted upward ('+') or downward ('-') from the
 previous reference point.
 
 In both cases, @c INTEGER is the amount of shift expressed as a
@@ -383,7 +410,7 @@ MACRO-NAME ::= SYMBOL
 @endverbatim
 
 @c MACRO-NAME is a symbol that appears in one of @c MACRO-DEF.  It is
-exapanded to the sequence of the correponding @c RULEs.
+exapanded to the sequence of the corresponding @c RULEs.
 
 @section flt-context-dependent CONTEXT DEPENDENT BEHAVIOR
 
@@ -456,6 +483,6 @@ Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
 License along with the m17n library; if not, write to the Free
-Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307, USA.
+Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.
 */