SIL Writing Systems Technology


A free and open rendering engine for complex scripts

Graphite Tutorial

Unit 7: Glyph attributes



Besides defining classes of glyphs, a further use of the glyph table is to define glyph attributes. The values of glyph attributes are constant for every instance of a given glyph (unlike slot attributes which are discussed later). There are several pre-defined glyph attributes, and GDL programmers can define their own.

The most common way of defining a glyph attribute is to include it in the glyph class definition, as follows:

clsExample  =  (item1, item2, …, itemN) {attr1 = value};

The statement above defines the glyph attribute attr1 for the members of the clsExample class. The value of a glyph attribute must be a number or a boolean.

For the exercise below, you will need to be able to test the value of attributes. This is done within the context of the rule. For instance, the rule below will only fire if the value of attr1 is true for the matched element of clsExample.

clsExample  >  clsModified  /  _ {attr1 == true};

Note that as in C++, the assignment operator is “=” and the comparison operator is “==”. Also the ! operator means “not”, and “!=” means “not equal”.


Rewrite the program from Exercise 6a to use a glyph attribute. Assign each letter a value for the glyph attribute “followsHardC”. Then test this glyph attribute in the rule to decide whether to change the “c” to a “k” or to an “s”.

Does this approach seem natural and elegant, or contrived? :-)


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