Debian Codegraph @

doc/sphinx/ui/mainviews/metricsview.rst

raw
1 The Metrics View
2 ================
3
4 .. image:: /images/MetricsView.png
5
6 The metrics view allows you to examine how glyphs look together and to alter the
7 spacing between them. You may apply various OpenType features to those glyphs
8 and see how they are altered.
9
10 If the metrics view is created from the font view then any selected glyphs
11 (well, the first 15 or so) will be displayed in the view in the order they were
12 selected. If it is created from an outline or bitmap glyph view then only that
13 glyph is displayed. If it is created from a bitmap glyph view (or from the font
14 view when that view is displaying a bitmap font) then the metrics view will
15 display bitmaps, but will not allow you to edit the bitmaps metrics (you must do
16 your metrics editing in a view displaying outlines).
17
18 Underneath the menu bar is a series of fields. The first shows the current
19 script and language combination being used to determine what lookups to apply
20 within the selected features, the next is a text field which allows you to enter
21 additional unicode characters to be displayed, and finally there is a pulldown
22 list of lookup subtables, this will be used if you create a kerning pair (the
23 kerning pair will become part of that subtable). Underneath that is a list
24 showing all features defined in the font. You may select which ones you want to
25 be active in this display. (Note the features are listed in alphabetic order --
26 this is not the order in which the lookups will be executed (or not usually the
27 order)).
28
29 If you wish to enter characters you cannot type:
30
31 #. Select the character (or glyph) in the fontview and then drag and drop it into
32 the metrics view at the appropriate place
33 #. Use the View menu to change or insert a character or glyph
34 (:menuselection:`View --> Insert Glyph After`)
35 #. Select the characters individually and in order in the font view before you open
36 the metrics view, when you do open it the characters will appear in the order
37 you selected them
38 #. FontForge has its own funky :ref:`input method <metricsview.Entering>`
39
40 The mid portion of the view is taken up with the displayed glyphs. For outline
41 glyphs these are sized so that the em-height of the font just fits in this
42 region. There are grey lines between the glyphs marking the origin of the glyph
43 on the right and the width of the glyph on the left. The baseline is also drawn
44 in grey.
45
46 A metrics view may be in one of three modes
47 (:menuselection:`Metrics --> Window Type`)
48
49 * Kerning only -- you may adjust the kerning between any pairs of glyphs shown,
50 but you may not set any advance widths
51 * Advance Width only -- you may adjust the advance width of any glyph shown, but
52 you may not set kerning
53 * Both -- see below
54
55 One of the glyphs is active. That glyph has a green line on its left (at its
56 origin) and a blue line on its right (its width). You may change the width by
57 dragging this line. You may change the left side bearing (lbearing) of the glyph
58 by clicking on the glyph and dragging it left or right. You may change the
59 kerning between this glyph and the one to its left by dragging the green line
60 around. (If you wish to create a :ref:`Device Table <metricsview.DeviceTable>`
61 for small pixel sizes you must use the
62 :ref:`Kern Pair Closeup dialog <metricsview.kernpair>`)
63
64 Shapers
65 -------
66
67 The shapers are responsible for the correct layout of the glyphs in the view and
68 for the application of OpenType features. Currently, FontForge supports two
69 shapers: the legacy built-in shaper and HarfBuzz. You can select the desired
70 shaper from the :menuselection:`View` menu.
71
72 .. _editmenu.HarfBuzz:
73
74 .. object:: HarfBuzz
75
76 The `HarfBuzz <https://harfbuzz.github.io/>`_ shaper is the standard text shaping
77 engine for many platforms, including most Linux systems, Android, and others. It
78 renders your font in exactly the same manner as it would appear on these platforms.
79
80 HarfBuzz relies on a cached copy of a font, which may not reflect changes to
81 OpenType lookups made while the Metrics View window is open. To ensure that the
82 shaper displays the most up-to-date version of the font, invoke
83 :menuselection:`View --> Refresh Shaper`.
84
85 .. _editmenu.BuiltIn:
86
87 .. object:: Built-in shaper
88
89 The built-in legacy shaper always uses the current state of the font and does not
90 require refreshing. However, it has limited support for OpenType features and may
91 fail to display complex scripts, such as Arabic or Indic, correctly.
92
93 Kerning
94 -------
95
96 .. flex-grid::
97 :class: flex-center
98
99 * :flex-widths: 0 0
100
101 - .. image:: /images/To-unkerned.png
102 - .. image:: /images/To-kerned.png
103
104 The active glyph may be changed by clicking on any of the glyphs.
105
106 Underneath the display area are a set of text fields. You may type in new
107 numbers for any of these fields to change the corresponding metrics of the
108 glyph. If you wish to type a negative number, it is best to type the positive
109 portion first, then an ASCII minus (`-`). So, to type, -300, type 300, then
110 press -.
111
112 The up and down arrow keys will increase and decrease the field's value by a
113 single unit. Holding Shift-up or -down will accelerate this by 10 and
114 Ctrl-Shift-up or -down by 5. Holding Alt-up, -down, -left or -right will move
115 the cursor to the field above, below, left or right.
116
117 Sometimes it is handy to be able to load a list of words into the metrics view
118 (so that you don't have to type them one by one). The text entry field has a
119 pull down list, and at the bottom of this list is an entry to load a word list
120 from a file. Once you select this, and your file, the pulldown list will ill up
121 with choices. You may use the up/down arrow keys to move through the word list.
122
123 If the first glyph to be displayed is in Hebrew or Arabic (or any other right to
124 left language) then the entire display area will be shown right to left
125
126 .. note::
127
128 There is a very complicated algorithm given in the Unicode spec for
129 displaying mixed right to left and left to right passages. This is not followed
130 here. The direction determination is done by the first glyph alone.
131
132 .. image:: /images/HebrewMetrics.png
133
134 .. image:: /images/VerticalMetrics.png
135 :align: left
136
137 You can make the window display vertical metrics and kerning by
138 :menuselection:`View --> Vertical`. (This is only available if your font has
139 vertical metrics enabled,
140 :menuselection:`Element --> Font Info --> General --> Has Vertical Metrics`). In
141 this mode you can change vertical width, vertical kerning, etc.
142
143 If you double click on one of the displayed glyphs then FontForge will bring up
144 a outline glyph view to allow you to edit that glyph.
145
146 .. image:: /images/MetricsView-features.png
147
148 In the example at left, the input text is an "f" followed by an "i", and as the
149 'liga' feature is turned on, this becomes the "fi" ligature. Then an "a"
150 followed by a "b", but as the 'smcp' (small caps) feature is on these become
151 small-caps letters rather than lower case. Finally "1", "/" and "2" were
152 entered, and as the 'frac' (diagonal fractions) feature is turned on these three
153 input glyphs become the onehalf glyph on output.
154
155 .. note::
156
157 This window is not a full blown layout engine. All the glyphs will be
158 treated as if they were in the same script, and all features will be applied to
159 all glyphs. Baseline alignment will not be done.
160
161
162 .. _metricsview.Entering:
163
164 Entering non-ASCII characters
165 -----------------------------
166
167 Most of us are stuck with keyboards that only have ASCII characters on them. Or
168 at best some sub-set of ISO 8859-1 characters. How can the full range of unicode
169 characters be entered?
170
171 X supplies a sophisticated mechanism for entering characters via stand-alone
172 :doc:`input method servers </ui/misc/xim>`. FontForge supports this to some extent now.
173
174 Aside from that, many versions of X supply a "Compose Character" key, or
175 something equivalent. The X software will map a sequence of keystrokes to one
176 character in whatever the native encoding may be.
177
178 My keyboard doesn't have such a key, and my X doesn't do this. But I have
179 implemented something along those lines for those of us with less expensive
180 keyboards. If you are in a mode where text entry is possible then press the F12
181 key and follow it by a series of keystrokes. Accented characters may be built
182 using the following:
183
184 .. flex-grid::
185 * - ````` grave accent
186 - ``0`` ring
187 - ``"`` double grave (or tonos)
188 * - ``'`` acute accent
189 - ``/`` slash
190 - ``.`` dot above
191 * - ``:`` diaeresis (umlaut)
192 - ``7`` breve
193 - ``,`` dot below
194 * - ``^`` circumflex
195 - ``6`` caron
196 - ``5`` cedilla
197 * - ``~`` tilde
198 - ``_`` macron
199 - ``4`` ogonec
200
201 So  may be built by ``[F12] ^ A``, and A with diaeresis and macron may be built
202 with ``[F12] : _ A``.
203
204 Greek letters may also be created. If you start with ``[F12] @`` and follow
205 with:
206
207 .. flex-grid::
208
209 * - ``A`` Alpha
210 - ``B`` Beta
211 - ``C`` Chi
212 - ``D`` Delta
213 * - ``E`` Epsilon
214 - ``F`` Phi
215 - ``G`` Gamma
216 - ``H`` Eta
217 * - ``I`` Iota
218 - ``J`` :small:`(technical)` Theta
219 - ``K`` Kappa
220 - ``L`` Lamda
221 * - ``M`` Mu
222 - ``N`` Nu
223 - ``O`` Omicron
224 - ``P`` Pi
225 * - ``Q`` Theta
226 - ``R`` Rho
227 - ``S`` Sigma
228 - ``T`` Tau
229 * - ``U`` Upsilon
230 - ``V`` final sigma
231 - ``W`` Omega
232 - ``X`` Xi
233 * - ``Y`` Psi
234 - ``Z`` Zeta
235
236 This is the mapping used by the Symbol font. (Lower case letters are created
237 similarly so ``[F12] @ a`` yields a lower case alpha). Accented greek letters
238 may also be built up, ``[F12] @ " A`` yields Alpha tonos.
239
240 Finally the following special characters may be built:
241
242 .. flex-grid::
243 :class: nowrap
244
245 * - [F12] <space>
246 - <no break space>
247 - [F12] *
248 - °
249 * - [F12] @ *
250 - <bullet>
251 - [F12] @ <space>
252 - <em space>
253 * - [F12] #
254 - £
255 - [F12] @ #
256 - ¥
257 * - [F12] $
258 - <euro>
259 - [F12] @ $
260 - ¢
261 * - [F12] !
262 - ¡
263 - [F12] +
264 - ±
265 * - [F12] -
266 - <soft-hyphen>
267 - [F12] @ -
268 - <en dash>
269 * - [F12] @ .
270 - ·
271 - [F12] 7 2
272 - ½
273 * - [F12] ;
274 - . . .
275 - [F12] <
276 - <less or equal>
277 * - [F12] >
278 - <greater or equal>
279 - [F12] @ >
280 - <triangle bullet>
281 * - [F12] =
282 - <quote dash>
283 - [F12] ?
284 - ¿
285 * - [F12] A
286 - Å
287 - [F12] C
288 - Ç
289 * - [F12] H
290 - <right index>
291 - [F12] O
292 - <OE lig>
293 * - [F12] P
294 - §
295 - [F12] [
296 - <single right quote>
297 * - [F12] ]
298 - <single right quote>
299 - [F12] \
300 - «
301 * - [F12] @ \
302 - <single guillemot>
303 - [F12] a
304 - å
305 * - [F12] c
306 - ç
307 - [F12] f
308 - <female sign>
309 * - [F12] g
310 - ©
311 - [F12] h
312 - <left index>
313 * - [F12] m
314 - <male sign>
315 - [F12] o
316 - <oe lig>
317 * - [F12] p
318 - ¶
319 - [F12] r
320 - ®
321 * - [F12] s
322 - ß
323 - [F12] t
324 - TM
325 * - [F12] z
326 - <long s>
327 - [F12] {
328 - <left dbl quote>
329 * - [F12] }
330 - <right dbl quote>
331 - [F12] |
332 - »
333 * - [F12] @ |
334 - <right single guillemot>
335 -
336 -
337
338 This still misses most unicode characters. But pressing [F12] twice will bring
339 up a dialog which will allow you to select any character in unicode.
340
341 If you type [F12] by mistake then an Escape will get you out of accent mode.
342
343
344 .. _metricsview.kernclass:
345
346 Kerning By Class
347 ----------------
348
349 Often it is a good idea to create classes of glyphs which kern alike. For
350 example A, À, Á, Â, Â, Ã and Ä probably all kern alike (but note that o and ô
351 probably kern quite differently after a T), and rather than create separate
352 kerning pairs for each of the "A"s above, they could all be placed in a class of
353 glyphs which kern alike.
354
355 The :doc:`Element->Font Info->Lookups </ui/dialogs/lookups>` provides an interface to this.
356
357 .. image:: /images/kerningformat.png
358 :align: right
359
360 It brings up a dialog showing all the GPOS lookups (of which kerning is one) and
361 their subtables. Each set of kerning classes lives in its own subtable. When you
362 create a kerning subtable you will be asked whether you want a set of individual
363 kerning pairs or a matrix based on kerning classes.
364
365 If you choose the latter then you may have fontforge try to guess a good set of
366 classes for you (it will look at the glyphs selected and divide them into
367 classes). The ``Intra Class Distance`` gives you some control over how picky
368 fontforge will be about what goes into a class. (This can be thought of as being
369 in em-units and being, roughly, the average error in how two different glyphs
370 interact with other glyphs). A value of 1 is very picky and almost all classes
371 will have one member. A value of 20 (in a 1000em font) is fairly loose.
372
373 The ``Default Separation`` and ``Min Kern`` fields are used in AutoKerning. The
374 goal of kerning to to make the optical separation between all glyphs to be
375 constant, and the ``Default Separation`` field specifies that desired value. The
376 ``Min Kern`` value is simply to prevent the dialog from filling with useless
377 junk. If AutoKerning suggests that two glyphs should be kerned by 1 em unit then
378 this won't make any difference to the human eye and there is no point in
379 including it. So if the kerning value (in absolute value) suggested by AutoKern
380 is less than ``Min Kern`` then fontforge will ignore that value. Selecting
381 ``[] Touching`` makes AutoKerning work in a slightly different way, instead of
382 trying to make the optical distance be the desired value this attempts to make
383 the minimum separation be the desired value (This is rarely useful, but
384 occasionally people want to set text where the letters actually touch one
385 another). The ``[] Only kern glyphs closer`` flag means that FontForge will only
386 generate negative kerning offsets, that is, offsets which will move glyphs
387 closer together.
388
389 .. image:: /images/kerningclass.png
390
391 Each kerning class belongs to a :doc:`lookup subtable </ui/dialogs/lookups>` and the
392 subtable name is displayed at the top of the dialog.
393
394 But the more interesting stuff follows this. A kerning by class actually
395 consists of two sets of classes -- one set for the first glyph of the pair and
396 one for the second glyph of the pair. A glyph class consists of a space
397 separated list of glyph names (For most glyphs you may also enter the unicode
398 character itself, and fontforge will convert that to a glyph name).
399
400 To edit a class, simply type in it (at the very bottom of the class list is an
401 entry called <New>, clicking here will create a new class). Pressing the little
402 rectangle at the right of the class will allow you to define your class as a
403 selection in a font view widget. You may delete a class by selecting it
404 (clicking in it) and pressing the [Delete] button.
405
406 The kerning classes can be fairly complex. You can search for a glyph by typing
407 its name in the "Select Glyph" field. This will highlight the class containing
408 that glyph.
409
410 Class 0 is usually magic. You almost never set it, it contains any glyphs not
411 mentioned elsewhere. In OpenType, class 0 of the first character can be set and
412 behaves normally.
413
414 Underneath the classes is a display of kerning values. The possible first glyph
415 classes are listed vertically, the possible second glyph classes are listed
416 horizontally. When you select a class (in one of the class lists above) the
417 display of kerning values will scroll to display that class. If you move the
418 mouse into the display and let it rest, a popup window will appear showing the
419 glyphs that make up the classes which intersect at that point. If you click on a
420 kerning value in the display, the dlg displays a visual representation of that
421 amount of kerning.
422
423 The kerning dialog displays a representative glyph from each class and allows
424 you to adjust the kerning between them (and all other class members of each
425 class). You can select which glyphs to display in the pulldown menus. You can
426 enter a new kerning offset by typing in a value, or you can click on the second
427 glyph of the kern pair and drag it around.
428
429 .. _metricsview.DeviceTable:
430
431 You can also create something called a "Device Table", a name which is not very
432 informative. When a font is rasterized at small pixel sizes rounding errors
433 become important, and this is particularly true of kerning, there are three
434 things that get rounded: The locations of the outlines (to fit them to a pixel
435 grid), the advance widths of the glyphs, and the kerning value itself. The
436 result is that something which looks perfectly kerned at 150pixels may be either
437 too close or too far apart at 12pixels
438
439 .. flex-grid::
440 :class: flex-bottom
441
442 * - .. figure:: /images/kern-We-150.png
443
444 Kerning at 150 pixels
445 - .. figure:: /images/kern-We-12.png
446
447 Kerning at 12 pixels (magnified by 2)
448
449 You could adjust the kerning value slightly until it looked right at 12pixels,
450 of course, but that might break it at 14 pixels. So OpenType has the concept of
451 a Device Table which allows you to add small corrections at particular point
452 sizes. Simply set the Display Size to a small, but common, value (say 10-24) and
453 examine the kerning. If the results are ugly then type a value into the "Device
454 Table Correction" field, and this will change the spacing by that many pixels at
455 the given display size (and no other). In the case above a correction of 1 might
456 be appropriate for the 12px display.
457
458 Because small pixel sizes can be hard to examine, you can change the
459 magnification (rasterized at the same size, but each pixel made twice as big).
460
461 .. _metricsview.kernpair:
462
463 :ref:`Device Tables <metricsview.DeviceTable>` may also be created in a number
464 of other cases. The example above was for a kerning class. Kerning pairs may
465 also have tables attached to them with the
466 :menuselection:`Metrics --> Kern Pair Closeup` dialog, which looks similar to
467 the Kerning Class dialog above.
468
469 .. image:: /images/kernpairclose.png