write_drawn_letters.json

Die JSON-Datei des Beispiels „Selbst gezeichnete Buchstaben“. Ein Haken, ein Kreuz und ein Strich, vom Programm gezeichnet, dem Dokument als Schrift hinzugefügt und zwischen gewöhnliche Wörter gesetzt.

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

Wofür dieses Beispiel da ist

Eine Schriftdatei enthält Buchstaben, die jemand anderes gezeichnet hat. Manchmal braucht ein Dokument ein Zeichen, das niemand für Sie gezeichnet hat: Ihr eigenes Logo, den Haken Ihrer Qualitätsbögen, ein Symbol, das Ihre Branche hat und Unicode nicht. Die übliche Antwort ist, an jeder Stelle ein Bild einzufügen und dann von Hand auszurechnen, wie weit es bis zum nächsten Wort weitergeht — was an dem Tag auseinanderfällt, an dem der Text übersetzt wird oder sich die Größe ändert.

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
{
  "fonts": [
    {
      "name": "HqfColor",
      "part": "HqfColor.ttf"
    }
  ],
  "color_fonts": [
    {
      "name": "signs",
      "from": "HqfColor",
      "characters": "★◉▲⚑"
    },
    {
      "name": "dark_star",
      "from": "HqfColor",
      "characters": "★",
      "palette": 1
    }
  ],
  "type3_fonts": [
    {
      "name": "marks",
      "matrix": [0.001, 0, 0, 0.001, 0, 0],
      "box": {"llx": 0, "lly": -200, "urx": 1000, "ury": 800},
      "glyphs": [
        {
          "character": "✓",
          "width": 1000,
          "items": [
            {
              "type": "path",
              "segments": [
                {"move_to": {"x": 140, "y": 480}},
                {"line_to": {"x": 390, "y": 230}},
                {"line_to": {"x": 870, "y": 740}}
              ],
              "stroke": {"width": 150, "color": [0.15, 0.55, 0.25]}
            }
          ]
        },
        {
          "character": "✗",
          "width": 1000,
          "items": [
            {
              "type": "path",
              "segments": [
                {"move_to": {"x": 200, "y": 230}},
                {"line_to": {"x": 810, "y": 740}},
                {"move_to": {"x": 810, "y": 230}},
                {"line_to": {"x": 200, "y": 740}}
              ],
              "stroke": {"width": 150, "color": [0.75, 0.15, 0.15]}
            }
          ]
        },
        {
          "character": "–",
          "width": 1000,
          "items": [
            {
              "type": "rect",
              "rect": {"llx": 160, "lly": 400, "urx": 840, "ury": 550},
              "fill": [0.55, 0.55, 0.55]
            }
          ]
        }
      ]
    },
    {
      "name": "shapes",
      "matrix": [0.001, 0, 0, 0.001, 0, 0],
      "box": {"llx": 0, "lly": -200, "urx": 1000, "ury": 800},
      "glyphs": [
        {
          "character": "■",
          "width": 1000,
          "box": {"llx": 200, "lly": 150, "urx": 800, "ury": 750},
          "items": [
            {
              "type": "rect",
              "rect": {"llx": 200, "lly": 150, "urx": 800, "ury": 750},
              "fill": [0]
            }
          ]
        }
      ]
    }
  ],
  "items": [
    {
      "type": "text",
      "rect": {"llx": 72, "lly": 700, "urx": 522, "ury": 760},
      "content": ["Letters you draw yourself"],
      "font": "DejaVuSans",
      "font_size": 18
    },
    {
      "type": "text",
      "rect": {"llx": 72, "lly": 640, "urx": 522, "ury": 724.4},
      "content": [
        "The three marks below are not in any font file. Each one is a drawing this program made, added to the document as a font, and set in a line of text like any other letter. Copy the line out of this file and the marks come back as the characters they stand for."
      ],
      "font": "DejaVuSans",
      "font_size": 10
    },
    {
      "type": "text",
      "rect": {"llx": 72, "lly": 620, "urx": 522, "ury": 662.4},
      "content": ["Marks that paint themselves"],
      "font": "DejaVuSans",
      "font_size": 12
    },
    {
      "type": "text",
      "rect": {"llx": 72, "lly": 600, "urx": 522, "ury": 638},
      "font": "DejaVuSans",
      "font_size": 11,
      "content": [
        {"text": "✓", "font": "marks"},
        {"text": " Invoice sent"},
        {"text": "    "},
        {"text": "✗", "font": "marks"},
        {"text": " Payment received"},
        {"text": "    "},
        {"text": "–", "font": "marks"},
        {"text": " Delivery note"}
      ]
    },
    {
      "type": "text",
      "rect": {"llx": 72, "lly": 560, "urx": 522, "ury": 598.8},
      "content": ["Marks that take the colour around them"],
      "font": "DejaVuSans",
      "font_size": 12
    },
    {
      "type": "text",
      "rect": {"llx": 72, "lly": 540, "urx": 522, "ury": 574.4},
      "font": "DejaVuSans",
      "font_size": 11,
      "content": [
        {"text": "■", "font": "shapes", "color": [0.75, 0.15, 0.15]},
        {"text": " Overdue", "color": [0.75, 0.15, 0.15]}
      ]
    },
    {
      "type": "text",
      "rect": {"llx": 72, "lly": 520, "urx": 522, "ury": 557.2},
      "font": "DejaVuSans",
      "font_size": 11,
      "content": [
        {"text": "■", "font": "shapes", "color": [0.15, 0.35, 0.75]},
        {"text": " Settled", "color": [0.15, 0.35, 0.75]}
      ]
    },
    {
      "type": "text",
      "rect": {"llx": 72, "lly": 460, "urx": 522, "ury": 518},
      "content": [
        "A mark of the first kind carries its own colour. A mark of the second kind states a shape and nothing else, so the colour of the words it sits among is the colour it comes out in."
      ],
      "font": "DejaVuSans",
      "font_size": 10
    },
    {
      "type": "text",
      "rect": {
        "llx": 72,
        "lly": 452.4,
        "urx": 522,
        "ury": 480
      },
      "content": [
        "The painted font: glyphs, 3; box, [0 -200 1000 1000]; matrix, [0.001 0 0 0.001 0 0]; ✓ is its glyph 1, 1000 wide."
      ],
      "font": "DejaVuSans",
      "font_size": 9
    },
    {
      "type": "text",
      "rect": {
        "llx": 72,
        "lly": 424.8,
        "urx": 522,
        "ury": 452.4
      },
      "content": [
        "The shaped font: glyphs, 1; box, [0 -200 1000 1000]; matrix, [0.001 0 0 0.001 0 0]; ■ is its glyph 0, 1000 wide."
      ],
      "font": "DejaVuSans",
      "font_size": 9
    },
    {
      "type": "text",
      "rect": {
        "llx": 72,
        "lly": 384.8,
        "urx": 522,
        "ury": 404.8
      },
      "content": [
        "Signs a font file paints in colour"
      ],
      "font": "DejaVuSans",
      "font_size": 12
    },
    {
      "type": "text",
      "rect": {
        "llx": 72,
        "lly": 360.4,
        "urx": 522,
        "ury": 380.4
      },
      "font": "DejaVuSans",
      "font_size": 11,
      "content": [
        {
          "text": "Each step is marked: "
        },
        {
          "text": "★",
          "font": "signs"
        },
        {
          "text": " approved,"
        },
        {
          "text": " "
        },
        {
          "text": "◉",
          "font": "signs"
        },
        {
          "text": " under review,"
        },
        {
          "text": " "
        },
        {
          "text": "▲",
          "font": "signs"
        },
        {
          "text": " awaiting signature."
        }
      ]
    },
    {
      "type": "text",
      "rect": {
        "llx": 72,
        "lly": 339.2,
        "urx": 522,
        "ury": 359.2
      },
      "font": "DejaVuSans",
      "font_size": 11,
      "content": [
        {
          "text": "★",
          "font": "signs"
        },
        {
          "text": " The star from the font’s first palette;"
        },
        {
          "text": " "
        },
        {
          "text": "★",
          "font": "dark_star"
        },
        {
          "text": " the same star from its second."
        }
      ]
    },
    {
      "type": "text",
      "rect": {
        "llx": 72,
        "lly": 318,
        "urx": 522,
        "ury": 338
      },
      "font": "DejaVuSans",
      "font_size": 11,
      "content": [
        {
          "text": "⚑",
          "font": "signs",
          "color": [
            0.75,
            0.15,
            0.15
          ]
        },
        {
          "text": " Overdue",
          "color": [
            0.75,
            0.15,
            0.15
          ]
        },
        {
          "text": "    "
        },
        {
          "text": "⚑",
          "font": "signs",
          "color": [
            0.15,
            0.35,
            0.75
          ]
        },
        {
          "text": " Settled",
          "color": [
            0.15,
            0.35,
            0.75
          ]
        }
      ]
    },
    {
      "type": "text",
      "rect": {
        "llx": 72,
        "lly": 270.8,
        "urx": 522,
        "ury": 310.8
      },
      "content": [
        "This program draws none of these signs: the font file paints each one in layers of colour, and the document sets them like any other letter. The flag’s pole takes the colour of the text around it; its cloth keeps its own."
      ],
      "font": "DejaVuSans",
      "font_size": 10
    }
  ]
}