SIL Non-Roman Script Initiative


A free and open rendering engine for complex scripts

Graphite Tutorial


Unit 12: Positioning by attachment


Use of attachment points can be a more elegant way to accomplish positioning than shifting and kerning. With this approach, attachment points are defined on glyphs using glyph attributes. Then there are rules that attach glyphs at their attachment points when they occur within a given context. When two glyphs are attached, they are positioned so that their attachment points exactly coincide.

For instance, the following statement defines an attachment point at the upper center of a base character, where you might want to attach a diacritic:

clsBase = <glyph-list>
    { upperAttPtS = point(bb.width/2, };

A second statement defines a corresponding attachment point at the bottom of the diacritic:

clsDiac = <glyph-list>
    { upperAttPtM = point(bb.width/2, bb.bottom) };

Notice that attachment points generally come in pairs, and so it is helpful to give them corresponding names. One convention is to use an S for the point on the base, meaning "stationary" - i.e., the base is stationary with respect to the diacritic. Similarly, M can be used on the diacritic to indicate that it is "mobile" with respect to the base.

A rule within the positioning table is used to perform the attachment, as shown:

  clsBase  clsDiac {attach {to=@1; at=upperAttPtS; with=upperAttPtM}};

This rule has the effect of attaching the diacritic. The slot attribute indicates the neighboring item to which it should be attached, that is, the base character. The attribute names the glyph attribute which is the relevant attachment point on the base character, and attach.with indicates the corresponding attachment point on the diacritic. (Remember that {attach {to=@1; ... }} is equivalent to { = @1; ... }.)

Exercise 12a

Rewrite your program from Exercise 11 to position the diacritics using attachment points.


Exercise 12b

Write a program to position the following lower diacritics using attachment points.

To test your program, open file test_ex12b.wpx, and set the font of the writing system “TUT12b” to your font. Or install the “Graphite Tutorial” (graphite_tutorial.kmx) Keyman keyboard and use the keystrokes shown in the table below.

CharacterGlyphKeystroke(s)Unicode (hex)
grave - ` (minus backquote) 0316
acute - ' (minus apostrophe) 0317
plus - + (minus plus) 031F
diaeresis - : (minus colon) 0324
ring - o 0325
vertical line - | 0329
tilde - ~ 0330


Exercise 12c

Write a program to position the Greek lower iota diacritic (“ypogegrammeni,” U+0345) correctly under the Greek vowels alpha (U+03B1), eta (U+03B7), and omega (U+03C9). Note that when attached to the eta, the diacritic is not centered but is positioned under the left-hand stroke, as shown:

Compile your program against the SIL Galatia Unicode font (SilGalUni20b1.ttf).

Extend your program to handle a possible intervening upper diacritic (eg, smooth breathing mark, U+0313 or rough breathing mark, U+0314) between the base character and the lower diacritic.


Copyright © 2012 SIL International® and released under the  Creative Commons Attribution-ShareAlike 3.0 license (CC-BY-SA) unless noted otherwise.