]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/contributor/feta-font.itexi
002aa895a43167a4fc9eac319d2925e6de207b9e
[lilypond.git] / Documentation / contributor / feta-font.itexi
1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @node Modifying the feta font
3 @chapter Modifying the feta font
4
5 @menu
6 * Overview of the feta font::
7 * Font creation tools::
8 * Adding a new font section::
9 * Adding a new glyph::
10 * Building the changed font::
11 * METAFONT formatting rules::
12 @end menu
13
14 @node Overview of the feta font
15 @section Overview of the feta font
16
17 The feta font is a font that was created specifically for use in
18 LilyPond.  The sources for the font are found in mf/*.mf.
19
20 The feta font is merged from a number of subfonts.  Each subfont
21 can contain at most 224 glyphs.  This is because each subfont is
22 limited to a one-byte address space (256 glyphs maximum) and we
23 avoid the first 32 points in that address space, since they are
24 non-printing control characters in ASCII.
25
26 In LilyPond, glyphs are accessed by glyph name, rather than by code point.
27 Therefore, the naming of glyphs is significant.
28
29 Information about correctly creating glyphs is found in @file{mf/README}.
30 Please make sure you read and understand this file.
31
32 TODO -- we should get mf/README automatically generated from texinfo source
33 and include it here.
34
35
36 @node Font creation tools
37 @section Font creation tools
38
39 The sources for the feta font are written in metafont.  The definitive
40 reference for metafont is "The METAFONT book".  Source for the book is
41 available at CTAN.
42
43 mf2pt1 is used to create type 1 fonts from the metafont sources.
44
45 FontForge is used to postprocess the output of mf2pt1 and clean up
46 details of the font.  It can also be used by a developer to
47 display the resulting glyph shapes.
48
49 @node Adding a new font section
50 @section Adding a new font section
51
52 The font is divided into sections, each of which contains less
53 than 224 glyphs.  If more than 224 glyphs are included in a section,
54 an error will be generated.
55
56 Each of the sections is contained in a separate @code{.mf} file.  The
57 files are named according to the type of glyphs in that section.
58
59 When adding a new section, it will be necessary to add the following:
60
61 @itemize
62 @item
63 The code for the glyphs, in a file @code{<section-name>.mf}
64 @item
65 Driver files used to create the font in different sizes
66 @item
67 An entry in the generic file used to create the font, or a new
68 generic file
69 @item
70 If necessary, new entries in the GNUmakefile
71 @item
72 An entry in @file{scripts/build/gen-emmentaler-scripts.py}
73 @end itemize
74
75 See the examples in @code{mf/} for more information.
76
77 @node Adding a new glyph
78 @section Adding a new glyph
79
80 Adding a new glyph is done by modifying the .mf file to which the
81 glyph will be added.
82
83 Necessary functions to draw the glyph can be added anywhere in the file,
84 but it is standard to put them immediately before the glyph definition.
85
86 The glyph definition begins with:
87
88 @example
89 fet_beginchar ("glyph description", "glyphname");
90 @end example
91
92 @noindent
93 with @code{glyph description} replaced with a short description of the
94 glyph, and @code{glyphname} replaced with the glyphname, which is chosen
95 to comply with the naming rules in @file{mf/README}.
96
97 The metafont code used to draw the glyph follows the @code{fet_beginchar}
98 entry.  The glyph is finished with:
99
100 @example
101 fet_endchar;
102 @end example
103
104 @node Building the changed font
105 @section Building the changed font
106
107 In order to rebuild the font after making the changes, the existing
108 font files must be deleted.  The simplest and quickest way to do this
109 is to do:
110
111 @example
112 rm mf/out/*
113 make
114 @end example
115
116 @node METAFONT formatting rules
117 @section METAFONT formatting rules
118
119 There are special formatting rules for METAFONT files.
120
121 Tabs are used for the indentation of commands.
122
123 When a path contains more than two points, put each point on a
124 separate line, with the operator at the beginning of the line.
125 The operators are indented to the same depth as the initial point
126 on the path using spaces.  The indentation mechanism is illustrated
127 below, with @samp{------->} indicating a tab character and any other
128 indentation created using spaces.
129
130 @example
131 def draw_something (test) =
132 ------->if test:
133 ------->------->fill z1
134 ------->------->     -- z2
135 ------->------->     -- z3
136 ------->------->     .. cycle;
137 ------->fi;
138 enddef;
139 @end example
140