Debian Codegraph @

doc/sphinx/tutorial/editexample2.rst

raw
1 More on glyphs
2 ==============
3
4
5 Navigating to glyphs.
6 ---------------------
7
8 The font view provides one way of navigating around the glyphs in a font. Simply
9 scroll around it until you find the glyph you need and then double click on it
10 to open a window looking at that glyph.
11
12 Typing a glyph will move to that glyph.
13
14 However some fonts are huge (Chinese, Japanese and Korean fonts have thousands
15 or even tens of thousands of glyphs) and scrolling around the font view is a an
16 inefficient way of finding your glyph. :menuselection:`View --> Goto` provides a
17 simple dialog which will allow you to move directly to any glyph for which you
18 know the name (or encoding). If your font is a Unicode font, then this dialog
19 will also allow you to find glyphs by block name (ie. Hebrew rather than Alef).
20
21 The simplest way to navigate is just to go to the next or previous glyph. And
22 :menuselection:`View --> Next Char` and :menuselection:`View --> Prev Char` will
23 do exactly that.
24
25
26 Creating the letter "o" -- consistent directions
27 ------------------------------------------------
28
29 In the previous example the bitmap of the letter filled the canvas of the image.
30 And when FontForge imported the image it needed to be scaled once in the
31 program. But usually when you create the image of the letter you have some idea
32 of how much white space there should be around it. If your images are exactly
33 one em high then FontForge will scale them automatically to be the right size.
34 So in the following examples all the images have exactly the right amount of
35 white-space around them to fit perfectly in an em.
36
37 For the next example double click on the square in the font view that should
38 contain "o", and import "o_Ambrosia.png" into it.
39
40 .. rubric:: Stages in editing "o"
41
42 .. flex-grid::
43
44 * - .. image:: /images/o1.png
45 - .. image:: /images/o2.png
46 - .. image:: /images/o3.png
47 - .. image:: /images/o4.png
48
49 Notice that the first outline is drawn clockwise and the second
50 counter-clockwise. This change in drawing direction is important. Both
51 PostScript and TrueType require that the outer boundary of a glyph be drawn in a
52 certain direction (they happen to be opposite from each other, which is a mild
53 annoyance), within FontForge all outer boundaries must be drawn clockwise, while
54 all inner boundaries must be drawn counter-clockwise.
55
56 If you fail to alternate directions between outer and inner boundaries you may
57 get results like the one on the left |o-baddir|. If you fail to draw the outer
58 contour in a clockwise fashion the errors are more subtle, but will generally
59 result in a less pleasing result once the glyph has been rasterized.
60
61 .. |o-baddir| image:: /images/o-baddir.png
62
63 .. note::
64 **TECHNICAL AND CONFUSING**
65
66 The exact behavior of rasterizers varies. Early PostScript rasterizers used a
67 "non-zero winding number rule" while more recent ones use an "even-odd" rule.
68 TrueType uses the "non-zero" rule. The description given above is for the
69 "non-zero" rule. The "even-odd" rule would fill the "o" correctly no matter
70 which way the paths were drawn (though there would probably be subtle
71 problems with hinting).
72
73 .. _editexample2.even-odd-non-zero:
74
75 Filling using the even-odd rules that a line is drawn from the current pixel to
76 infinity (in any direction) and the number of contour crossings is counted. If
77 this number is even the pixel is not filled. If the number is odd the pixel is
78 filled. In the non-zero winding number rule the same line is drawn, contour
79 crossings in a clockwise direction add 1 to the crossing count,
80 counter-clockwise contours subtract 1. If the result is 0 the pixel is not
81 filled, any other result will fill it.
82
83 The command :ref:`Element->Correct Direction <elementmenu.Correct>` will look at
84 each selected contour, figure out whether it qualifies as an outer or inner
85 contour and will reverse the drawing direction when the contour is drawn
86 incorrectly.