| 1 |
Metrics, spacing and kerning |
| 2 |
============================ |
| 3 |
|
| 4 |
|
| 5 |
Examining and controlling metrics |
| 6 |
--------------------------------- |
| 7 |
|
| 8 |
.. image:: /images/sidebearings.png |
| 9 |
:align: right |
| 10 |
|
| 11 |
After you have created the shapes of your glyphs you must next figure out the |
| 12 |
spacing between glyphs. The space between any two glyph has two components, the |
| 13 |
space after the first glyph, and the space before the second glyph. In a left to |
| 14 |
right world these two are called the right side bearing and the left side |
| 15 |
bearing respectively. |
| 16 |
|
| 17 |
The left side bearing may be changed by the simple expedient of |
| 18 |
:menuselection:`Edit --> Select All` (in the outline view) and then dragging the |
| 19 |
selected objects to the appropriate place. The right side bearing may be changed |
| 20 |
by selecting the advance width line and adjusting it appropriately. |
| 21 |
|
| 22 |
However it is generally better not to set the metrics of a single glyph in |
| 23 |
isolation, you should see the glyph in the context of other glyphs and set it |
| 24 |
from that perspective. Use the |
| 25 |
:menuselection:`Window --> Open `:doc:`Metrics Window </ui/mainviews/metricsview>` command. |
| 26 |
|
| 27 |
.. image:: /images/MetricsView.png |
| 28 |
|
| 29 |
Any glyphs selected in the fontview (when you invoke the metrics view) will be |
| 30 |
displayed in the metrics view. You may change which glyphs are displayed by |
| 31 |
either typing new ones in to the text field at the top of the view, or by |
| 32 |
dragging a glyph from the fontview. |
| 33 |
|
| 34 |
From here you may adjust any glyph's metrics by typing into the textfields below |
| 35 |
it, or you may select a glyph (by clicking on its image) and drag it around (to |
| 36 |
adjust the left side bearing), or drag its width line (to adjust its right side |
| 37 |
bearing). |
| 38 |
|
| 39 |
If you want to generate a "typewriter" style font (where all glyphs have the |
| 40 |
same width) execute an :menuselection:`Edit --> Select All` from the fontview |
| 41 |
and then :menuselection:`Metrics --> Set Width`. This will set the widths of all |
| 42 |
glyphs to the same value. After doing that you might also want to execute |
| 43 |
:menuselection:`Metrics --> Center in Width` to even out the left and right |
| 44 |
spacing on each glyph. |
| 45 |
|
| 46 |
.. image:: /images/autowidth.png |
| 47 |
:align: right |
| 48 |
|
| 49 |
If all this manual operation seems too complicated, try |
| 50 |
:ref:`Metrics->Auto Width <autowidth.AutoWidth>`. This will automagically assign |
| 51 |
widths to glyphs. These widths are not up to professional standards, but they |
| 52 |
are generally reasonable approximations. |
| 53 |
|
| 54 |
.. container:: clearer |
| 55 |
|
| 56 |
.. |
| 57 |
|
| 58 |
|
| 59 |
Vertical Metrics |
| 60 |
^^^^^^^^^^^^^^^^ |
| 61 |
|
| 62 |
FontForge provides some support for the vertical metrics needed for CJK fonts. |
| 63 |
First you must tell FontForge that this font should contain vertical metrics, do |
| 64 |
this with |
| 65 |
:menuselection:`Element --> Font Info --> General --> Has Vertical Metrics`. |
| 66 |
Then in each outline glyph enable VMetrics in the Layers palette. |
| 67 |
|
| 68 |
You should now see a vertical advance line somewhere underneath your glyph. You |
| 69 |
may drag this line just as you would the horizontal advance (width) line. |
| 70 |
|
| 71 |
|
| 72 |
Setting the baseline to baseline spacing of a font. |
| 73 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 74 |
|
| 75 |
You might imagine that there would be an easy way to set this seemingly |
| 76 |
important quantity. Unfortunately there is not. |
| 77 |
|
| 78 |
.. object:: In a PostScript Type1 font (or bare CFF font) |
| 79 |
|
| 80 |
There is no way to set this value. |
| 81 |
|
| 82 |
At all, ever. |
| 83 |
|
| 84 |
In traditional typography the inter-line spacing is 1em (which in FontForge |
| 85 |
is the ascent+descent of a font). Some applications will use this. Other |
| 86 |
applications will use the font's bounding box (summing the maximum ascender |
| 87 |
height with the minimum descender depth) -- a very bad, but very common |
| 88 |
approach. |
| 89 |
|
| 90 |
.. object:: In a TrueType or OpenType font |
| 91 |
|
| 92 |
Unfortunately this depends on the platform |
| 93 |
|
| 94 |
.. object:: Mac |
| 95 |
|
| 96 |
On a mac the baseline to baseline spacing is determined again by the |
| 97 |
bounding box values of the font, specified in the 'hhea' table, possibly |
| 98 |
modified by a linegap (Which you can set in FontForge with |
| 99 |
:doc:`Element->FontInfo->OS/2 </ui/dialogs/fontinfo>`. |
| 100 |
|
| 101 |
.. object:: On Windows |
| 102 |
|
| 103 |
According to the OpenType spec, the baseline to baseline distance is set |
| 104 |
by the values of Typographic Ascent and Descent of the 'OS/2' table. These |
| 105 |
can be set with :doc:`Element->FontInfo->OS/2 </ui/dialogs/fontinfo>`, but are usually |
| 106 |
allowed to default to the Ascent and Descent values of FontForge -- they |
| 107 |
generally sum to 1em and are equivalent to the traditional unleaded |
| 108 |
default. |
| 109 |
|
| 110 |
Again this may be modified by a linegap field. |
| 111 |
|
| 112 |
Unfortunately Windows programs rarely follow the standard (which I expect |
| 113 |
doesn't supprise anyone), and generally they will use the font's bounding |
| 114 |
box as specified in the Win Ascent/Descent fields of the 'OS/2' table. |
| 115 |
|
| 116 |
.. object:: On linux/unix |
| 117 |
|
| 118 |
I doubt there is any standard behavior. Unix apps will probably choose one |
| 119 |
of the above. |
| 120 |
|
| 121 |
Typographically ept applications will allow users to adjust baseline to baseline |
| 122 |
spacing, so the default value may not be all that relevant. |
| 123 |
|
| 124 |
|
| 125 |
Kerning |
| 126 |
------- |
| 127 |
|
| 128 |
If you are careful in setting the left and right side-bearings you can design |
| 129 |
your font so that the spacing looks nice in almost all cases. But there are |
| 130 |
always some cases which confound simple solutions. |
| 131 |
|
| 132 |
Consider "``To``" or "``Av``" here the standard choices are inappropriate. The |
| 133 |
"``o``" will look better if it can slide more to the left and snuggle under the |
| 134 |
top bar of the "``T``". This is called kerning, and it is used to control |
| 135 |
inter-glyph spacing on a pair-by-pair basis. |
| 136 |
|
| 137 |
.. rubric:: Kerning comparison |
| 138 |
|
| 139 |
.. flex-grid:: |
| 140 |
:class: flex-center |
| 141 |
|
| 142 |
* :flex-widths: 0 0 |
| 143 |
|
| 144 |
- .. image:: /images/To-unkerned.png |
| 145 |
- .. image:: /images/To-kerned.png |
| 146 |
|
| 147 |
.. image:: /images/addlookup-kern.png |
| 148 |
:align: right |
| 149 |
|
| 150 |
In the above example the left image shows the unkerned text, the right shows the |
| 151 |
kerned text. To create a kerned pair in the metrics window, simply click on the |
| 152 |
right glyph of the pair, the line (normally the horizontal advance) between the |
| 153 |
two should go green (and becomes the kerned advance). Drag this line around |
| 154 |
until the spacing looks nice. |
| 155 |
|
| 156 |
Sadly that statement is a simplification... Before you can create a kerning pair |
| 157 |
you must create a kerning lookup (see |
| 158 |
:ref:`the section on lookups <editexample4.lookups>`). Once again you bring up |
| 159 |
the :menuselection:`Element --> Font Info --> Lookups` pane and this time you |
| 160 |
must select the GPOS (Glyph Positioning) tab at the top of the pane. Once again |
| 161 |
you press ``[Add Lookup]``. This time the lookup type is "Pairwise Positioning", |
| 162 |
and the feature is "kern" (or perhaps "vkrn" if you want to do vertical |
| 163 |
kerning). |
| 164 |
|
| 165 |
Once you have created your lookup you again select it and press the [Add |
| 166 |
Subtable] button (which asks you to name the subtable). Then FontForge will ask |
| 167 |
you whether you want a subtable of kerning pairs or kerning classes. |
| 168 |
|
| 169 |
If you have many glyphs which have similar kerning features you might wish to |
| 170 |
create a set of :ref:`kerning classes <metricsview.kernclass>` (which might say |
| 171 |
that A, À, Á, Â, Â, Ã and Ä all kern alike). However for this example you want a |
| 172 |
kerning pair subtable. |
| 173 |
|
| 174 |
.. image:: /images/subtable-to.png |
| 175 |
:align: left |
| 176 |
|
| 177 |
Then FontForge will popup a dialog allowing you to set the kerning subtable |
| 178 |
directly. You may set your kerning pairs from here, though I prefer the metrics |
| 179 |
view myself because you can see more glyphs and so get a better feel for the |
| 180 |
"color" of the font. |
| 181 |
|
| 182 |
(Some glyph combinations are better treated by |
| 183 |
:ref:`creating a ligature <editexample4.ligature>` than by kerning the letters) |
| 184 |
|
| 185 |
.. container:: clearer |
| 186 |
|
| 187 |
.. |
| 188 |
|
| 189 |
|
| 190 |
Vertical Kerning |
| 191 |
^^^^^^^^^^^^^^^^ |
| 192 |
|
| 193 |
FontForge has equivalent support for vertical kerning. It can read and write |
| 194 |
vertical kerning information from and to truetype, opentype and svg fonts. It |
| 195 |
allows you to create vertical kerning classes. The metrics window has a vertical |
| 196 |
mode in which you can set vertical kerning pairs. Finally it has a command which |
| 197 |
will copy horizontal kerning information to the vertically rotated glyphs (That |
| 198 |
is, if the combination "A" "V" is horizontally kerned by -200, then "A.vert" |
| 199 |
"V.vert" should be vertically kerned by -200. |
| 200 |
|
| 201 |
(Vertical kerning is only available if the font has vertical metrics) |