write_self_showing_layers.json

The JSON file of the “A Plan That Shows What Can Be Read” example. A land plan whose layers decide by themselves when to appear. A wide name stands over the plot while the plan is looked at whole, the fine wall figures come in once it is enlarged twice over, and the sentence under the plan is there in two languages, of which reading software shows the one it is set to.

JSON 259 lines

This file is a request: an application sends it over the network to the server, which creates the PDF and sends it back. It creates the same page as the Rust and Python versions of this example. A request names every file it uses, never its content; the call carries the request and the files together. A font the server already holds, such as DejaVuSans, is named with nothing attached. Send the request to the address the API page gives.

The page is written in two languages, and where the library example picks its set of words at the moment it runs, a request holds one set of words and there is one request per language. The one published here is the English one. The library also writes each line of the page at a stated height; a request gives a block of words a rectangle instead, so every line's rectangle here is worked back from that height, and twelve of them reach past the plan they stand under, harmlessly, because the library writes those lines without breaking them and a block of words would break them at the edge of its rectangle. The plot boundary and the house are one setting of the ink kept for both on the library's side and two things here, each stating that colour for itself, and the house is filled and then outlined as two shapes there and drawn once and painted in one go here. The four layers, the enlargement the first two change hands at, the language each of the last two states and which one reading software falls back on are the same either way, down to the order the panel lists them in.

What This Example Is For

A plan of a plot is read at two distances. Across a desk, somebody wants to know which plot it is and how wide it is, and that has to read at arm's length. On the screen, enlarged, the builder wants the figure written on each wall — and those figures are so small that at ordinary size they are a grey smudge over the drawing. Draw both at once and the plan is crowded when it is looked at whole and coarse when it is enlarged. The sentence under the plan has the same trouble again: the buyer reads French, the bank reads English, and keeping two plans side by side means two plans to keep in step.

What This Example Shows

  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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
{
  "layers": [
    { "name": "Whole plot", "zoom": { "to": 2.0 } },
    { "name": "Fine figures", "zoom": { "from": 2.0 } },
    { "name": "English", "language": "en", "preferred": true },
    { "name": "Français", "language": "fr" },
    { "name": "Deutsch", "language": "de" },
    { "name": "Español", "language": "es" },
    { "name": "Italiano", "language": "it" },
    { "name": "Português", "language": "pt" },
    { "name": "Nederlands", "language": "nl" }
  ],
  "items": [
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 790.0, "urx": 590.0, "ury": 808.0 },
      "content": ["A plan that shows what can be read"],
      "font": "DejaVuSans",
      "font_size": 15.0
    },
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 770.0, "urx": 590.0, "ury": 782.0 },
      "content": [
        "Every layer here decides for itself, by the magnification and by the language."
      ],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "color": [0.35, 0.35, 0.35]
    },

    {
      "type": "rect",
      "rect": { "llx": 80.0, "lly": 380.0, "urx": 515.0, "ury": 740.0 },
      "stroke": { "width": 1.6, "color": [0.2, 0.2, 0.2] }
    },
    {
      "type": "rect",
      "rect": { "llx": 140.0, "lly": 470.0, "urx": 340.0, "ury": 640.0 },
      "fill": [0.9, 0.91, 0.94],
      "stroke": { "width": 1.2, "color": [0.2, 0.2, 0.2] }
    },

    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 686.0, "urx": 515.0, "ury": 717.2 },
      "content": ["PLOT 12"],
      "font": "DejaVuSans",
      "font_size": 26.0,
      "align": "center",
      "color": [0.35, 0.42, 0.55],
      "layer": "Whole plot"
    },
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 664.0, "urx": 515.0, "ury": 678.4 },
      "content": ["24.30 m × 17.60 m"],
      "font": "DejaVuSans",
      "font_size": 12.0,
      "align": "center",
      "color": [0.35, 0.42, 0.55],
      "layer": "Whole plot"
    },

    {
      "type": "text",
      "rect": { "llx": 257.5, "lly": 385.0, "urx": 337.5, "ury": 390.4 },
      "content": ["24.30"],
      "font": "DejaVuSans",
      "font_size": 4.5,
      "align": "center",
      "color": [0.2, 0.45, 0.35],
      "layer": "Fine figures"
    },
    {
      "type": "text",
      "rect": { "llx": 54.0, "lly": 560.0, "urx": 134.0, "ury": 565.4 },
      "content": ["17.60"],
      "font": "DejaVuSans",
      "font_size": 4.5,
      "align": "center",
      "color": [0.2, 0.45, 0.35],
      "layer": "Fine figures"
    },
    {
      "type": "text",
      "rect": { "llx": 200.0, "lly": 475.0, "urx": 280.0, "ury": 480.4 },
      "content": ["11.20"],
      "font": "DejaVuSans",
      "font_size": 4.5,
      "align": "center",
      "color": [0.2, 0.45, 0.35],
      "layer": "Fine figures"
    },
    {
      "type": "text",
      "rect": { "llx": 114.0, "lly": 555.0, "urx": 194.0, "ury": 560.4 },
      "content": ["8.40"],
      "font": "DejaVuSans",
      "font_size": 4.5,
      "align": "center",
      "color": [0.2, 0.45, 0.35],
      "layer": "Fine figures"
    },
    {
      "type": "text",
      "rect": { "llx": 70.0, "lly": 555.0, "urx": 150.0, "ury": 560.4 },
      "content": ["3.35"],
      "font": "DejaVuSans",
      "font_size": 4.5,
      "align": "center",
      "color": [0.2, 0.45, 0.35],
      "layer": "Fine figures"
    },
    {
      "type": "text",
      "rect": { "llx": 200.0, "lly": 425.0, "urx": 280.0, "ury": 430.4 },
      "content": ["5.10"],
      "font": "DejaVuSans",
      "font_size": 4.5,
      "align": "center",
      "color": [0.2, 0.45, 0.35],
      "layer": "Fine figures"
    },

    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 350.0, "urx": 590.0, "ury": 362.0 },
      "content": ["Plot 12, Mill Lane — sold with the barn and the well."],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "layer": "English"
    },
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 335.0, "urx": 590.0, "ury": 347.0 },
      "content": ["Parcelle 12, chemin du Moulin — vendue avec la grange et le puits."],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "layer": "Français"
    },
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 320.0, "urx": 590.0, "ury": 332.0 },
      "content": ["Flurstück 12, Mill Lane — mit Scheune und Brunnen verkauft."],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "layer": "Deutsch"
    },
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 305.0, "urx": 590.0, "ury": 317.0 },
      "content": ["Parcela 12, Mill Lane — se vende con el granero y el pozo."],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "layer": "Español"
    },
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 290.0, "urx": 590.0, "ury": 302.0 },
      "content": ["Lotto 12, Mill Lane — venduto con il fienile e il pozzo."],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "layer": "Italiano"
    },
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 275.0, "urx": 590.0, "ury": 287.0 },
      "content": ["Lote 12, Mill Lane — vendido com o celeiro e o poço."],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "layer": "Português"
    },
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 260.0, "urx": 590.0, "ury": 272.0 },
      "content": ["Perceel 12, Mill Lane — verkocht met de schuur en de put."],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "layer": "Nederlands"
    },

    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 235.0, "urx": 590.0, "ury": 247.0 },
      "content": ["Whole plot"],
      "font": "DejaVuSans",
      "font_size": 10.0
    },
    {
      "type": "text",
      "rect": { "llx": 190.0, "lly": 235.0, "urx": 594.0, "ury": 247.0 },
      "content": ["stands over the plan while it is looked at whole"],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "color": [0.35, 0.35, 0.35]
    },
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 217.0, "urx": 590.0, "ury": 229.0 },
      "content": ["Fine figures"],
      "font": "DejaVuSans",
      "font_size": 10.0
    },
    {
      "type": "text",
      "rect": { "llx": 190.0, "lly": 217.0, "urx": 594.0, "ury": 229.0 },
      "content": ["comes in once the plan is enlarged twice over"],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "color": [0.35, 0.35, 0.35]
    },
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 199.0, "urx": 590.0, "ury": 211.0 },
      "content": ["English · Français · Deutsch · Español · Italiano · Português · Nederlands"],
      "font": "DejaVuSans",
      "font_size": 10.0
    },
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 185.0, "urx": 594.0, "ury": 197.0 },
      "content": ["one layer a language, shown when reading software is set to it"],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "color": [0.35, 0.35, 0.35]
    },
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 153.0, "urx": 590.0, "ury": 165.0 },
      "content": [
        "Enlarge the plan past two hundred per cent: the figures on the walls come in as the"
      ],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "color": [0.35, 0.35, 0.35]
    },
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 139.0, "urx": 590.0, "ury": 151.0 },
      "content": [
        "wide label steps back. Set reading software to another language and the sentence"
      ],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "color": [0.35, 0.35, 0.35]
    },
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 125.0, "urx": 590.0, "ury": 137.0 },
      "content": [
        "follows."
      ],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "color": [0.35, 0.35, 0.35]
    }
  ]
}