Glyph Substitution
The two internal tables are the GSUB and GPOS tables that contain instructions for, respectively, glyph substitution and glyph positioning.
Glyph substitution involves replacing one or more glyphs with one or more different glyphs representing the same text string. The backing string of Unicode characters is not changed, only the visual representation. These substitutions may be required (as
part of script rendering), recommended as default behavior, or activated at the discretion of the user; they may also be contextual, active only when preceded or followed by a certain glyph or sequence of glyphs, or contextually chained so that one substitution affects another. In the first of the following simple examples, substitutions are made by activating the 'Standard Ligatures' OTL feature in a line of Latin script text. This replaces colliding letter combinations with ligatured forms: a better solution than adding space between the colliding glyphs that would result in gaping wounds in the middle of words. This font also contains a ligature for the frequent Th combination that reduces the amount of white space between the T and the h.
In this second example, a user has chosen to activate the 'Discretionary Ligatures' feature t o
replace the ct letter combination with a decorative, historical ligature. This flamboyant typographer has also used the 'Swash' feature to replace the initial Th ligature with a more calligraphic form, replace the y with a subtly swung form, and substitute corsiva versions of h and l.
None of these changes requires any font switching, because all the variant glyphs are included in a single italic font. Because all substitutions take place at the glyph level, rather than at the character level, the text string remains unchanged and can be selected, copied and pasted between Unicode savvy programs without semantic damage.
Glyph positioning
Features associated with the GPOS table shift glyphs from their normative positions and reposition them relative to each other. This is particularly useful for complex scripts in which graphic elements change position contextually, or in which quality typographic or manuscript tradition demands that two or more glyphs maintain a particular relationship when one or more of them are adjusted. For instance, GPOS lookups can be used to control the precise positioning of matras (vowel markers) in Indic scripts relative to base consonants or conjuncts, and can then adjust the position of other markers above and below the syllable to avoid collisions. The conjuncts themselves will have been rendered using GSUB lookups, and this is a good example of how GSUB and GPOS features work together to provide sophisticated solutions for complex script rendering.
I
n this Latin script example, two quite simple GPOS features—'Case-Sensitive Forms' and 'Capital Spacing'—are applied to the Spanish and English text when it is converted to an all uppercase setting.
In the mixed upper and lowercase setting above, the dot of the initial inverted question mar
k is vertically aligned with the x-height of the lowercase letters and descends below the baseline. Likewise, the parentheses around the English text are optically aligned with the mix of letter cases. In the image below, the same text has been set in all uppercase letters, and the two GPOS features have been applied. The 'Case-Sensitive Forms' feature has raised the inverted question mark to align with the capital letters, and has slightly raised the parentheses so that they vertically align with the new setting.
The third line allows direct comparison of the adjusted glyph positions to the normative vertical positioning. The light grey glyphs are in normative positions; the red glyphs show the new positions after the 'Case-Sensitive Forms' feature has been applied. It should also be noted that the same effect could have been achieved using GSUB lookups to replace the normative glyphs with glyphs in new positions; in fact, the registered definition of the 'Case-Sensitive Forms' feature explicitly notes that either solution is legitimate.
The second GPOS feature applied in the above example—'Capital Spacing'—is a metrics adjustment feature that increases the normal spacing between letters to make uppercase settings easier to read. These two features together are a good example of something that an application might choose to present to users as a single UI choice, associating both with an 'All Caps' option that uses Unicode case mapping to switch between lower and uppercase. An application might leave it to the user to select and apply these kind of case sensitive features to text, or it might use heuristics to identify words and phrases that the user has set in uppercase and apply the features automatically.
Both the features demonstrated above are examples of GPOS lookups that adjust the position of glyphs relative to their normative positions. It is also possible to adjust glyph positions relative to specific elements of other glyphs.