Skip to content

Commit c0a9494

Browse files
committed
Add guardspace description to manual
1 parent 7ded63e commit c0a9494

File tree

5 files changed

+572
-1
lines changed

5 files changed

+572
-1
lines changed

ChangeLog

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
. Fonts no longer require a glyf/loca table. In such cases the bounding box is always 0.
99
. Clang ASAN build support added for testing.
1010
. Handle out of memory sanely.
11-
. Dcoumentation improvements
11+
. Documentation improvements
1212
. Bug fixes:
1313
. Enforce fonts having to store glyph attributes by monotonically increasing attribute number
1414
. zeropadding was not getting called on feature tags

doc/font.txt

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
== Font Topics ==
2+
3+
=== Guard Space ===
4+
5+
Graphite introduces guard space around diacritics. Sometimes a diacritic is
6+
wider than its base and the diacritic is in danger of crashing into clusters on
7+
either side of it. To stop that happening, graphite allows the font designer to
8+
signal that they want guard space to be ensured around a diacritic. For example,
9+
if a diacritic glyph is designed with a positive left side bearing and a
10+
positive right side bearing, the graphite engine will ensure that the cluster
11+
honours those side bearings for the diacritic. Of course, if the base character
12+
is wider than the diacritic, then no guard space is needed.
13+
14+
The basic principle for cluster adjustment is that if a diacritic has a non-zero
15+
advance and after positioning, the advance of the diacritic is greater than the
16+
advance of the base then the advance of the base is increased to be the same as
17+
the positioned advance of the diacritic. Likewise if the origin of the diacritic
18+
is to the left of the origin of the base character, then the cluster is adjusted
19+
so that the origin of the diacritic is now where the origin of the base
20+
character was and the base character is moved to the right. Notice that this
21+
only happens if the origin of the diacritic is to the left of where it is
22+
attached or the advance is non-zero.
23+
24+
In the following image, we use a dotless i with a combining tilde over it, which
25+
is wider than the dotless i. The four scenarios show how positioning the tilde
26+
and setting its advance controls the origin and advance of the attached cluster:
27+
28+
image::guardspace.png[]
29+
30+
Each line shows the two glyphs as they are designed with the origin and advance
31+
(if any). The third element on the line is the combined cluster. Again the
32+
origin and advance for the cluster is shown with solid lines and any subglyph
33+
origins and advances that don't coincide with a solid line, are shown dotted.
34+
Notice that we don't show the implied attachment point used to attach the tilde
35+
to the dotless i.
36+
37+
The first line shows the diacritic as if it were a full base character, with
38+
positive left and right side bearings. When the glyphs attach the origin and the
39+
advance of the dotless i (shown as dotted lines) are pushed out to the origin
40+
and advance of the diacritic. Notice that graphite uses the wider advance and
41+
origin regardless of which component of the cluster they come from.
42+
43+
The second line shows the other extreme. Here no guard space is inserted. The
44+
diacritic is to the left of the origin and the advance is zero. The cluster
45+
origin and advance are taken from the base glyph. The dotted line shows the
46+
origin and advance of the diacritic.
47+
48+
These two lines are the most common cases that people want to use for rendering
49+
diacritics and whether space is automatically inserted to avoid collisions. The
50+
next two are rarely used but help to explain how the mechanism works.
51+
52+
The third line has guard space on the left only. For this the diacritic is drawn
53+
to the right of the origin but the advance width is set to 0. The effect is that
54+
guard space is inserted on the left, because there is a positive left side
55+
bearing (or more precisely the origin of the diacritic is to the left of the
56+
origin of the base when the two glyphs combine). Thus the dotless i origin
57+
(shown as a dotted line) is pushed out. Actually the whole cluster is pushed to
58+
the right so that the origin of the diacritic is aligned with where the origin
59+
of the base glyph was.
60+
61+
The fourth line gives guard space only after the diacritic. In this case, the
62+
diacritic is drawn to the left of the origin, and so no left guard space can
63+
occur, since the origin of the diacritic is to the right of the dotless i. The
64+
diacritic has also been drawn so that it finishes at the origin. This ensures
65+
that the guard space to the right is the same as the advance. It need not be.
66+
The cluster has the same origin as the base glyph. The base glyph advance is
67+
shown as a dotted line, which while not necessarily coinciding with the origin
68+
of the diacritic, will be close. Finally the advance for the cluster is the
69+
advance from the diacritic.
70+
71+
Since it is possible to change the advance width of a glyph (or at least for a
72+
particular instance of a glyph or slot), it is possible to dynamically control
73+
some of the guard space mechanism within GDL. It is possible to use a rule to
74+
change from both to or from left only. Likewise it is possible to use a rule to
75+
change from none to or from right only. But, unfortunately, it is not possible
76+
to shift glyphs within their drawn space and so switch between both and none,
77+
purely from GDL.
78+

doc/guardspace.png

57.5 KB
Loading

0 commit comments

Comments
 (0)