Debian Codegraph @

doc/sphinx/techref/gposgsub.rst

raw
1 Advanced Typography Tables
2 ==========================
3
4 These differ between OpenType (originally called TrueType Open) and Apple (GX or
5 Apple Advanced Typography). My support for both OpenType and Apple is
6 incomplete.
7
8 * :ref:`The GPOS, GSUB and GDEF OpenType tables <gposgsub.opentype>`
9 * :ref:`Apple Advanced Typography <gposgsub.AAT>`
10 * :ref:`What features can be converted between OpenType and AAT? <gposgsub.Conversion>`
11 * :doc:`other true type and open type tables <TrueOpenTables>`
12 * :ref:`What is unsupported <gposgsub.Unsupported>`
13 * :doc:`FontForge's non-standard extensions <non-standard>`
14
15
16 .. _gposgsub.opentype:
17
18 The ``GPOS``, ``GSUB``, ``GDEF`` and ``BASE`` OpenType tables
19 -------------------------------------------------------------
20
21 The first two tables are used for positioning and substituting glyphs. The GPOS
22 table can control things like: kerning, accent positioning, cursive joining,
23 etc. The GSUB table can control things like: ligatures, arabic forms, vertical
24 rotation, conversion to small caps, indic glyph rearrangement, etc. GDEF
25 contains some rather esoteric glyph information, ligature carets, etc. BASE
26 contains information on baseline placement and line heights.
27
28 This page assumes basic familiarity with the abilities of the tables, for more
29 information on them read, study and inwardly digest the OpenType docs on:
30
31 * `The header for both GPOS and GSUB <http://partners.adobe.com/public/developer/opentype/index_table_formats.html>`__
32 * `The GPOS table <http://partners.adobe.com/public/developer/opentype/index_table_formats2.html>`__,
33 for positioning glyphs
34 * `The GSUB table <http://partners.adobe.com/public/developer/opentype/index_table_formats1.html>`__,
35 for substituting glyphs
36 * `The GDEF table <http://partners.adobe.com/public/developer/opentype/index_table_formats5.html>`__,
37 for classifying glyphs and for providing a ligature caret table
38 * `The BASE table <http://partners.adobe.com/public/developer/opentype/index_base.html>`__,
39 for baseline placement
40 * `The list of feature tags supported by OpenType <http://partners.adobe.com/public/developer/opentype/index_tag3.html>`__
41 * `The list of script tags supported by OpenType <http://partners.adobe.com/public/developer/opentype/index_tag1.html>`__
42 * `The list of language tags supported by OpenType <http://partners.adobe.com/public/developer/opentype/index_tag2.html>`__
43 * `The list of baseline tags supported by OpenType <http://partners.adobe.com/public/developer/opentype/index_tag4.html>`__
44
45 The basic idea of the GPOS and GSUB tables is that each script (or language
46 within a script) has a set of "features" that are available to it. A feature in
47 turn is associated with a lookup which contains data for the feature. An example
48 of a script is 'latn' for latin, 'arab' for arabic, 'hani' for chinese
49 ideographs. Two examples of features are 'kern' which provides kerning
50 information between pairs of glyphs and 'init' which will transform one set of
51 glyphs to another when those glyphs are at the beginning of a word.
52
53 FontForge :ref:`does not support <gposgsub.Unsupported>` the full range of
54 possibilities inherent in these tables.
55
56
57 .. _gposgsub.GPOS:
58
59 The **GPOS** table
60 ^^^^^^^^^^^^^^^^^^
61
62 FontForge will read the following sub tables of the GPOS table:
63
64 .. object:: single adjustment
65
66 .. object:: Reading support
67
68 This sub-table allows the font designer to change the metrics of a
69 specific glyph. The feature tag will provide a context in which the change
70 should occur. For instance the 'tnum' (tabular numbers) feature could
71 change a proportionally spaced digit by adjusting its advance width to be
72 some set value and then centering the digit (by adjusting the left side
73 bearing) within the new width.
74
75 .. object:: Writing support
76
77 These can be created with the
78 :doc:`Element->Char Info </ui/dialogs/charinfo>`->Position command.
79
80 .. object:: pair adjustment
81
82 .. object:: Reading support
83
84 This sub-table allows the font designer to change the metrics of a
85 specific pair of glyph. The most common use of this is for kerning where
86 the advance width of the first glyph is altered depending on which glyph
87 follows it. But the table is more general than that and could support mark
88 (accent, vowel) positioning over a base glyph (though that is more
89 efficiently done with the mark to base subtable).
90
91 .. object:: Writing support
92
93 'kern' feature s may be created from the
94 :doc:`Metrics View </ui/mainviews/metricsview>`. 'vkrn' with
95 :ref:`Metrics->VKern From HKern <metricsmenu.VKernFromHKern>`.
96
97 .. object:: cursive attachment
98
99 .. object:: Reading support
100
101 This sub-table allows the font designer to force adjacent glyphs to join
102 at specific points. It can be used to generate the slanted script style
103 needed for Urdu.
104
105 .. object:: Writing support
106
107 Only the 'curs' feature is supported for this sub-table. These may be
108 created with the :ref:`Points->Add Anchor <pointmenu.AddAnchor>` command
109
110 .. object:: mark to base
111
112 .. object:: Reading support
113
114 This sub-table allows the font designer to specify how mark glyphs
115 (accents, vowel signs, etc.) are positioned over base glyphs. Every glyph
116 can have an attachment point and the mark's attachment point will be
117 placed on the base's attachment point so the two join properly. See my
118 :ref:`example <overview.Anchors>` in the overview.
119
120 .. object:: Writing support
121
122 These may be created with the
123 :ref:`Points->Add Anchor <pointmenu.AddAnchor>` command
124
125 .. object:: mark to ligature
126
127 .. object:: Reading support
128
129 This sub-table is very similar to the previous one except that the base
130 glyph is a ligature and may have several different points at which the
131 same type of accent may be placed.
132
133 .. object:: Writing support
134
135 These may be created with the
136 :ref:`Points->Add Anchor <pointmenu.AddAnchor>` command
137
138 .. object:: mark to mark
139
140 .. object:: Reading support
141
142 This sub-table is very similar to the previous two except that the base
143 glyph is itself a mark. This may be used when a glyph has two accents each
144 of which would normally be placed at the same attachment point on a base
145 glyph. The second accent will be place relative to the first accent rather
146 than to the base glyph.
147
148 .. object:: Writing support
149
150 These may be created with the
151 :ref:`Points->Add Anchor <pointmenu.AddAnchor>` command
152
153 .. object:: contextual positioning
154
155 .. object:: Reading support
156
157 This sub-table allows the font designer to control the positioning of
158 glyphs when they occur within a specific string (or class of strings). For
159 instance this table could say "when you see a digit followed by the string
160 "th" then raise the "th" into a superscript position"
161
162 .. object:: Writing support
163
164 These may be created with the
165 :ref:`Element->Font Info->Contextual <lookups.contextual-subs>` command
166
167 .. object:: chaining contextual positioning
168
169 .. object:: Reading support
170
171 This is a slightly more complex version of the above, it doesn't really
172 add new capabilities, but it does provide a more logical approach to the
173 issue.
174
175 .. object:: Writing support
176
177 These may be created with the
178 :ref:`Element->Font Info->Contextual <lookups.contextual-subs>` command
179
180 .. object:: extension positioning
181
182 .. object:: Reading support
183
184 This is used to allow for a GPOS table which is bigger than 64k. Its use
185 should be quite invisible to the font designer
186
187 .. object:: Writing support
188
189 FontForge uses this sub-table when needed.
190
191 .. object:: reserved for future use
192
193 .. object:: Writing support
194
195 FontForge does not support these sub-tables yet.
196
197 (nor does anyone)
198
199 FontForge also has built into it knowledge on how to provide default values for
200 some features that use these tables.
201
202 FontForge will retain the order of features in the GPOS table and when a font is
203 generated the order should be the same as it was before.
204
205
206 .. _gposgsub.GSUB:
207
208 The **GSUB** table
209 ^^^^^^^^^^^^^^^^^^
210
211 FontForge will read the following sub tables of the GSUB table:
212
213 .. object:: single substitution
214
215 .. object:: Reading support
216
217 This sub-table allows the font designer to change from one glyph to
218 another, with a context provided by the feature tag. For example many
219 scripts have letters which have a different form at the end of a word than
220 they do within (this is true of every letter in arabic, several in hebrew,
221 lower case sigma in greek, and the long-s/short-s pair in renaissance
222 latin). So the 'fina' feature would map the normal form into the final
223 form, and the word processing program would do a lookup at the end of each
224 word to see if a transformation was needed.
225
226 .. object:: Writing support
227
228 These can be created with the
229 :doc:`Element->Char Info </ui/dialogs/charinfo>`->Substitution command.
230
231 .. object:: multiple substitution
232
233 .. object:: Reading support
234
235 This sub-table allows the font designer to replace one glyph by a series
236 of others. This is generally used for rather technical layout issues.
237
238 .. object:: Writing support
239
240 These can be created with the
241 :doc:`Element->Char Info </ui/dialogs/charinfo>`->Multiple Substitution command.
242
243 .. object:: alternate substitution
244
245 .. object:: Reading support
246
247 This sub-table allows the font designer to have a series of "alternates"
248 for each glyph. One common example would be an italic font which had
249 several swash variants for each capital letter. The word processing
250 program would allow the user to choose which variant was appropriate
251
252 .. object:: Writing support
253
254 These can be created with the
255 :doc:`Element->Char Info </ui/dialogs/charinfo>`->Alternate Substitution command.
256
257 .. object:: ligature substitution
258
259 .. object:: Reading support
260
261 This sub-table allows the font designer to replace a string of glyphs with
262 another glyph. A common example is a ligature where the string |f+i| is
263 replaced by the |fi| ligature.
264
265 .. |f+i| image:: /images/f+i.png
266 .. |fi| image:: /images/fi.png
267
268 .. object:: Writing support
269
270 These can be created with the
271 :doc:`Element->Char Info </ui/dialogs/charinfo>`->Ligature command.
272
273 .. object:: contextual substitution
274
275 .. object:: Reading support
276
277 This subtable allows for a string of glyphs to replace another string of
278 glyphs (or class of strings of glyphs)
279
280 .. object:: Writing support
281
282 These may be created with the
283 :ref:`Element->Font Info->Contextual <lookups.contextual-subs>` command
284
285 .. object:: chaining contextual substitution
286
287 .. object:: Reading support
288
289 This is a slightly more complex version of the above, it doesn't really
290 add new capabilities, but it does provide a more logical approach to the
291 issue.
292
293 .. object:: Writing support
294
295 These may be created with the
296 :ref:`Element->Font Info->Contextual <lookups.contextual-subs>` command
297
298 .. object:: extension positioning
299
300 .. object:: Reading support
301
302 This is used to allow for a GSUB table which is bigger than 64k. Its use
303 should be quite invisible to the font designer
304
305 .. object:: Writing support
306
307 FontForge uses this sub-table when needed.
308
309 .. object:: reverse chaining contextual single substitution
310
311 .. object:: Reading support
312
313 This allows glyph substitutions to happen in reverse order, and it a
314 variant of the chaining contextual subtable.
315
316 .. object:: Writing support
317
318 These may be created with the
319 :ref:`Element->Font Info->Contextual <lookups.contextual-subs>` command
320
321 .. object:: reserved for future use
322
323 .. object:: Writing support
324
325 FontForge does not support these sub-tables yet.
326
327 (nor does anyone)
328
329 FontForge also has built into it knowledge on how to provide default values for
330 some features that use these tables. See the [Populate] button of the various
331 :doc:`lookup subtable </ui/dialogs/lookups>` dialogs.
332
333 FontForge can produce some of these tables, but the text layout/word processing
334 program used has to look up the tables and do the actual work of rearranging the
335 glyphs.
336
337 FontForge will retain the order of features in the GSUB table, and the user may
338 adjust it with the :doc:`Element->Font Info </ui/dialogs/lookups>` command.
339
340
341 .. _gposgsub.GDEF:
342
343 The **GDEF** table
344 ^^^^^^^^^^^^^^^^^^
345
346 FontForge will read ligature carets out of a GDEF table.
347
348 It will generate a GDEF table containing a glyph class definition sub-table (if
349 needed) or a ligature caret sub-table (if needed).
350
351
352 .. _gposgsub.AAT:
353
354 Apple Advanced Typography
355 -------------------------
356
357 As above I do not go deeply into the abilities of these tables, for more
358 information see Apple's docs:
359
360 * `The 'bsln' (baseline) table <http://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6bsln.html>`__
361 * `The 'kern' table <http://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6kern.html>`__
362 * `The 'lcar' (ligature caret) table <http://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6lcar.html>`__
363 * `The 'morx' (extended glyph metamorphosis) table <http://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6morx.html>`__
364
365 * `The 'mort' (older version of 'morx') table <http://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6mort.html>`__
366 * `The 'feat' (feature) table <http://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6feat.html>`__
367 * `Apple's Font Feature registry <http://developer.apple.com/fonts/Registry/index.html>`__
368 * `Description of the subtables of the 'mort'/'morx' tables <http://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6Tables.html>`__
369 * `The 'opbd' (optical bounds) table <http://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6opbd.html>`__
370 * `The 'prop' (glyph properties) table <http://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6prop.html>`__
371
372 FontForge will currently read and produce (if Apple mode is set in font
373 generation) the following tables:
374
375 .. rubric:: Apple tables corresponding vaguely to BASE
376
377 .. object:: baseline table
378
379 .. object:: Reading support
380
381 FontForge will read baseline data (except for Apple's ideographic centered
382 baseline, for which there is no OpenType equivalent)
383
384 .. object:: Writing support
385
386 FontForge will produce this table if the user has specified baseline data
387 which apple supports
388
389 .. rubric:: Apple tables corresponding vaguely to GDEF
390
391 .. object:: ligature caret table
392
393 .. object:: Reading support
394
395 FontForge will read ligature carets
396
397 .. object:: Writing support
398
399 FontForge will produce this table if the user has specified ligature
400 carets
401
402 .. object:: glyph properties table
403
404 .. object:: Reading support
405
406 FontForge will read this table to figure out which glyphs are hebrew and
407 arabic, and which have 'r2la' substitutions.
408
409 .. object:: Writing support
410
411 FontForge will generate this table if the font contains some right to left
412 glyphs.
413
414 .. rubric:: Apple tables corresponding vaguely to GPOS
415
416 .. object:: kerning table
417
418 .. object:: Reading support
419
420 FontForge will read horizontal/vertical kerning pairs and classes.
421 FontForge can read contextual kerning information too into a state
422 machine.
423
424 .. object:: Writing support
425
426 FontForge will produce this if the font contains kerning data -- kerning
427 pairs, kerning by classes, and kerning by state machine.
428
429 .. object:: Optical bounds table
430
431 .. object:: Reading support
432
433 FontForge will read optical bounds
434
435 .. object:: Writing support
436
437 FontForge will produce this table if the user has specified right and left
438 bounds as simple positions ('lfbd' and 'rtbd').
439
440 .. _gposgsub.morx:
441
442 FontForge has support for the ``'mort'`` and ``'morx'`` tables (Glyph
443 metamorphosis and extended glyph metamorphosis tables). These correspond vaguely
444 to the :ref:`GSUB <gposgsub.GSUB>` table. Note: Any feature type/setting
445 combinations which correspond directly to an open type feature will be converted
446 to the OpenType tag when read in. It will be converted back to a feature/setting
447 when an apple font is generated (use :ref:`File->Preferences <prefs.Mac>` to
448 extend FontForge's mapping from feature type/setting to OpenType tags).
449
450 .. rubric:: Sub tables of 'mort' or 'morx'
451
452 .. object:: Indic style rearrangement
453
454 .. object:: Reading support
455
456 FontForge can read these and stores them as state machines (which can be
457 edited with :ref:`Font Info <lookups.sm-subs>`)
458
459 .. object:: Writing support
460
461 Any indic state machines will be output in the generated font.
462
463 .. object:: contextual glyph substitution
464
465 .. object:: Reading support
466
467 FontForge can read these and stores them as state machines (which can be
468 edited with :ref:`Font Info <lookups.sm-subs>`)
469
470 .. object:: Writing support
471
472 If the font contains any state machines they will be output here. If there
473 are no state machines then the following conversions of OpenType features
474 will be done:
475
476 .. _gposgsub.cursive-connection:
477
478 * FontForge will generate a cursive connection feature using this subtable
479 type if the font contains 'init', 'medi', 'fina' or 'isol' simple
480 substitutions.
481 * In :ref:`some cases <gposgsub.sometimes>` FontForge is able to convert an
482 OpenType Contextual/Chaining substitution table into an Apple contextual
483 glyph substitution table.
484
485 .. object:: ligature substitution
486
487 .. object:: Reading support
488
489 FontForge can read the unconditional information from these and stores
490 them as OpenType ligatures (which can be edited with
491 :doc:`Font Info </ui/dialogs/lookups>` or :doc:`Char Info </ui/dialogs/charinfo>`).
492
493 .. object:: Writing support
494
495 If there are any ligatures with an apple feature/setting (or which have an
496 OpenType tag which can be converted to an apple feature/setting) then this
497 table will be output.
498
499 .. object:: non-contextual glyph substitution
500
501 .. object:: Reading support
502
503 FontForge can read these and stores them as OpenType simple substitutions
504 (which can be edited with :doc:`Font Info </ui/dialogs/lookups>` or
505 :doc:`Char Info </ui/dialogs/charinfo>`)
506
507 .. object:: Writing support
508
509 If there are any substitutions with an apple feature/setting (or which
510 have an OpenType tag which can be converted to an apple feature/setting)
511 then this table will be output.
512
513 .. object:: contextual glyph insertion
514
515 .. object:: Reading support
516
517 FontForge can read these and stores them as state machines (which can be
518 edited with :ref:`Font Info <lookups.sm-subs>`)
519
520 .. object:: Writing support
521
522 Any glyph insertion state machines will be output in the generated font.
523
524
525 .. _gposgsub.Conversion:
526
527 What features can be interconverted between OpenType and AAT?
528 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
529
530 Some features have almost the same meaning in OpenType and AAT (although they
531 are expressed quite differently), others are similar enough that they can
532 sometimes be converted, and others have essentially no common ground.
533
534 .. object:: GDEF -> lcar
535
536 The ligature caret information in both 'GDEF' and 'lcar' is essentially
537 identical and FontForge has no trouble reading both and converting from one
538 to the other.
539
540 .. object:: BASE -> bsln
541
542 There is slightly different baseline data in the two formats. 'bsln' does not
543 provide extent information. 'bsln' provides a baseline for every glyph, while
544 'BASE' provides a baseline for every script -- one hopes all glyphs in a
545 script will have the same baseline, but it isn't guaranteed. Finally 'bsln'
546 and 'BASE' provide a slightly different set of baseline tags, and FontForge
547 only supports the OpenType ones. In particular Apple's ideographic centered
548 baseline will be lost.
549
550 .. object:: GPOS -> kern
551
552 In most cases kerning information can be converted from one format to
553 another. Both provide support for vertical kerning and right to left kerning.
554 Both provide support for kerning by glyph pair and kerning by classes.
555
556 OpenType allows kerning commands to be supplied via a contextual chaining
557 feature, Apple allows them to be controlled by a state machine. FontForge
558 supports both, but does not interconvert.
559
560 .. object:: GPOS -> opbd
561
562 The GPOS features 'lfbd' and 'rtbd' provide the information needed to
563 generate an Apple opbd table. If FontForge reads a font with an opbd table it
564 will generate appropriate 'lfbd' and 'rtbd' features. If FontForge generates
565 a font in apple mode that has these features it will create an opbd table.
566 Similarly when FontForge reads an opbd table it will create 'lfbd' and 'rtbd'
567 features.
568
569 .. object:: GPOS -> other
570
571 I am not aware of any way to convert other GPOS features to AAT.
572
573 .. object:: GSUB -> morx / mort
574
575 The 'mort' and 'morx' tables have the same capabilities ('mort' tables are an
576 old format and Apple currently encourages that 'morx' tables be used
577 instead). FontForge can read either one, but only generates 'morx' tables.
578 Interconversion depends on specific feature types and the sub-table formats,
579 see below
580
581
582 An analysis of GSUB and morx sub-tables and feature tags
583 """"""""""""""""""""""""""""""""""""""""""""""""""""""""
584
585 OpenType uses a four character feature tag (like 'liga') while Apple uses two
586 numbers to represent a feature setting (<1,2>). For FontForge to be able to
587 inter-convert an OpenType feature into an Apple feature there must first be a
588 correspondence between the two naming conventions. Sometimes there is an easy
589 direct conversion (above 'liga' and <1,2> both represent "Common Ligatures") but
590 far more often there is none. See :ref:`below <gposgsub.OT-Mac-features>` for a
591 list of the tags and feature settings that FontForge considers similar enough to
592 interconvert.
593
594 GSUB tables have 7 sub-table formats, while morx tables have 5.
595
596 .. object:: Single -> Non-Contextual Glyph
597
598 These two sub-tables have almost exactly the same capabilities. Each allows
599 one glyph to be substituted for another. The morx sub-table also allows a
600 glyph to be deleted, while the GSUB sub-table does not.
601
602 .. object:: Multiple -> N/A
603
604 This GSUB subtable allows a single glyph to be replaced by multiple glyphs.
605 It has some similarities to Apple's Glyph Insertion sub-table except:
606
607 * the 'morx' sub-table always leaves the current glyph in the glyph stream,
608 while this sub-table need not
609 * the 'morx' sub-table is contextual while this sub-table is never. (But if
610 this sub-table is wrapped inside a Context or Chaining Context subtable the
611 result can be contextual).
612
613 .. object:: N/A -> Glyph Insertion
614
615 This morx subtable allows a string of glyphs to be inserted before or after
616 the current glyph (the current glyph always remains). This sub-table is
617 contextual (ie. the insertion can be restricted to certain contexts). It
618 bears some similarities to the GSUB Multiple subtable above.
619
620 .. object:: Alternate -> N/A
621
622 This GSUB subtable allows a single glyph to be replaced by any one of several
623 alternatives (presumably with help from a word processor's UI). An example of
624 this would be a character which had several swash variants. There is nothing
625 like this in the 'morx' table.
626
627 .. object:: Ligature -> Ligature
628
629 Both formats have ligature sub-tables. The 'GSUB' version is unconditional
630 (the ligature is always applied -- though a ligature substitution could be
631 embedded in an OpenType contextual substitution to make it conditional). The
632 'morx' version can be contextual (though in fonts I have examined it is
633 usually uncontextual). FontForge only supports unconditional ligatures.
634
635 FontForge can read all the unconditional ligatures from a 'morx' sub-table.
636 FontForge loses all contextual ligatures.
637
638 In OpenType, contextual ligatures can be built by wrapping a ligature
639 sub-table inside a Context or Chaining Context subtable.
640
641 .. object:: N/A -> Contextual Glyph
642
643 This morx subtable allows single glyph substitutions to be applied within
644 certain contexts. At first glance it seems that this could be converted into
645 an OpenType Context subtable,
646 :ref:`but this is rarely the case <gposgsub.sometimes>`.
647
648 .. object:: Chaining / Chaining Context -> N/A
649
650 These GSUB subtables allow any collection of other substitutions to be applied
651 contextually. At first glance one might think that these (with appropriate
652 nested substitutions) might be converted to 'morx' contextual glyph
653 substitutions, contextual ligatures, or even glyph insertion.
654 :ref:`Unfortunately this is rarely the case <gposgsub.sometimes>`.
655
656 .. object:: Reverse Chaining Context -> N/A
657
658 This GSUB subtable is applied backwards to the stream of glyphs, it allows a
659 single glyph substitution per contextual match. There is nothing like it in
660 'morx'.
661
662 .. object:: N/A -> Indic Rearrangement
663
664 This 'morx' subtable allows for several glyphs to interchange their positions
665 in the glyph stream. There is nothing like it in GSUB (or GPOS for that
666 matter).
667
668
669 .. _gposgsub.sometimes:
670
671 Why do contextual glyph substitutions only sometimes get generated in AAT?
672 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
673
674 Sadly OpenType and AAT provide disjoint capabilities when it comes to contextual
675 matching. AAT is more capable in some areas, OpenType more capable in others.
676 FontForge is able to convert an OpenType contextual substitution into an AAT one
677 if FontForge can detect that the OpenType substitution does not use capabilities
678 beyond those of AAT. Currently this means:
679
680 * There is an apple feature which matches the otf tag
681 * And one of the following is true:
682
683 #. Either
684
685 * The sub-table is in coverage format
686 * The sub-table contains either exactly one nested single glyph replacement
687 substitution, or
688
689 it contains exactly two single glyph replacements and one of them refers to the
690 last glyph matched (and the other does not)
691 #. or
692
693 * The sub-table is in either glyph or class format
694 * If in class format then either the backtrack and lookahead classes must be the
695 same as the main class, or they must not be used.
696 * If a rule has a substitution at a given glyph position, then all rules which
697 match the current rule up to that glyph position must also have a substitution
698 at that position.
699 * A rule with exactly one substitution is acceptable
700
701 A rule with one substitution in the middle and one substitution on the last
702 glyph is acceptable.
703
704 A rule may contain more substitutions only if there is another rule which
705 matches it exactly up to the internal substitution.
706
707 So the following rule set is valid:
708
709 .. list-table::
710 :stub-columns: 1
711
712 * - Rule
713 - a
714 - b
715 - c
716 - d
717 - e
718 - f
719 * - Rule
720 - a
721 - b
722 - c
723 - d
724 -
725 -
726 * - Rule
727 - a
728 - b
729 -
730 -
731 -
732 -
733 * - Substitutions
734 - A
735 - B
736 - C
737 - D
738 - E
739 - F
740
741 So the third rule will match an "ab" and convert them to "AB" (and this is valid
742 because we have one internal and one final substitution and that's ok), then if
743 that "ab" is followed by "cd" then rule 2 kicks in and will replace the "cd"
744 with "CD" (again this has one internal and one final substitution, which is ok),
745 and if that is followed by "ef" then they will be converted to "EF".
746
747 The following is not valid:
748
749 .. list-table::
750 :stub-columns: 1
751
752 * - Substitution
753 -
754 - B
755 -
756 * - Rule
757 - a
758 - b
759 - c
760 * -
761 -
762 -
763 -
764 * - Rule
765 - a
766 - b
767 -
768 * - Substitution
769 - A
770 -
771 -
772
773 The two rules have substitutions at different places and that can't be expressed
774 in an Apple state machine given that they have the same glyphs.
775
776 FontForge does not even try to convert an AAT contextual glyph substitution
777 sub-table, too few of these can be expressed in OpenType to make it worth while.
778
779 NOTE: It would be possible to convert more lookups to state machines if
780 FontForge were willing to:
781
782 #. Use several state machines to represent complicated lookups
783 #. Add additional glyphs to the font to be used as temporary state flags.
784
785 FontForge will do neither of these.
786
787 .. warning::
788
789 There is a subtle bug involved in converting a chaining contextual
790 substitution into an Apple contextual glyph substitution. AAT does not have
791 the concept of a backtrack list, this means that substitutions may occur in a
792 different order.
793
794
795 .. _gposgsub.not-converted:
796
797 Why can't all contextual/chaining tables be converted?
798 """"""""""""""""""""""""""""""""""""""""""""""""""""""
799
800 Well, obviously there are some thing that just aren't present. The concept of
801 contextual positioning is missing from AAT, while Indic rearrangement is missing
802 from OpenType. So let's concentrate on contextual substitutions, which both
803 appear to support. The argument that follows is based on the capabilities of
804 contextual matching, it applies equally to contextual ligatures, glyph
805 insertion, glyph substitution and kerning, the examples given are only of glyph
806 substitution because it is easier to represent (and because FontForge is only
807 willing to convert contextual glyph substitutions) But even here, there is a
808 very basic mismatch in concepts between the way OpenType and Apple specify
809 contextual substitutions. Consider the following contextual substitution in a
810 glyph list format:
811
812 .. list-table::
813 :stub-columns: 1
814
815 * - Initial Sequence
816 - a
817 - b
818 - c
819 - d
820 * - Replace With
821 -
822 - B
823 - C
824 -
825
826 Now in OpenType this means if you find the sequence "abcd" then replace the "b"
827 with "B" and the "c" with "C". But this can't be expressed in an Apple state
828 machine. In OpenType the match is done first, and then the substitutions occur.
829 In a state machine the substitutions have to be done (almost) concurrently with
830 the match and so must happen whether the final "d" is present or not. (Note I'm
831 using a glyph sequence because it is easier to display in an example. The same
832 problem applies if the substitution is expressed by classes or by coverage
833 tables)
834
835 Consider the following table with two glyph strings
836
837 .. list-table::
838 :stub-columns: 1
839
840 * - Initial Sequence
841 - a
842 - b
843 - c
844 - d
845 * - Replace With
846 -
847 - B
848 -
849 -
850 * - Initial Sequence
851 - a
852 - b
853 - c
854 - e
855 * - Replace With
856 -
857 -
858 - C
859 -
860
861 So replace the "b" if the final "d" is present, otherwise replace the "c". Again
862 this cannot be expressed in Apple's state machines.
863
864 Finally consider
865
866 .. list-table::
867 :stub-columns: 1
868
869 * - Initial Sequence
870 - a
871 - b
872 - c
873 - d
874 * - Replace With
875 -
876 -
877 - C
878 -
879 * - Initial Sequence
880 - b
881 - c
882 - e
883 -
884 * - Replace With
885 - B
886 -
887 -
888 -
889
890 If this substitution is given the sequence "abce" it cannot work in AAT. When it
891 reads the "a" it will start down the "abcd" branch, the match will not fail
892 until it looks for the "d" and finds "e" instead. At that point it is too late
893 to switch to the "bce" substitution (which does match) because the "b" glyph
894 will not have been marked as a substitution location.
895
896 --------------------------------------------------------------------------------
897
898 On the other hand, Apple's state machines can express things that OpenType
899 tables cannot (again I'm restricting myself to contextual glyph substitutions).
900 Consider the case of a swash glyph at the beginning (or end) of a word. Let us
901 say that a word begins when a letter appears at the start of input or following
902 a whitespace character. But OpenType has no way of expressing "start of input"
903 (or end of input) in a contextual/chaining context, whereas Apple's state
904 machines do.
905
906 Since Apple's glyph substitutions can delete glyphs a contextual glyph
907 substitution table can create two character ligatures (one glyph is converted to
908 the ligature and the other is deleted), while OpenType tables must use a
909 ligature substitution to do this.
910
911 Finally an AAT state machine can match a general regular expression, while
912 OpenType tables can only match fixed length strings. Suppose you were
913 typesetting mathematics and wanted a substitution which would convert an
914 arbitrary digit string following a variable into a subscript (so x23 should
915 become x\ :sub:`23`). It is easy to write a state machine which will keep
916 substituting as long as it gets more digits, but you'd need an infinite
917 number of OpenType rules to have the same expressive power.
918
919 These examples probably seem fairly contrived, and (except for the swash one)
920 they are. But they illustrate the point that the two formats have very different
921 expressive capabilities and it is NOT possible to write a converter which will
922 take any input in one format and produce an equivalent output in the other.
923
924
925 Apple and OpenType features
926 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
927
928 .. list-table:: Correspondences between Apple and OpenType features (that I support)
929 :name: gposgsub.OT-Mac-features
930 :header-rows: 1
931
932 * - Apple Feature Setting
933 - OpenType Feature Name
934 - OpenType Tag
935 * - Required Ligatures
936 - Required Ligatures
937 - rlig
938 * - Common Ligatures
939 - Standard Ligatures
940 - liga
941 * - Rare Ligatures
942 - Discretionary
943 - dlig
944 * - Fractions
945 - Fractions
946 - frac
947 * -
948 -
949 -
950 * - Contextual Alternatives
951 - Cursive connection
952 - calt
953 * -
954 -
955 -
956 * - Vertical Forms
957 - Vertical Rotation 2
958 - vrt2
959 * - Monospace numbers
960 - Tabular numbers
961 - tnum
962 * - Superscript
963 - Superscript
964 - sups
965 * - Subscript
966 - Subscript
967 - subs
968 * - Proportional Text
969 - Proportional Widths
970 - pwid
971 * - Half-width Text
972 - Half Width
973 - hwid
974 * - Full-width Text
975 - Full Width
976 - fwid
977 * - Traditional Characters
978 - Traditional
979 - trad
980 * - Simplified Characters
981 - Simplified
982 - smpl
983 * - JIS 1978 Characters
984 - JIS 1978 Characters
985 - jp78
986 * - JIS 1983 Characters
987 - JIS 1983 Characters
988 - jp83
989 * - JIS 1990 Characters
990 - JIS 1990 Characters
991 - jp90
992
993 FontForge will retain the order of features in the morx table, and the user may
994 adjust it with the :ref:`Element->Font Info <fontinfo.Lookups>` command. (this
995 is the same list as that used for GSUB table. GSUB features that don't
996 correspond to mac features will be ignored).
997
998
999 .. _gposgsub.Unsupported:
1000
1001 What is Unsupported?
1002 --------------------
1003
1004 FontForge does not (yet) support all the advanced typographic features available
1005 in either OpenType or apple advanced typography.
1006
1007
1008 OpenType
1009 ^^^^^^^^
1010
1011 * FontForge does not provide an attachment list subtable nor a MarkAttachClassDef
1012 subtable of the GDEF table.
1013 * FontForge does not support the VORG and JUST tables
1014
1015 :doc:`See here for a complete list of supported tables <TrueOpenTables>`.
1016
1017
1018 Apple Advanced Typography
1019 ^^^^^^^^^^^^^^^^^^^^^^^^^
1020
1021 * FontForge will never generate a 'mort' table. It can read 'mort' tables, but it
1022 will only produce 'morx' tables.
1023 * FontForge is unable to parse contextual ligatures. It can find ligatures which
1024 start from state 0, but it will not find ligatures which start from other states
1025 (that is, which are contextual)
1026 * FontForge does not support the following Apple specific tables
1027
1028 * acnt (accent attachment)
1029 * bsln (baseline)
1030 * fdsc (font descriptor)
1031 * fmtx (font metrics)
1032 * hsty (horizontal style)
1033 * just (justification)
1034 * trak (tracking)
1035 * Zapf (glyph reference)
1036
1037 :doc:`See here for a complete list of supported tables <TrueOpenTables>`.