write_font_fallback.json

Die JSON-Datei des Beispiels „Eine Schrift hinter der Schrift“. Eine Zeile mit Statusangaben, zweimal gesetzt: nur in einer Hausschrift, in der die Zeichen ohne Glyphe als leere Kästchen herauskommen, dann mit einer zweiten Schrift dahinter, die sie zeichnet.

JSON 349 Zeilen

Diese Datei ist eine Anfrage: Eine Anwendung sendet sie über das Netz an den Server, der das PDF erzeugt und zurücksendet. Sie erzeugt dieselbe Seite wie die Rust- und die Python-Fassung dieses Beispiels. Eine Anfrage nennt jede Datei, die sie verwendet, nie ihren Inhalt; der Aufruf trägt die Anfrage und die Dateien zusammen. Eine Schrift, die der Server bereits vorhält, etwa DejaVuSans, wird ohne Anhang genannt. Senden Sie die Anfrage an die Adresse, die die API-Seite angibt.

Diese Anfrage schreibt drei Dinge von Hand aus, die die Bibliothek selbst ermittelt: die Zahl der Abschnitte — sieben —, in die die beiden Schriften die Zeile zerlegen, und den Namen jeder der beiden Schriften. Die Zahl ändert sich, wann immer sich die Zeile oder die Abdeckung einer der Schriften ändert, und die Namen ändern sich, wann immer eine der Schriftdateien ersetzt wird; da die drei Werte in der Datei von Hand stehen, heißt jede dieser Änderungen, sie von Hand zu korrigieren. Jede der drei Spalten am Fuß erhält ein Rechteck, das breiter ist als der Platz daneben, und das der dritten läuft über den rechten Seitenrand hinaus; was sie enthalten, passt trotzdem, weil es kurz ist. Zwei Zeilen der Seite der Bibliothek fehlen in der Anfrage: die Hausschrift, angewiesen, für Fehlendes nichts zu zeichnen, und angewiesen, an seiner Stelle ein Fragezeichen zu zeichnen. Eine Anfrage sagt nur einer Schrift, die sie selbst trägt, was sie für Fehlendes zeichnen soll, und die Hausschrift hält der Server vor; die Seite der Anfrage hat also nichts, wo diese beiden Zeilen stehen.

Wofür dieses Beispiel da ist

Eine Hausschrift hat selten eine Glyphe für jedes Zeichen, das ein Dokument braucht. Ein Haken, ein Stern, ein Schirm: Die Schrift enthält sie einfach nicht, und wo eine Glyphe fehlt, lässt die Anzeigesoftware ein leeres Kästchen. Das Tückische ist, dass die Lücke stillschweigend durchgeht. Die Seite sieht fertig aus, der Druck geht hinaus, und der Kunde findet die Lücke — in der einen Statuszeile von vierzig, die zufällig das Symbol verwendet.

Was dieses Beispiel zeigt

  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
    }
  ]
}