write_font_fallback.json

The JSON file of the “A Font behind the Font” example. One line of statuses set twice: in a company font alone, where the characters it has no glyph for come out as empty boxes, then with a second font behind it that draws them.

JSON 349 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.

This request writes by hand three things the library works out for itself: the number of stretches — seven — the two fonts cut the line into, and the name of each of the two fonts. The count changes whenever the line or either font's coverage changes, and the names change whenever either font file is replaced; since the three values are written by hand in the file, each of those changes means correcting them by hand. Each of the three columns at the foot is given a rectangle wider than the room left beside it, and the third one's runs past the right edge of the page; what they hold fits all the same, because it is short. Two lines of the library's page are not in the request: the house font told to draw nothing for what it lacks, and told to draw a question mark in its place. A request tells only a font it carries itself what to draw for what that font lacks, and the house font is one the server holds, so the request's page has nothing where those two lines stand.

What This Example Is For

A company font rarely has a glyph for every character a document needs. A tick, a star, an umbrella: the font simply does not carry them, and where a glyph is missing the reading software leaves an empty box. The trouble is that the hole passes in silence. The page looks finished, the run goes out, and it is the customer who finds the hole — in the one status line out of forty that happens to use the symbol.

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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
{
  "fonts": [
    {"name": "plex_box", "part": "IBMPlexSans-Regular.otf", "missing_glyph": "notdef"},
    {"name": "plex_nothing", "part": "IBMPlexSans-Regular.otf", "missing_glyph": "drop"},
    {"name": "plex_question_mark", "part": "IBMPlexSans-Regular.otf", "missing_glyph": {"replace": "?"}}
  ],
  "font_variants": [
    {"name": "plex_standing_in", "from": "plex", "stand_ins": true}
  ],
  "font_chains": [
    {"name": "chained", "faces": ["plex", "DejaVuSans"]},
    {"name": "plex_figures_behind", "faces": ["plex"],
     "ranges": [{"from": "0", "to": "9", "font": "DejaVuSans"}]}
  ],
  "items": [
    {
      "type": "text",
      "rect": {"llx": 60, "lly": 758.4, "urx": 535, "ury": 780},
      "content": ["A font behind the font"],
      "font": "plex",
      "font_size": 18
    },
    {
      "type": "text",
      "rect": {"llx": 60, "lly": 694, "urx": 535, "ury": 750},
      "content": ["A house font rarely covers every character a document has to draw. Without a second font behind it, a character it has no glyph for comes out as the empty box below.\nA chain hands that character to the next font instead, so the line is set in as many fonts as it takes and every mark is drawn."],
      "font": "chained",
      "font_size": 10,
      "leading": 14
    },

    {
      "type": "text",
      "rect": {"llx": 60, "lly": 639.2, "urx": 535, "ury": 650},
      "content": ["The house font alone: what it has no glyph for, it cannot draw."],
      "font": "plex",
      "font_size": 9
    },
    {
      "type": "text",
      "rect": {"llx": 60, "lly": 598, "urx": 535, "ury": 616},
      "content": ["✓ Paid · ★ Priority · ☂ Weather hold · ✗ Refused"],
      "font": "plex",
      "font_size": 15
    },

    {
      "type": "text",
      "rect": {"llx": 60, "lly": 549.2, "urx": 535, "ury": 560},
      "content": ["The house font, with a second one behind it."],
      "font": "plex",
      "font_size": 9
    },
    {
      "type": "text",
      "rect": {"llx": 60, "lly": 508, "urx": 535, "ury": 526},
      "content": ["✓ Paid · ★ Priority · ☂ Weather hold · ✗ Refused"],
      "font": "chained",
      "font_size": 15
    },

    {
      "type": "text",
      "rect": {"llx": 60, "lly": 442, "urx": 535, "ury": 470},
      "content": ["The line above is cut into 7 stretches, drawn by two fonts: IBMPlexSans, then DejaVuSans. The words are in the first; the marks it lacks are in the second."],
      "font": "chained",
      "font_size": 10,
      "leading": 14
    },

    {
      "type": "text",
      "rect": {"llx": 60, "lly": 389.2, "urx": 535, "ury": 400},
      "content": ["Mark"],
      "font": "plex",
      "font_size": 9
    },
    {
      "type": "text",
      "rect": {"llx": 106, "lly": 389.2, "urx": 581, "ury": 400},
      "content": ["Status"],
      "font": "plex",
      "font_size": 9
    },
    {
      "type": "text",
      "rect": {"llx": 236, "lly": 389.2, "urx": 711, "ury": 400},
      "content": ["Drawn by"],
      "font": "plex",
      "font_size": 9
    },

    {
      "type": "text",
      "rect": {"llx": 60, "lly": 358, "urx": 535, "ury": 382},
      "content": ["✓"],
      "font": "chained",
      "font_size": 10
    },
    {
      "type": "text",
      "rect": {"llx": 106, "lly": 358, "urx": 581, "ury": 382},
      "content": ["Paid"],
      "font": "chained",
      "font_size": 10
    },
    {
      "type": "text",
      "rect": {"llx": 236, "lly": 358, "urx": 711, "ury": 382},
      "content": ["IBMPlexSans"],
      "font": "chained",
      "font_size": 10
    },

    {
      "type": "text",
      "rect": {"llx": 60, "lly": 340, "urx": 535, "ury": 364},
      "content": ["★"],
      "font": "chained",
      "font_size": 10
    },
    {
      "type": "text",
      "rect": {"llx": 106, "lly": 340, "urx": 581, "ury": 364},
      "content": ["Priority"],
      "font": "chained",
      "font_size": 10
    },
    {
      "type": "text",
      "rect": {"llx": 236, "lly": 340, "urx": 711, "ury": 364},
      "content": ["DejaVuSans"],
      "font": "chained",
      "font_size": 10
    },

    {
      "type": "text",
      "rect": {"llx": 60, "lly": 322, "urx": 535, "ury": 346},
      "content": ["☂"],
      "font": "chained",
      "font_size": 10
    },
    {
      "type": "text",
      "rect": {"llx": 106, "lly": 322, "urx": 581, "ury": 346},
      "content": ["Weather hold"],
      "font": "chained",
      "font_size": 10
    },
    {
      "type": "text",
      "rect": {"llx": 236, "lly": 322, "urx": 711, "ury": 346},
      "content": ["DejaVuSans"],
      "font": "chained",
      "font_size": 10
    },

    {
      "type": "text",
      "rect": {"llx": 60, "lly": 304, "urx": 535, "ury": 328},
      "content": ["✗"],
      "font": "chained",
      "font_size": 10
    },
    {
      "type": "text",
      "rect": {"llx": 106, "lly": 304, "urx": 581, "ury": 328},
      "content": ["Refused"],
      "font": "chained",
      "font_size": 10
    },
    {
      "type": "text",
      "rect": {"llx": 236, "lly": 304, "urx": 711, "ury": 328},
      "content": ["DejaVuSans"],
      "font": "chained",
      "font_size": 10
    },
    {
      "type": "flow",
      "rect": {
        "llx": 60,
        "lly": 260,
        "urx": 535,
        "ury": 280
      },
      "content": "The house font alone, told three ways what to draw for what it lacks:",
      "font": "plex",
      "font_size": 9
    },
    {
      "type": "flow",
      "rect": {
        "llx": 60,
        "lly": 236,
        "urx": 210,
        "ury": 256
      },
      "content": "the box every font carries",
      "font": "plex",
      "font_size": 9
    },
    {
      "type": "flow",
      "rect": {
        "llx": 220,
        "lly": 236,
        "urx": 535,
        "ury": 256
      },
      "content": "✓ Paid · ★ Priority · ☂ Weather hold · ✗ Refused",
      "font": "plex_box",
      "font_size": 11
    },
    {
      "type": "flow",
      "rect": {
        "llx": 60,
        "lly": 212,
        "urx": 210,
        "ury": 232
      },
      "content": "nothing at all",
      "font": "plex",
      "font_size": 9
    },
    {
      "type": "flow",
      "rect": {
        "llx": 220,
        "lly": 212,
        "urx": 535,
        "ury": 232
      },
      "content": "✓ Paid · ★ Priority · ☂ Weather hold · ✗ Refused",
      "font": "plex_nothing",
      "font_size": 11
    },
    {
      "type": "flow",
      "rect": {
        "llx": 60,
        "lly": 188,
        "urx": 210,
        "ury": 208
      },
      "content": "“?” in its place",
      "font": "plex",
      "font_size": 9
    },
    {
      "type": "flow",
      "rect": {
        "llx": 220,
        "lly": 188,
        "urx": 535,
        "ury": 208
      },
      "content": "✓ Paid · ★ Priority · ☂ Weather hold · ✗ Refused",
      "font": "plex_question_mark",
      "font_size": 11
    },
    {
      "type": "flow",
      "rect": {
        "llx": 60,
        "lly": 160,
        "urx": 210,
        "ury": 184
      },
      "content": "told to draw what it lacks as the character it stands for",
      "font": "plex",
      "font_size": 9
    },
    {
      "type": "flow",
      "rect": {
        "llx": 220,
        "lly": 164,
        "urx": 535,
        "ury": 184
      },
      "content": "273 K",
      "font": "plex_standing_in",
      "font_size": 11
    },
    {
      "type": "flow",
      "rect": {
        "llx": 60,
        "lly": 120,
        "urx": 535,
        "ury": 140
      },
      "content": "The house font's figures, drawn once by the house font and once by the second font:",
      "font": "plex",
      "font_size": 9
    },
    {
      "type": "flow",
      "rect": {
        "llx": 60,
        "lly": 96,
        "urx": 210,
        "ury": 116
      },
      "content": "its own figures",
      "font": "plex",
      "font_size": 9
    },
    {
      "type": "flow",
      "rect": {
        "llx": 220,
        "lly": 96,
        "urx": 535,
        "ury": 116
      },
      "content": "0123456789",
      "font": "plex",
      "font_size": 11
    },
    {
      "type": "flow",
      "rect": {
        "llx": 60,
        "lly": 72,
        "urx": 210,
        "ury": 92
      },
      "content": "the second font's figures",
      "font": "plex",
      "font_size": 9
    },
    {
      "type": "flow",
      "rect": {
        "llx": 220,
        "lly": 72,
        "urx": 535,
        "ury": 92
      },
      "content": "0123456789",
      "font": "plex_figures_behind",
      "font_size": 11
    }
  ]
}