write_drawn_letters.json

The JSON file of the “Letters you draw yourself” example. A tick, a cross and a dash drawn by the program, added to the document as a font, and set among ordinary words.

JSON 149 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 makes 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.

What this example is for

A font file holds letters somebody else drew. Sometimes what a document needs is a mark nobody drew for you: your own logo, the tick your quality sheets use, a symbol your trade has and Unicode has not. The usual answer is to drop a picture in at every occurrence and then work out by hand how far to move along before the next word — which comes apart the day the text is translated or the size changes.

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
{
  "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, which no font read from a file can do. 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
    }
  ]
}