| 1 |
Glyph variants and anchoring marks |
| 2 |
================================== |
| 3 |
|
| 4 |
|
| 5 |
Glyph Variants |
| 6 |
-------------- |
| 7 |
|
| 8 |
In many scripts glyphs have several variant glyphs. In latin the most obvious |
| 9 |
example is that every letter has both an upper case and a lower case variant. A |
| 10 |
more esoteric example would be that in renaissance times the long-s variant (of |
| 11 |
s) was used initially and medially in a word, while the short-s was only used at |
| 12 |
the end of a word. |
| 13 |
|
| 14 |
Most Arabic glyphs have four variants (initial, medial, final and isolated). |
| 15 |
|
| 16 |
The digits often have several variants: tabular digits (where all digits have |
| 17 |
the same advance width so that tables of numbers don't look ragged), |
| 18 |
proportional digits (where each digit has a width appropriate to its shape) and |
| 19 |
old-style or lower case digits (|lcdigits|) where some digits have descenders |
| 20 |
and others have ascenders. |
| 21 |
|
| 22 |
.. |lcdigits| image:: /images/lcdigits.png |
| 23 |
|
| 24 |
Some of these variants are built into the encodings (the upper and lower case |
| 25 |
distinction is), but in other cases you should provide extra information in the |
| 26 |
font so that the word processor can be aware of the variants (Arabic is midway |
| 27 |
between the two, the various forms are in the encoding, but you need to provide |
| 28 |
extra information as well). |
| 29 |
|
| 30 |
.. image:: /images/subtable-oldstyle.png |
| 31 |
:align: right |
| 32 |
|
| 33 |
Let us consider the case of the digits mentioned above. Assume that the glyph |
| 34 |
called "one" contains the tabular variant of one, the glyph "one.prop" contains |
| 35 |
the proportional variant and "one.oldstyle" contains the lower-case variant, and |
| 36 |
so on for all the other digits. Before you do anything else you must create two |
| 37 |
:ref:`lookups <editexample4.lookups>` and associated subtables (I shan't go into |
| 38 |
that again. Here the lookup type is "Single Substitution", and the features are |
| 39 |
"pnum" for Proportional Numbers and "onum" for Oldstyle Figures. Also the digits |
| 40 |
aren't in any single script, but are in many, so make this feature apply to |
| 41 |
multiple scripts (including "DFLT"). |
| 42 |
|
| 43 |
When FontForge brings up the dialog to fill in the oldstyle lookup subtable |
| 44 |
notice that there is a button [Default Using Suffix:] followed by a text field |
| 45 |
containing a suffix. Set the text field to "oldstyle" and press the button. It |
| 46 |
will search through all glyphs in all the scripts of the feature and find any |
| 47 |
"oldstyle" variants of them and populate the table with them. |
| 48 |
|
| 49 |
.. image:: /images/glyphinfo-one.png |
| 50 |
:align: left |
| 51 |
|
| 52 |
Sometimes it makes more sense to think of all the substitutions available for a |
| 53 |
specific glyph (rather than all substitutions in a specific lookup). So instead |
| 54 |
if filling up the subtable dialog for "Proportional Numbers" let us instead |
| 55 |
select "one" from the fontview, |
| 56 |
:ref:`Element->Glyph Info <charinfo.substitution>`, select the ``Substitutions`` |
| 57 |
tab and press the ``<New>`` button. |
| 58 |
|
| 59 |
(Note: Type0, Type1 and Type3 PostScript fonts have no notation to handle this. |
| 60 |
You need to be creating an OpenType or TrueType font for these variants to be |
| 61 |
output). |
| 62 |
|
| 63 |
|
| 64 |
.. _editexample6.Conditional: |
| 65 |
|
| 66 |
Conditional Variants |
| 67 |
^^^^^^^^^^^^^^^^^^^^ |
| 68 |
|
| 69 |
FontForge supports OpenType's Contextual Substitution and Chaining Contextual |
| 70 |
Substitution sub-tables, and to a lesser extent, Apple's contextual glyph |
| 71 |
substitution sub-table. This means that you can insert conditional variants into |
| 72 |
your font. :doc:`The next page <editexample6-5>` will go into this |
| 73 |
in greater detail. |
| 74 |
|
| 75 |
|
| 76 |
Anchoring marks |
| 77 |
--------------- |
| 78 |
|
| 79 |
Some scripts (Arabic, Hebrew) need vowel marks placed around the main text |
| 80 |
glyphs. Other scripts (some variants of Latin and Greek) have so many possible |
| 81 |
accent combinations that having preassembled glyphs for all combinations is |
| 82 |
unwieldy. |
| 83 |
|
| 84 |
In OpenType (which includes MicroSoft's TrueType fonts) it is possible to |
| 85 |
indicate on all base glyphs where marks should attach, and on all marks where |
| 86 |
the base glyphs should attach. Thus one could put an anchor centered above a |
| 87 |
lowercase-a indicating that all accents (acute, grave, umlaut, circumflex, |
| 88 |
tilde, macron, ring, caron, ...) should attach there, and underneath all the |
| 89 |
accents one could put another anchor so that when the two glyphs are adjacent in |
| 90 |
the text the word-processor will know where to place the accent so that it rides |
| 91 |
above the "a". |
| 92 |
|
| 93 |
.. flex-grid:: |
| 94 |
:class: flex-nobreak flex-middle |
| 95 |
|
| 96 |
* :flex-widths: 0 0 0 0 0 |
| 97 |
|
| 98 |
- .. image:: /images/a_with_anchor.png |
| 99 |
- \+ |
| 100 |
- .. image:: /images/grave_with_anchor.png |
| 101 |
- => |
| 102 |
- .. image:: /images/agrave_anchored.png |
| 103 |
|
| 104 |
Not all accents ride centered above the letter (the dot and ogonek ride below |
| 105 |
the letter), so you may need more than one anchor for different styles of |
| 106 |
attachment. |
| 107 |
|
| 108 |
Finally some letters can have multiple attachments, unicode U+1EA4, for example, |
| 109 |
is an A with a circumflex and an acute. Normally the circumflex and the acute |
| 110 |
will attach at the same point, which would be ugly and confusing. Instead we |
| 111 |
create a different kind of anchor, a mark to mark anchor, on the circumflex and |
| 112 |
allow the acute accent to attach to that. |
| 113 |
|
| 114 |
Before one can create an anchor in a glyph one must (of course) create a lookup |
| 115 |
and subtable. This is another Glyph Positioning lookup (so you enter it in the |
| 116 |
GPOS pane). Once you have created the subtable you will be presented with |
| 117 |
another dialog asking for anchor classes, you must create an |
| 118 |
:ref:`anchor class <overview.Anchors>` for each type of attachment (thus in the |
| 119 |
case of A above with two types of attachments (one above and one below) you |
| 120 |
would create two anchor classes. |
| 121 |
|
| 122 |
Then for each glyph in which an attachment will be made, you should first click |
| 123 |
at the point where the anchor is to be created and then bring up the |
| 124 |
:ref:`Point->Add Anchor <pointmenu.AddAnchor>` dialog. |
| 125 |
|
| 126 |
You can examine (and correct) how a glyph fits to any others that combine with |
| 127 |
it by using the :ref:`View->Anchor Control... <viewmenu.AControl>` command. |
| 128 |
|
| 129 |
.. warning:: |
| 130 |
|
| 131 |
**A warning about mark attachments:** Not all software supports them. And |
| 132 |
even more confusing software may support them for some scripts and not for |
| 133 |
others. |