Drawing good paths
There are two kinds of paths. Good ones and bad ones. Here’s how to spot the bad ones and how to correct or avoid the most frequent problems. You’ll be so glad you’ve read this tutorial!
Badly drawn outlines can cause headaches. Your letters may look mangled or not appear at all. You can avoid these difficulties if you keep a few basic rules in mind.
The magic triangle
This is important: every curve segment should fit nicely in a triangle.
‘What’s a segment?’ I hear you ask. Simple, it’s everything between two adjacent on-curve points a.k.a. nodes. There are two types of segments, straight lines and curves. Straight lines only consist of those two nodes. Curve segments additionally sport two off-curve points a.k.a. Bézier control points (BCPs) or ‘handles’.
It’s important to note that the magic triangle is described by the two nodes encompassing the segment and the point where the elongations of the handles intersect. This means that the handles must never extend outside the triangle. If they do, you may want to reconsider the position of your nodes. So these two things should not happen: a handle crossing the other handle, and a handle crossing the elongation of the other handle. This may produce unnecessary inflections, cusp curves or even self-intersections, all of which may put a rasterizer into trouble.
This may come as a surprise to you if you have prior experience in vector applications like Illustrator. First, the handles do not belong to the nodes, but to the segment. Secondly, a curve segment always has two BCPs, never just one. Illustrator seems to let you draw curve segments with only one BCP. But actually, what Illustrator really does is hide the second BCP in one of the surrounding nodes. This is pretty bad because in font vectors, no two points should share the same coordinates. Plus, you have more control over the path if you make good use of both BCPs.
If one of the BCPs appears to be missing, it’s hiding in the node next to it. The easiest way to fix this is to select a point in the vicinity, be it a handle or a node, and then tab to the hiding handle. Use Shift-tab to go into the opposite direction. A light-grey highlight indicates that the handle is selected. Now, use your arrow keys to drag the handle out of the node. If you add the option key, your handle will keep its direction. Hold down Shift for increments of 10:
At first sight, the magic triangle implies that a curve segment should only have a single orientation, i.e. not inflect, not switch from clockwise to counterclockwise. There are, however, many exceptions.
Very often, you are better off without an inflection when drawing glyphs like an
S or a
tilde, especially if you are drawing for interpolation. If your design intention allows it, and both handles of the segment are orthogonal (i.e., vertical or horizontal), there is no technical need to add an inflection. And fewer points mean less trouble. So, wherever possible, keep it like in the s on the left side:
However, if you cannot get your s curve to flow the way you want it without an inflection point, add it by choosing the Draw tool (P), holding down the Shift key and clicking approximately in the middle of the segment. Glyphs will add an on-curve point at the nearest inflection, like in the s on the right side.
Do try to avoid inflections though, because they may create a problem in interpolation. The diagonal triplet of on-curve point and the surrounding two handles can cause a so-called ‘kink’ in interpolated steps between masters. Read more about it in the Multiple Masters tutorial on how to keep your outlines compatible, there is a whole section dedicated to kinks.
Special case: When you draw cupped serifs in a font that is supposed to be optimised for the screen, you even need curve segments without inflections:
Make sure Points A and C are on the same height, all the BCPs are horizontal (or between the heights of B and A/C, i.e. they do not go beyond the area spanned by these two heights), and the distance between the base and B is less than 20 units. In File > Font Info > Font, add a
blueShiftcustom parameter with the depth of your cups plus one as value. Then the PostScript autohinter can apply a so-called flex hint, which suppresses display of the cups at very low resolutions. And most importantly, make sure B sits on the baseline. Yes, you heard right, the B point! And the cup parts with the A and C need to immerse completely in the baseline alignment zone. Read more about PostScript hinting.
Path orientation and order
Wrong path directions can mess up counters and make proper hinting impossible. Paths need to be oriented counter-clockwise, counters need to be oriented clockwise. You can control path directions by selecting paths, right-clicking and picking Reverse Selected Contours from the context menu. Don’t wanna keep that in mind? No problem. Glyphs can do that for you. Just pick Paths > Correct Path Direction (Cmd-Shift-R) and you’re done. This command also works on multiple glyphs, or even the whole font.
By the way, Paths > Correct Path Direction (Cmd-Shift-R) also re-orders your paths and resets the starting point in each closed path.
Working with multiple masters? Hold down the Option key, and the menu command will change to Paths > Correct Path Direction for All Masters (Cmd-Opt-Shift-R), which, as the name implies, will do its magic on all layers of the selected glyph(s) simultaneously. Comes in handy when you want to quickly make a glyph with multiple masters compatible again. You can quickly cure most interpolation problems this way. Read more about keeping outlines compatible.
A path in an exported font must not intersect itself. You can fix a self-intersection by selecting the contour in question and choosing Filter > Remove Overlap (Cmd-Shift-O). But then again, in your Glyphs file, you may want to keep an intersection for easier editing and better interpolation. In this case, make sure you activate the Remove Overlap option when you export your font (Cmd-E).
Hint: This does not apply to Variable Fonts.
You can even add overlaps with the Open Corner and Reconnect Nodes commands from your context menu:
There is one problem with keeping overlaps though: double overlaps. That is, if you have another overlap inside an overlap. They may show as tiny white gaps inside your shapes. This can happen when, inside the overlap, a curve segment connects to a straight line, and the curve bends a little too much to the wrong side:
How can we find these spots? Well, a Python script could have a look at what your glyphs would look like after overlap removal, and see if there is some outline debris left over somewhere. In the mekkablue script repository, there is a script called Paths > New Tab with Small Paths, which opens a new Edit tab with all the glyphs it can find that contain such a tiny path:
Superfluous points and wrong node types
Not really a biggie, but it can improve the rendering performance of your font: Paths > Tidy Up Paths (Cmd-Opt-Shift-T) will remove superfluous nodes and superfluous BCPs. In other words, it will remove all points not necessary for displaying the shape at hand, e.g., handles on a completely straight segment, and so on. This command will also fix the type of your nodes, thus changing a blue corner point into a green curve point (or vice versa) where appropriate. And it will fix two consecutive points sharing the exact same coordinates, also known as a ‘zero-length segment’, indicated by a red circle.
While we’re at it, a lot of stuff is much easier if you insert nodes at the x and y extremes of your paths, i.e., the spots where your paths have completely horizontal or vertical tangents. Very often, this allows you to get rid of the other points while achieving simpler paths, fewer points, smaller file sizes.
Also, if you want to make use of hinting, you need extremum points for hints to attach to the respective stem. No extremums, no stem hint. Read more about hinting.
You can either choose Paths > Add Extremes to add extrema to the selected outlines, selected glyphs or even the whole font. Or, if you want to have more control, just take your Pen tool (P) and Shift-click on the path. Glyphs will look for the nearest extremum or inflection point of the curve and insert a node there.
After you inserted extremum points, you can often get rid of intermediate points without compromising on the shape:
You do that by selecting one of the green diagonal points, and pressing the Delete key. If you delete one node at a time, Glyphs will do its best to reconstruct the shape with a single segment. Your mileage may vary.
Pro tip: You may want to avoid an extremum point if it would create a so-called shallow curve otherwise, i.e., a curve segment that is only a handful of units deep. Why would you want to avoid shallow curves? Because point coordinates usually do not have decimals, and the curve segment will mess up the shape no matter how smartly you are trying to place your on- and off-curve points. A good example is the finial at the bottom right of a lowercase a:
Open and closed
Did a whole path go missing in the final font? Perhaps it was open. Open paths are ignored at export time. So, all paths should be closed.
To close a path, just drag one of the open ends onto the other one with your Edit tool (V). Or switch to the Pen tool (P) and subsequently click on both end points to add a closing segment. Or, select open paths, right click to open the context menu and choose Close Open Paths.
Vectors out of bounds
Got super-weird left or right sidebearing values? You probably have some object way off the visible part of your glyph. Here’s how to get rid of it:
- Make sure the right glyph is active, i.e. the cursor is placed before it. Hint: pay attention to the LSB and RSB values in the grey info box (Cmd-Shift-I), and see if you can spot a ridiculously large, probably negative, number there.
- Switch to the Edit tool by clicking on the arrow symbol in the toolbar.
- Choose Edit > Select All (Cmd-A). All paths in the glyph are selected now.
- While simultaneously holding down your Shift key, drag a rectangle selection across the parts you want to keep. This will deselect them. Now, only the out-of-bounds debris remains selected.
- Hit the Delete key.
Useful plug-ins and scripts
Via Window > Plugin Manager, you can put your hands on a couple of analytic View menu plug-ins that help you identify potentially problematic spots in your outlines. Good plug-ins in that respect are Show Angled Handles, Jens Kutílek’s Red Arrow, Simon Cozens’ Heatmap, and perhaps Show Tops and Bottoms can also be helpful.
In the Plugin Manager, you will also find Filter menu extensions that help fix problems. Fix Zero Handles and Delete Small Paths are two examples. But think of what you need for your design, and see if there is a plug-in for that.
Also, take a look at the script repositories listed on the Extend page, many of which contain scripts that help you fix problems in your fonts, like the one mentioned above.
In the mekkablue scripts, you will find a few useful scripts in the Paths submenu. One important script is Path Problem Finder, which helps find problematic spots in your outlines throughout your font:
While we are at it, Green Blue Manager (for aligning handles) and Find Near Vertical Misses (for finding all nodes that just miss a vertical metrics line by that much) have proven useful in the past.
Now is a good time to go through your glyphs and optimize the vectors. Trust me, it will save you some hassle later.
Update 2018-08-04: revised text and adapted text to match current app versions. Added double overlaps, reconnecting and corner opening, as well as script and plug-in tips.
Update 2018-08-19: more precise description of Tidy up Paths in Superfluous Points and Wrong Node Types. More clarification and new screenshot for the cupped serif example. Cleaned up wording for describing inflections.
Update 2020-08-18: changed section about inflection, now suggesting to avoid them wherever possible; added paragraph about useful mekkablue scripts; added sample image for avoiding shallow curves, and note about extremums for hinting.
Update 2022-07-22: updated title, minor formatting.