| 1 |
Accented glyphs, ligatures, lookups and features |
| 2 |
================================================ |
| 3 |
|
| 4 |
|
| 5 |
Building accented glyphs |
| 6 |
------------------------ |
| 7 |
|
| 8 |
Latin, Greek and Cyrillic all have a large complement of accented glyphs. |
| 9 |
FontForge provides several ways to build accented glyphs out of base glyphs. |
| 10 |
|
| 11 |
The most obvious mechanism is simple copy and paste: :ref:`Copy <editmenu.Copy>` |
| 12 |
the letter "A" and :ref:`Paste <editmenu.Paste>` it to "Ã" then |
| 13 |
:ref:`copy <editmenu.Copy>` the tilde accent and |
| 14 |
:ref:`Paste it Into <editmenu.PasteInto>` "Ã" (note Paste Into is subtly |
| 15 |
different from Paste. Paste clears out the glyph before pasting, while Paste |
| 16 |
Into merges what was in the glyph with the what is in the clipboard). Then you |
| 17 |
open up "Ã" and position the accent so that it appears properly centered over |
| 18 |
the A. |
| 19 |
|
| 20 |
This mechanism is not particularly efficient, if you change the shape of the |
| 21 |
letter "A" you will need to regenerate all the accented glyphs built from it. |
| 22 |
FontForge has the concept of a :ref:`Reference <overview.References>` to a |
| 23 |
glyph. So you can Copy a Reference to "A", and Paste it, the Copy a Reference to |
| 24 |
tilde and Paste it Into, and then again adjust the position of the accent over |
| 25 |
the A. |
| 26 |
|
| 27 |
Then if you change the shape of the A the shape of the A in "Ã" will be updated |
| 28 |
automagically -- as will the width of "Ã". |
| 29 |
|
| 30 |
But FontForge knows that "Ã" is built out of "A" and the tilde accent, and it |
| 31 |
can easily create your accented glyphs itself by placing the references in "Ã" |
| 32 |
and then positioning the accent over the "A". (The Unicode consortium provides a |
| 33 |
database which lists the components of every accented glyph in Unicode and |
| 34 |
FontForge uses this). |
| 35 |
|
| 36 |
As an example, open the file: tutorial/Ambrosia.sfd, then select all the glyphs |
| 37 |
at encodings 0xc0-0xff, and then press |
| 38 |
:ref:`Element->Build->Build Accented <elementmenu.Accented>` all the accented |
| 39 |
glyphs will magically appear (there are a few glyphs in this range which are not |
| 40 |
accented, and they will remain blank). |
| 41 |
|
| 42 |
FontForge has a heuristic for positioning accents (most accents are centered |
| 43 |
over the highest point of the glyph), sometimes this will produce bad results |
| 44 |
(if the one of the two stems of "u" is slightly taller than the other the accent |
| 45 |
will be placed over it rather than being centered over the glyph), so you should |
| 46 |
be prepared to look at your accented glyphs after creating them. You may need to |
| 47 |
adjust one or two (or you may even want to redesign your base glyphs slightly). |
| 48 |
|
| 49 |
|
| 50 |
.. _editexample4.ligature: |
| 51 |
|
| 52 |
Creating a ligature |
| 53 |
------------------- |
| 54 |
|
| 55 |
Unicode contains a number of ligature glyphs (in latin we have: Æ, OE, fi, etc. |
| 56 |
while in arabic there are hundreds). Again Unicode provides a database listing |
| 57 |
the components of each standard ligature. |
| 58 |
|
| 59 |
FontForge cannot create a nice ligature for you, but what it can do is put all |
| 60 |
the components of the ligature into the glyph with |
| 61 |
:ref:`Element->Build->Build Composite <elementmenu.Accented>`. This makes it |
| 62 |
slightly easier (at least in latin) to design a ligature. For this to work the |
| 63 |
original glyph and the combining glyph (identified by circles plus the glyph) |
| 64 |
must be present in the overview. If either of them is not, the menuitem is |
| 65 |
disabled. To find of which components the glyph consists review Glyph Info |
| 66 |
and then the Components section. |
| 67 |
|
| 68 |
.. rubric:: Steps to building a ligature |
| 69 |
|
| 70 |
.. flex-grid:: |
| 71 |
|
| 72 |
* - .. image:: /images/ffi-refs.png |
| 73 |
:alt: ffi ligature as references |
| 74 |
|
| 75 |
Use the :ref:`Element -> Glyph Info <elementmenu.CharInfo>` dialog to name |
| 76 |
the glyph and mark it as a ligature. Then use |
| 77 |
:ref:`Element -> Build -> Build Composite <elementmenu.Accented>` to insert |
| 78 |
references to the ligature components. |
| 79 |
- .. image:: /images/ffi-unlink.png |
| 80 |
:alt: ffi after unlinking references |
| 81 |
|
| 82 |
Use the :ref:`Edit-> Unlink References <editmenu.Unlink>` command to turn the |
| 83 |
references into a set of contours. |
| 84 |
- .. image:: /images/ffi-moved.png |
| 85 |
:alt: ffi after lowering first f |
| 86 |
|
| 87 |
Adjust the components so that they will look better together. Here the stem |
| 88 |
of the first f has been lowered. |
| 89 |
- .. image:: /images/ffi-rmoverlap.png |
| 90 |
:alt: ffi after doing remove overlap |
| 91 |
|
| 92 |
Use the :ref:`Element -> Remove Overlap <elementmenu.Remove>` command to |
| 93 |
clean up the glyph. |
| 94 |
- .. image:: /images/ffi-caret.png |
| 95 |
:alt: ffi after adjusting ligature carets |
| 96 |
|
| 97 |
Finally drag the ligature caret lines from the origin to more appropriate |
| 98 |
places between the components. |
| 99 |
|
| 100 |
Some word processors will allow the editing caret to be placed inside a ligature |
| 101 |
(with a caret position between each component of the ligature). This means that |
| 102 |
the user of that word processor does not need to know s/he is dealing with a |
| 103 |
ligature and sees behavior very similar to what s/he would see if the components |
| 104 |
were present. But if the word processor is to be able to do this it must have |
| 105 |
some information from the font designer giving the locations of appropriate |
| 106 |
caret positions. As soon as FontForge notices that a glyph is a ligature it will |
| 107 |
insert in it enough caret location lines to fit between the ligature's |
| 108 |
components. FontForge places these on the origin, if you leave them on the |
| 109 |
origin FontForge will ignore them. But once you have built your ligature you |
| 110 |
might want to move the pointer tool over to the origin line, press the button |
| 111 |
and drag one of the caret lines to its correct location. (Only Apple Advanced |
| 112 |
Typography and OpenType support this). |
| 113 |
|
| 114 |
There are a good many ligatures needed for the indic scripts, but Unicode does |
| 115 |
not provide an encoding for them. If you wish to build a ligature that is not |
| 116 |
part of Unicode you may do so. First |
| 117 |
:ref:`add an unencoded glyph to your font <faq.new-name>` (or if your font is a |
| 118 |
Unicode font, you could use a code point in the private use area), and name the |
| 119 |
glyph. The name is important, if you name it correctly FontForge will be able to |
| 120 |
figure out that it is a ligature and what its components are. If you want to |
| 121 |
build a ligature out of the glyphs "longs", "longs" and "l" then name it |
| 122 |
"longs_longs_l", if you want to build a ligature out of Unicode 0D15, 0D4D and |
| 123 |
0D15 then name it "uni0D15_uni0D4D_uni0D15". |
| 124 |
|
| 125 |
Once you have named your ligature, and inserted its components (with Build |
| 126 |
Composite), you probably want to open the glyph, |
| 127 |
:ref:`Unlink your References <editmenu.Unlink>` and edit them to make a pleasing |
| 128 |
shape (as above). |
| 129 |
|
| 130 |
|
| 131 |
.. _editexample4.lookups: |
| 132 |
|
| 133 |
Lookups and Features |
| 134 |
-------------------- |
| 135 |
|
| 136 |
.. image:: /images/fontinfo-lookups.png |
| 137 |
:align: right |
| 138 |
|
| 139 |
Unfortunately simply creating a ligature glyph is not enough. You must also |
| 140 |
include information in the font to say that the glyph is a ligature, and to say |
| 141 |
what components it is built from. |
| 142 |
|
| 143 |
In OpenType this is handled by lookups and features. A lookup is a collection of |
| 144 |
tables in the font which contain transformation information. A feature is a |
| 145 |
collection of lookups and is a provides semantic information to the world |
| 146 |
outside the font about what that set of lookups can be expected to do. So in the |
| 147 |
example above the lookup would contain the information that "f" + "f" + "i" |
| 148 |
should turn into "ffi", while the feature would say that this is a standard |
| 149 |
ligature for the latin script. |
| 150 |
|
| 151 |
So the first time you create a ligature glyph you will need to create a lookup |
| 152 |
(and a lookup subtable) in which the information for that glyph will reside. Any |
| 153 |
subsequent ligatures can probably share the same lookup and subtable. |
| 154 |
|
| 155 |
(This may seem like overkill for latin ligatures, and perhaps it is, but the |
| 156 |
complexity is needed for more complex writing systems). |
| 157 |
|
| 158 |
You would open the Lookups pane of the |
| 159 |
:ref:`Element->FontInfo <fontinfo.Lookups>` command and press the |
| 160 |
``[Add Lookup]`` button. This will give you a new dialog in which you can fill |
| 161 |
in the attributes of your new lookup. |
| 162 |
|
| 163 |
.. image:: /images/AddLookup-Liga.png |
| 164 |
:align: left |
| 165 |
|
| 166 |
You must first choose the lookup type. For ligatures this should be "Ligature |
| 167 |
Substitution". You may then bind this lookup to a feature, script and language |
| 168 |
set. The "ffi" ligature is a standard ligature in latin typesetting so it should |
| 169 |
be bound to the 'liga' tag, and the 'latn' script. (If you click on the little |
| 170 |
box to the right of "liga" you will get a pulldown list of the so-called |
| 171 |
"friendly names" for the features. "liga" corresponds to "Standard Ligatures"). |
| 172 |
|
| 173 |
The language is a bit tricky. This ligature should probably be active for all |
| 174 |
languages except Turkish that use the latin script (Turkish uses a dotlessi and |
| 175 |
it is not clear whether the "i" in the "fi" and "ffi" ligatures has a dot over |
| 176 |
it). So we want to list all languages but Turkish. That's a lot of languages. |
| 177 |
The convention instead is that if a language isn't mentioned explicitly anywhere |
| 178 |
in the font then that language will be treated as the "default" language. So to |
| 179 |
make this feature not be active for Turkish, we'd have to create some other |
| 180 |
feature which specifically mentioned Turkish in its language list. |
| 181 |
|
| 182 |
Underneath the feature list is a set of flags. In latin ligatures none of these |
| 183 |
flags need be set. In Arabic one might want to set both "Right to Left" and |
| 184 |
"Ignore Combining Marks". |
| 185 |
|
| 186 |
Next the lookup must be given a name. This name is for your use and will never |
| 187 |
be seen in the real font. The name must be distinct from the name of any other |
| 188 |
lookup however. |
| 189 |
|
| 190 |
Finally you get to decide whether you want the ligatures in this lookup to be |
| 191 |
stored in afm files. |
| 192 |
|
| 193 |
.. image:: /images/subtable-ffi.png |
| 194 |
:align: right |
| 195 |
|
| 196 |
Once you have created a lookup, you must create a subtable in that lookup. |
| 197 |
Select the lookup line (in the Lookups pane of Font Info) and press |
| 198 |
``[Add Subtable]``. This is a fairly simple dialog... you simply provide a name |
| 199 |
for the sub-table, and then another dialog will pop up and you will (finally) be |
| 200 |
able to store your ligature information. |
| 201 |
|
| 202 |
.. warning:: |
| 203 |
|
| 204 |
OpenType engines will only apply features which they believe are appropriate |
| 205 |
for the current script (in Latin scripts, Uniscribe will apply 'liga'). Even |
| 206 |
worse, some applications may choose not to apply any features ever (Word does |
| 207 |
not do ligatures in latin -- though this may have changed with the 2007 |
| 208 |
release?). |
| 209 |
`Microsoft tries to document <http://www.microsoft.com/typography/specs/default.htm>`__ |
| 210 |
what features they apply for which scripts in Uniscribe, but that isn't very |
| 211 |
helpful since Word and Office have quite different behavior than the default. |