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