Debian Codegraph @

doc/sphinx/tutorial/editexample.rst

raw
1 Font and glyph creation
2 =======================
3
4 If you wish to follow along with the tutorial,
5 `this bundle <https://fontforge.org/downloads/tutorial.tgz>`__
6 should provide you with the basic files you need.
7
8 I shall not presume to teach aesthetics, I concentrate solely on the mechanics
9 here.
10
11 .. epigraph::
12
13 **NOBLEMAN:** Now this is what I call workmanship. There is nothing
14 on earth more exquisite than a bonny book, with well-placed columns of rich
15 black writing in beautiful borders, and illuminated pictures cunningly inset.
16 But nowadays, instead of looking at books, people read them. A book might as
17 well be one of those orders for bacon and bran that you are scribbling.
18
19 | -- Saint Joan, Scene IV
20 | George Bernard Shaw, 1924
21
22
23 Font creation
24 -------------
25
26 First create a new font with the ``New`` command in the ``File`` menu (or by
27 using the ``-new`` argument at startup).
28
29 .. image:: /images/newfont.png
30
31 Give the font a name with the :doc:`Font Info </ui/dialogs/fontinfo>` command from the
32 ``Element`` menu. You use this same command to set the copyright message and
33 change the ascent and descent (the sum of these two determines the size of the
34 em square for the font, and by convention is 1000 for postscript fonts, a power
35 of two (often 2048 or 4096) for truetype fonts and 15,000 for Ikarus fonts).
36 :small:`(Also if you are planning on making a truetype font you might want to
37 check the Quadratic Splines checkbox to use the native truetype format.
38 Editing is a little more difficult in this mode though)`
39
40 .. image:: /images/fontinfo.png
41
42 You may also wish to use :menuselection:`Encoding --> Reencode` to change what
43 characters are available in your font. FontForge generally creates new fonts
44 with an ISO-8859-1, which contains (most of) the characters needed for Western
45 Europe (the latin letters, some accented letters, digits, and symbols).
46
47
48 Creating a glyph
49 ----------------
50
51 Once you have done that you are ready to start editing glyphs. Double click on
52 the entry for "C" in the font view above. You should now have an empty Outline
53 Glyph window:
54
55 .. image:: /images/C1.png
56
57 The outline glyph window contains two palettes snuggled up on the left side of
58 the window. The top palette contains a set of editing tools, and the bottom
59 palette is for managing drawing layers. They can be added, deleted (not all!),
60 shown or hidden, for example.
61
62 Cubic layers (C) use third-order Bezier splines, like PS fonts. Quadratic ones
63 (Q) use second-degree splines, that are harder to edit, but mathematically
64 easier and simpler to control, so they are used in TTF fonts.
65
66 The foreground (F) layer contains the outline that will become part of the font.
67 The background (B) layer can contain images or line drawings that help you draw
68 this particular glyph. The guide (#) layer contains lines that are useful on a
69 font-wide basis (such as the x-height). Currently all layers are empty.
70
71 This window also shows the glyph's internal coordinate system with the x and y
72 axes drawn in light grey. A line representing the glyph's advance width is drawn
73 in black at the right edge of the window. FontForge assigns an advance width of
74 one em (in PostScript that will usually be 1000 units) to the advance width of a
75 new glyph.
76
77 .. _editexample.Import:
78
79 Let us assume you already have a bitmap image of the glyph you are working on.
80 Select the Import command from the File menu and import that image. It will be
81 scaled so that it is as high as the em-square.
82
83 .. image:: /images/C2.png
84
85 Select the background layer as editable from the layers palette, move the mouse
86 pointer to one of the edges of the image, hold down the shift key, depress and
87 drag the corner until the image is a reasonable size, then move the pointer onto
88 the dark part of the image, depress the mouse and drag until the image is
89 properly positioned.
90
91 .. image:: /images/C3.png
92
93 If you have downloaded the
94 `autotrace program <http://sourceforge.net/projects/autotrace/>`__ you can
95 invoke :menuselection:`Element --> AutoTrace` to generate an outline from the
96 image. But if you have not you must add points yourself. Change the active layer
97 to be the foreground, and go to the tools palette and select the round (or
98 curve) point. Then move the pointer to the edge of the image and add a point. I
99 find that it is best to add points at places where the curve is horizontal or
100 vertical, at corners, or where the curve changes inflection (A change of
101 inflection occurs in a curve like "S" where the curve changes from being open to
102 the left to being open on the right. If you follow these rules hinting will work
103 better.
104
105 .. image:: /images/C4.png
106
107 It is best to enter a curve in a clockwise fashion, so the next point should be
108 added up at the top of the image on the flat section. Because the shape becomes
109 flat here, a curve point is not appropriate, rather a tangent point is (this
110 looks like a little triangle on the tools palette). A tangent point makes a nice
111 transition from curves to straight lines because the curve leaves the point with
112 the same slope the line had when it entered.
113
114 .. image:: /images/C5.png
115
116 At the moment this "curve" doesn't match the image at all, don't worry about
117 that we'll fix it later, and anyway it will change on its own as we continue.
118 Note that we now have a control point attached to the tangent point (the little
119 blue x). The next point needs to go where the image changes direction abruptly.
120 Neither a curve nor a tangent point is appropriate here, instead we must use a
121 corner point (one of the little squares on the tools palette).
122
123 .. image:: /images/C6.png
124
125 As you see the old curve now follows the image a bit more closely. We continue
126 adding points until we are ready to close the path.
127
128 .. image:: /images/C7.png
129
130 Then we close the path just by adding a new point on top of the old start point
131
132 .. image:: /images/C8.png
133
134 Now we must make the curve track the image more closely, to do this we must
135 adjust the control points (the blue "x"es). To make all the control points
136 visible select the pointer tool and double-click on the curve and then move the
137 control points around until the curve looks right.
138
139 .. image:: /images/C9.png
140
141 Finally we set width. Again with the pointer tool, move the mouse to the width
142 line on the right edge of the screen, depress and drag the line back to a
143 reasonable location.
144
145 .. image:: /images/C10.png
146
147 And we are done with this glyph.
148
149 If you are mathematically inclined you may be interested in the coordinates that
150 fontforge shows in the upper left of the window. Generally you can draw glyphs
151 quite happily without bothering about these, but for those who are interested
152 here is some basic info:
153
154 * Each glyph has its own coordinate system.
155 * The vertical origin is the font's baseline (the line on which most latin letters
156 rest)
157 * The horizontal origin is the place where drawing the glyph will commence. In the
158 example above what gets drawn initially is empty space, that is fairly common,
159 and that empty space (the distance from the origin to the left edge of the
160 glyph) is called the left side bearing.
161 * The units of the coordinate system are determined by the em-size of the font.
162 This is the sum of the font's ascent and descent. In the example above the
163 font's ascent is 800 and descent is 200, and the ascent line (the one just above
164 the top of the "C") is 800 units from the baseline, while the descent line is
165 200 units below.
166 * So a position of 282,408 (as above) means that the cursor is 282 units right of
167 the horizontal origin and 408 units above the baseline (or roughly halfway
168 between baseline and ascent).