So far the right-hand (output) side of our GDL rules have contained single glyphs. It is also possible to use a multi-glyph class for substititution.
When one glyph is substituted for another, the Graphite engine determines the position of the input glyph within the input class, and uses the corresponding item from the output class in the substitution. For instance, the following two classes define classes of uppercase and lowercase letters:
table(glyph); clsUppercase = unicode(65..90); // A .. Z clsLowercase = unicode(97..122); // a .. z endtable; table(sub); clsUppercase > clsLowercase; endtable;
When, say, the uppercase “H” is encountered in the input, the corresponding lowercase “h” is placed into the output. Keep in mind that the order of the items in the classes becomes very significant when this mechanism is being used.
Note that you need to use parenthesis around the members of a class when there are more than one. For instance:
clsConsVoiced = (gB, gD, gG); clsConsVoiceless = (gP, gT, gK);
Write a program to capitalize all text.
Write a program to make all vowels uppercase and all consonants lowercase.
The program you wrote for Exercise 4b should have at least two rules in it. Enter some test data: Hello World! The output should look like: hEllO wOrld! Double-click on Pass 1 in the Passes pane. Notice that both Rule 0 and Rule 1 appear in the Rules pane. Clicking on the box in the left-hand column should highlight the appropriate rule in the code pane.
Also notice that hovering over the left-hand cell containing the rule number will cause the rule to be displayed near the cursor.
Highlighting one of several rules
Write a program to create a Greek transliteration of Roman text, using the mappings in the table below. (You may ignore uppercase for this exercise.) Note that the Unicode codepoints are not in strict numerical order, and that there are no mappings for the letters j and v.
|Roman letter||Greek letter||Glyph||Unicode (hex)|
Compile your program against the Galatia Graphite Tutorial font (GalatiaGrTut.ttf) that is provided with the tutorial materials. It is best to copy the font into your workspace.
If you use lowercase in the hexadecimal numbers representing your Unicode codepoints, you may see a compilation error: "Undefined glyph class: oundingbox". This a bug in the pre-processor, where it interprets the hex digits 'bb' as 'boundingbox'. The work-around is to use 'BB' in instead of 'bb'.