1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
/*********************************************************************************
File: xline.gdl
For testing cross-line contextualization.
Compile with stddr.ttf
To test, type something like these examples:
abc$x
abcx@
abc$x@
and force a line break after the x.
*********************************************************************************/
#include "stddef.gdh"
Bidi = false;
#define duplicated user1
table(glyph) {MUnits = 1000 }
g_A = codepoint("A");
g_B = codepoint("B");
g_C = codepoint("C");
g_D = codepoint("D");
g_E = codepoint("E");
g_F = codepoint("F");
g_G = codepoint("G");
g_a = codepoint("a");
g_b = codepoint("b");
g_c = codepoint("c");
g_d = codepoint("d");
g_e = codepoint("e");
g_f = codepoint("f");
g_g = codepoint("g");
g_x = codepoint("x");
g_y = codepoint("y");
g_z = codepoint("z");
g_asterisk = codepoint("*") { ptCenter = point(bb.width/2, bb.height/2) };
g_dollar = codepoint("$") { xWid = aw };
g_hash = codepoint("#");
g_at = codepoint("@") { xWid = aw };
g_amp = codepoint("&") {xWid = aw };
g_percent = codepoint("%");
g_leftArrow = codepoint("<") { xWid = aw };
g_rightArrow = codepoint(">") { xWid = aw };
clsUpper = codepoint("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
{ ptCenter = point(bb.width/2, ascent/2) };
clsLower = codepoint("abcdefghijklmnopqrstuvwxyz");
clsMyAny = glyphid(2..216) { justify.stretch = 700m };
g_m = codepoint("m");
g_Mlig = codepoint("M") {
component.one = box(0,0, bb.width/2, ascent);
component.two = box(bb.width/2,0, bb.width,ascent) };
gSpace = U+0020 { justify.stretch = 3000m };
clsXYZ = (g_x g_y g_z);
endtable; // glyph
table(lb)
// Allow non-optimal linebreaks after x, y, or z.
clsXYZ {break = BREAK_INTRA};
endtable; // lb
table(sub)
pass(1)
// Switch the $ and @ if they are both there, and insert & after the one on the first
// line and before the one on the second line. Note that these rules supercede the rule
// to insert the left- and right-arrows.
g_dollar _ _ g_at > @7 g_amp:7 g_amp:1 @1
/ _ _ ANY? # {break == BREAK_INTRA} ANY? _ _ ;
g_dollar
clsXYZ {measure.endofline = g_at.aw - g_dollar.aw + g_amp.aw}
ANY {measure.startofline = g_dollar.aw - g_at.aw + g_amp.aw}
g_at;
g_dollar
clsXYZ {measure.endofline = g_at.aw - g_dollar.aw + g_amp.aw}
g_at {measure.startofline = g_dollar.aw - g_at.aw + g_amp.aw};
// Just copy the $ to the following segment.
g_dollar _ > @1 {duplicated = true} g_dollar:1
/ _ {duplicated == false} ANY? ^ # {break == BREAK_INTRA} ANY? _ ;
g_dollar
clsXYZ {measure.endofline = g_rightArrow.aw}
ANY {measure.startofline = g_dollar.aw + g_leftArrow.aw};
// Just copy the @ to the previous segment.
_ g_at > g_at:5 @5 {duplicated = true}
/ _ ANY? ^ # {break == BREAK_INTRA} ANY? _ {duplicated == false};
clsXYZ {measure.endofline = g_at.aw + g_rightArrow.aw}
ANY {measure.startofline = g_leftArrow.aw}
g_at;
clsXYZ {measure.endofline = g_at.aw + g_rightArrow.aw}
g_at {measure.startofline = g_leftArrow.aw};
// Insert a '<' at the beginning of the line and a '>' at the end.
_ > g_leftArrow / # _;
_ > g_rightArrow / clsMyAny _ # ^ ;
clsMyAny {measure {startofline = g_leftArrow.aw; endofline = g_rightArrow.aw}};
endpass;
pass(2)
// Don't stretch trailing white space.
gSpace {justify.stretch = 0} / _ [gSpace [gSpace [gSpace gSpace?]? ]? ]? # ;
// In fact, don't stretch any line-boundary glyph.
clsMyAny {justify.stretch = 0} / _ #;
endpass;
endtable; // sub
table(pos)
clsMyAny {adv.x += justify.width};
endtable; // pos
|