Debian Codegraph @

doc/sphinx/ui/dialogs/problems.rst

raw
1 Finding common font problems automagically
2 ==========================================
3
4 Nobody is perfect.
5
6 Well, I'm not.
7
8 When you draw your glyphs you are likely to make some minor errors, like having
9 stems with slightly different widths in different glyphs, or having lines which
10 aren't quite vertical or...
11
12 FontForge's Find Problems command can help track down some common errors. In
13 some cases it will be able to fix things for you, but it won't do so without
14 your permission (who knows, some of the so-called "problems" might actually be
15 what you wanted), but it will point things out to you that you should look at.
16
17 This command works either in the font view, the outline view or the metrics
18 view. In the font view it will examine all selected glyphs for errors, and if it
19 finds anything open a window looking at the glyph and post a (non-modal) dialog
20 saying what the error is. You may then correct the problem and press the [Next]
21 button in the dialog when you are done, or you may stop the command with the
22 [Stop] button. Some errors FontForge will be able to fix automagically, and if
23 so there will be a [Fix] button in this dlg.
24
25 .. note::
26
27 You should not assume that all problems are in fact errors. Some "problems"
28 may be intended peculiarities of the font design. Don't just blindly press
29 the [Fix] button
30
31 Behavior in the outline and metrics views is similar, except that only one glyph
32 is searched for problems.
33
34 FontForge will be able to check for more problems if you:
35
36 * AutoHint the font first
37 * Bring up the :ref:`Element->Font Info->Private <fontinfo.Private>` sub-dialog,
38 add entries for BlueValues, StdHW and StdVW and press the [Guess] button for
39 each of them
40
41 Note: Some of these problems are geared specifically to the problems of
42 Latin/Greek/Cyrillic fonts. I would be happy to hear of ways to extend these to
43 other script systems, or of problems that are specific to other script systems
44 (`[email protected] <mailto:[email protected]>`__
45 this is a public mailing list).
46
47 .. image:: /images/findprobs.png
48 :align: right
49
50 FontForge can detect the following potential problems:
51
52
53 Non-Integral Coordinates
54 ------------------------
55
56 In TrueType fonts all coordinates must be on integral coordinates. When
57 FontForge generates your font it will round any non-integral coordinates --
58 sometimes this is fine, but it can also introduce small uglinesses into your
59 font that you won't be aware of in fontforge. (Implied points are allowed to
60 have half-integral values (2.5 is ok, 2.25 is not)).
61
62 PostScript fonts can have non-integral coordinates, but it will make the font
63 bulkier, so even there it may be better to use integer values.
64
65
66 X near [val]
67 ------------
68
69 Often there will be a set of features which should be consistent across the
70 entire file. For example the left side-bearing of the glyphs "BDEFHIKLMNPR"
71 should perhaps all be the same. This will let you enter in the desired
72 side-bearing value, and then FontForge will find all glyphs with points that are
73 near, but not exactly on the desired value. Where "near" is defined at the
74 bottom of the dialog (in this case, everything within 3 em-units -- in either
75 direction -- will be near). If it finds an errant point, FontForge will select
76 it, stop and let you fix it.
77
78
79 Y near [val]
80 ------------
81
82 This is the exact counter-part of the above command except for being in the Y
83 direction. Often times this check is more efficiently done by the following
84 check...
85
86
87 Y near standard heights
88 -----------------------
89
90 In Latin, Greek and Cyrillic alphabets there are certain standard heights that
91 FontForge expects to find: the baseline, the height of lower case letters, the
92 height of capital letters, the height of lower case letters with ascenders
93 (often the same as, or very close to, the capital height), and the depth of
94 lower case letters with descenders. For this command FontForge defines these
95 heights to be 0, the height of "x", the height of "I", the height of "l" and the
96 depth of "p" (If you are working on a Greek or Cyrillic font and don't include
97 the Latin alphabet, FontForge will pick similar letters from your alphabet).
98 Then FontForge will search for any points which are "near", but not on, these
99 heights. Again where "near" is defined at the bottom of the dialog. If it finds
100 such a point, FontForge will select it, stop and let you fix things.
101
102
103 Control points near horizontal/vertical/italic
104 ----------------------------------------------
105
106 This is similar to the :doc:`Edges near Horizontal option <problems>` below, but
107 where that only looks for straight lines, this one looks for curved lines that
108 begin or end near horizontal (vertical, italic angle).
109
110
111 Control points beyond spline
112 ----------------------------
113
114 .. image:: /images/cpodd.png
115 :align: right
116
117 Consider the glyph at right, the selected point has a control point that is far
118 outside of what is reasonable and is probably not where it should be. This will
119 check for such points.
120
121 Technically it will search for all control points, which when projected onto the
122 line between the two end points of the spline lie outside of the segment between
123 the two.
124
125
126 Irrelevant control points
127 -------------------------
128
129 This will look for control points which are so close to the point they modify
130 that they are unlikely to affect the shape of the curve. A control point is
131 deemed too close if the distance between it and its modified point is less than
132 the "Irrelevant Factor" times the distance between the two end points of the
133 spline controlled by this control point.
134
135
136 Points Too Close
137 ----------------
138
139 Some of FontForge's own commands get confused by tiny splines, on the order of
140 one unit or less, and anyway if you have several points very close together it
141 is unlikely that they will make a detectable difference when the font is
142 printed. Probably you should remove one of them... If FontForge detects two
143 points on the same path which it deems to be too close it will select both, stop
144 and let you fix things.
145
146
147 Points Too Far Apart
148 --------------------
149
150 Most font formats use 16 bit integers to describe the distance from one point
151 (or control point) to the next. This means that each point must be within 32767
152 em-units of the next point. If it is further away then it cannot be represented
153 in a generated font. If FontForge detects two points too far from each other it
154 will select both (a special case -- the first point in a glyph must be within
155 32767 of the origin, if it is further, only the first point will be selected),
156 stop and let you fix things.
157
158
159 Open Paths
160 ----------
161
162 .. image:: /images/findprobs-paths.png
163 :align: right
164
165 All of your paths should be closed, that is they shouldn't have any end points
166 the way a line segment does, but should connect back to their beginning. This is
167 often caused by being a little careless with the last point on a path, and
168 instead of joining it to the first, you just put it near the first. If FontForge
169 detects any open paths it will select the entire path, and stop to let you fix
170 things up.
171
172
173 .. _problems.Intersecting:
174
175 Intersecting Paths
176 ------------------
177
178 Both PostScript and TrueType discourage you from having intersecting paths in a
179 font.
180
181
182 Edges near horizontal/vertical/italic
183 -------------------------------------
184
185 It is very easy to create a line which is almost, but not quite, vertical. This
186 will check for that situation. And for horizontal, and (if your font has an
187 italic angle) for lines which are almost but not quite parallel to the italic
188 angle. If it finds one of these, FontForge will select the two end points, stop
189 and let you fix things.
190
191 For horizontal lines it will tell you the y coordinates of the two end-points,
192 for vertical lines it will show you the x coordinates.
193
194
195 Path Direction
196 --------------
197
198 Both PostScript and TrueType require that paths be traced in a clockwise
199 fashion. This sometimes doesn't matter, but many rasterizers do a better job if
200 this rule is obeyed. This command will detect whether this constraint is
201 violated.
202
203 **FontForge cannot determine path direction properly if there are
204 self-intersecting paths.** :ref:`Do that test first. <problems.Intersecting>`
205
206 Currently the command will report the same error several times if you do not fix
207 the problem. That's sort of a bug, but I don't see an easy way around it yet.
208
209
210 Check Missing Extrema
211 ---------------------
212
213 Both PostScript and TrueType would like you to have points at the maxima and
214 minima (the extrema) of a path. This checks that you do.
215
216
217 More Points Than
218 ----------------
219
220 Appendix B of the PostScript Language Reference manual says that an interpreter
221 is only required to support paths with 1500 points on them. Most interpreters
222 actually have a much higher limit, so you may change the limit to suit your
223 desires. I believe that control points are included in the count. Note that when
224 checking a quadratic font (ie. a truetype font) there will be at most one
225 control point between any two end points, but when that font gets converted to
226 PostScript there will be two. FontForge currently counts this as one point).
227 TrueType has no such limit.
228
229
230 Flipped References
231 ------------------
232
233 .. image:: /images/findprobs-refs.png
234 :align: right
235
236 As mentioned above both PostScript and TrueType like clockwise paths. If you
237 have a flipped reference then either the reference or the original glyph will be
238 drawn with a counter-clockwise path. To fix it you should
239 :menuselection:`Edit --> Unlink` the reference and
240 :menuselection:`Element --> Correct Direction`
241
242
243 Refs with bad ttf transformation matrices
244 -----------------------------------------
245
246 The TrueType glyph format allows almost arbetrary transformations to be applied
247 to a reference. The one restriction is that all terms of the transformation
248 matrix (except for the translation terms) must have a value between -2 and 2.
249
250 If you have a reference with an unexpressable transformation matrix, fontforge
251 will expand the reference inline, so all the contours will be present they just
252 won't be in a reference.
253
254 TrueType also requires that all references be translated by integral values. If
255 you have a reference with a non-integral translation vector, FontForge will
256 round it to an integer when it generates the font (this does not cause the
257 reference to be unlinked).
258
259
260 Mixed contours and references
261 -----------------------------
262
263 In TrueType glyphs may be composed either of all references or all contours (a
264 reference with an unexpressable transformation matrix counts as a contour).
265
266 If you have a mixed glyph, fontforge will expand all references inline.
267
268
269 Refs with bad ps transformation matrices
270 ----------------------------------------
271
272 The Type1 font format only allows references to be translated (so no rotation or
273 scaling is permitted). Technically the Type2 format does not allow any
274 references at all, but they can be simulated by using subroutines, which also
275 cannot be rotated or scaled.
276
277 If you have a reference with an unexpressable transformation matrix, fontforge
278 will expand the reference inline, so all the contours will be present they just
279 won't be in a reference.
280
281
282 Refs Deeper Than
283 ----------------
284
285 Appendix B of the the
286 `Type2 <http://adobe-type-tools.github.io/font-tech-notes/pdfs/5177.Type2.pdf>`__ spec
287 says that an interpreter is only required to support subroutine nesting up to 10
288 levels. FontForge uses subroutine calls to handle referenced glyphs and
289 sometimes also to handle hinting. Hinting will take up a maximum of 1 level of
290 subroutine calls leaving 9 available for references. TrueType has no such limit.
291
292
293 Refs with out of date point matching
294 ------------------------------------
295
296 TrueType allows references to be positioned by aligning points in different
297 references. If the point count in one of the glyphs being referred changes then
298 you will need to fix up these references to match the new point count.
299
300
301 Hints controlling no points
302 ---------------------------
303
304 .. figure:: /images/findprobs-hint.png
305
306 This is a bit esoteric, and is present to provide a work-around for (what I
307 think is) a bug in ghostview. Consider the following glyph
308
309 .. image:: /images/phi-nohints-outline.png
310
311 .. image:: /images/phi-nohints-filled.png
312
313 .. image:: /images/phi-hints-outline.png
314
315 .. image:: /images/phi-hints-filled.png
316
317 The first two images show the glyph with no hints, first as seen in FontForge,
318 then as displayed by ghostview. The result looks good. If we add hints to the
319 two curved stems then ghostview gets very confused. I don't know enough about
320 hints to know whether there should be hints there. But this command will detect
321 this problem if in fact it is a problem. If FontForge finds this it will select
322 the offending hint and allow you to fix things (probably the best fix is to add
323 curved points at the extrema of all the curved splines, this is actually
324 recommended by adobe anyway
325 (`T1_Spec.pdf <http://partners.adobe.com/asn/developer/pdfs/tn/T1_Spec.pdf>`__
326 section 4.1)).
327
328
329 Points near hint edges
330 ----------------------
331
332 If you have a glyph like "H" where the main vertical stems are broken by the
333 cross bar, it is all too easy to make the top part of the stem a slightly
334 different width than the bottom. (The hinting process figures out all the
335 stems.) So this command, in essence, is looking for points which are slightly
336 off from a stem. (again, near is defined at the bottom of the dlg). If FontForge
337 finds such a point it selects it, stops, and allows you to fix it up.
338
339
340 Hint width near [val]
341 ---------------------
342
343 Usually one wants many of the glyphs to have a constant stem width, and this
344 command will check that all stems near the indicated value are that value (again
345 near is defined at the bottom of the page). If FontForge finds a bad stem it
346 will select it, stop and allow you to fix things.
347
348
349 Almost stem3 hint
350 -----------------
351
352 PostScript has a special hint operator (hstem3 and vstem3) which is designed to
353 hint the stems of things like "m" where there are three stems of equal width and
354 equally far apart. It is easy for a glyph not to fit the criteria for this
355 operator (which means FontForge won't use it). This will detect cases that are
356 close to right. I found that I needed to adjust the "Near" value to be bigger
357 than the default.
358
359
360 Show exact stem3
361 ----------------
362
363 (this is not a problem, but I found it helpful to be able to distinguish between
364 cases where the "almost stem3" above didn't say anything. It might be because it
365 was a stem3 or it might be really far off from a stem3)
366
367
368 More Hints Than
369 ---------------
370
371 Appendix B of the the
372 `Type2 <http://adobe-type-tools.github.io/font-tech-notes/pdfs/5177.Type2.pdf>`__ spec
373 says that an interpreter is only required to support a total of 96 horizontal
374 and vertical hints.
375
376
377 Overlapped Hints
378 ----------------
379
380 In a PostScript font a glyph should either contain no overlapping hints, or it
381 may have a set of hint masks, and each mask specifies a set of hints which do
382 not overlap.
383
384
385 Missing Bitmaps
386 ---------------
387
388 .. image:: /images/findprobs-random.png
389 :align: right
390
391 Look through the associated bitmap fonts, and find if there is a bitmap font
392 which is missing versions of glyphs present in the outline font. Conversely look
393 for bitmap fonts with glyphs which are not present in the outline font.
394
395
396 Bitmap/Outline Advance Width Mismatch
397 -------------------------------------
398
399 If you have a font with embedded bitmaps, then you would expect that the bitmap
400 advance width would be the same as the outline glyph's advance width (with
401 appropriate scaling and rounding, of course). This checks to ensure that that is
402 true.
403
404
405 Check Multiple Unicode
406 ----------------------
407
408 Check that you do not have two glyphs assigned to the same unicode code point.
409 (The unicode encoding is used to determine which glyph will appear in the
410 truetype/opentype 'cmap' table. If you have two glyphs with the same code point,
411 there is no guarantee which will be used.)
412
413
414 Check Multiple Name
415 -------------------
416
417 Check that you do not have two glyphs with the same name.
418
419
420 Check Unicode/Name mismatch
421 ---------------------------
422
423 Look for glyphs whose name indicates a unicode value different from the one
424 attached to a glyph. So if a glyph were named "A" but had Unicode code point
425 U+0020 (space) FontForge would complain about it.
426
427
428 Glyph BB Above
429 --------------
430
431 .. image:: /images/findprobs-bb.png
432 :align: right
433
434 Find all glyphs whose bounding box extends above the indicated value
435
436
437 Glyph BB Below
438 --------------
439
440 Find all glyphs whose bounding box extends below the indicated value
441
442
443 Glyph BB Right Of
444 -----------------
445
446 Find all glyphs whose bounding box extends to the right of the indicated value
447
448
449 Glyph BB Left Of
450 ----------------
451
452 Find all glyphs whose bounding box extends to the left of the indicated value .
453
454
455 .. _problems.Advance:
456
457 Check Advance
458 -------------
459
460 Check for any glyphs whose advance width is not the specified value (useful for
461 a mono-space font where you want to check that all glyphs have the same width).
462
463
464 Check Vertical Advance
465 ----------------------
466
467 Check for any glyphs whose vertical advance (for fonts with vertical metrics)
468 differs from the specified value.
469
470
471 Missing Glyph Names
472 -------------------
473
474 .. image:: /images/findprobs-att.png
475 :align: right
476
477 It is possible to create a substitution, ligature, etc. which refers to a glyph
478 name that is not in the font. This option will check for the above error.
479
480
481 Missing scripts in features
482 ---------------------------
483
484 In OpenType a lookup will only be applied to a glyph if it is attached to a
485 feature which is active for the glyph's script. So if you had a smallcaps
486 feature which was active for latin, and if this invoked a lookup which had also
487 had smallcaps data for the greek letters, then that lookup would not be invoked
488 for greek even though it could happily make the substitution.
489
490 This item will look for cases like the above, where a lookup applies to a script
491 which is not active for any of its features.
492
493
494 Check substitutions for empty chars
495 -----------------------------------
496
497 Looks through all the 'GSUB' substitution, alternate substitution, multiple
498 substitution and ligature entries that are attached to the current glyph and
499 checks to make sure that all the named components are present in the font (and
500 contain something).
501
502
503 Check for incomplete mark to base subtables
504 -------------------------------------------
505
506 I find it hard to believe that this is really a problem, but I have a second
507 hand report that MicroSoft considers it to be so.
508
509 If a mark to base subtable has several anchor classes, then all base glyphs must
510 define anchor points for all anchor classes.
511
512 --------------------------------------------------------------------------------
513
514 .. image:: /images/findprobs-cid.png
515 :align: right
516
517 If your font is a CID keyed font you will also get:
518
519
520 Check for CIDs defined twice
521 ----------------------------
522
523 Looks through the font set to see if there are any CIDs which have valid glyphs
524 in two or more fonts.
525
526
527 Check for undefined CIDs
528 ------------------------
529
530 Looks for CIDs which have no glyphs defined for them in any font. This is a
531 fairly common occurrence in CID fonts, so use this with caution.
532
533 At the bottom of the dialog are two buttons (``[Clear All]`` and ``[Set All]``
534 which will, respectively, clear and set the check boxes for all tests -- Well,
535 CID tests will not be set by ``[Set All]`` in non cid-keyed fonts).
536
537 There is also a text field which allows you to define the meaning of "Near" as
538 used in various of these tests. The default value is that things are "near" if
539 they are within 3 em-units of the desired value and not equal to that value.