write_soft_hyphen.json

The JSON file of the “Soft hyphens and no-break spaces” example. A justified column set twice: the long words breaking at their soft hyphens with a hyphen shown, or left whole, and a figure a no-break space keeps together.

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

The library writes the paragraph once and takes the soft hyphens out of it for the upper panel; the request writes it out twice, the upper one already without them. The height of each panel is a number the library measures off the lines it has just set, so that the frame closes on the last of them; here it is typed in, and would have to be typed in again if a word changed.

What this example is for

A narrow justified column goes loose as soon as its words are long: the spaces stretch, channels of white run down the page, and the eye falls into them instead of reading. What sets the page right today, and costs nothing, is to say inside the text itself where a particular word is allowed to break (automatic word-breaking, with a dictionary behind it for each language, is planned for a future version).

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
{
  "items": [
    {
      "type": "text",
      "rect": {
        "llx": 80.0,
        "lly": 750.4,
        "urx": 480.0,
        "ury": 760.0
      },
      "content": [
        "Without soft hyphens: justify opens the lines to fill the column."
      ],
      "font": "DejaVuSans",
      "font_size": 8.0
    },
    {
      "type": "text",
      "rect": {
        "llx": 80.0,
        "lly": 650.0,
        "urx": 230.0,
        "ury": 740.0
      },
      "content": [
        "Our international subscription, billed at 1\u00a0200\u00a0EUR, covers unlimited documents, priority support and quarterly statements."
      ],
      "font": "DejaVuSans",
      "font_size": 11.0,
      "align": "justify",
      "leading": 15.0
    },
    {
      "type": "rect",
      "rect": {
        "llx": 80.0,
        "lly": 650.0,
        "urx": 230.0,
        "ury": 740.0
      },
      "stroke": {
        "width": 0.5,
        "color": [
          0.8,
          0.8,
          0.8
        ]
      }
    },
    {
      "type": "text",
      "rect": {
        "llx": 80.0,
        "lly": 590.4,
        "urx": 480.0,
        "ury": 600.0
      },
      "content": [
        "With soft hyphens: the long words break, each break drawing a hyphen."
      ],
      "font": "DejaVuSans",
      "font_size": 8.0
    },
    {
      "type": "text",
      "rect": {
        "llx": 80.0,
        "lly": 490.0,
        "urx": 230.0,
        "ury": 580.0
      },
      "content": [
        "Our inter\u00adnational sub\u00adscription, billed at 1\u00a0200\u00a0EUR, covers unlimited docu\u00adments, prior\u00adity support and quarterly state\u00adments."
      ],
      "font": "DejaVuSans",
      "font_size": 11.0,
      "align": "justify",
      "leading": 15.0
    },
    {
      "type": "rect",
      "rect": {
        "llx": 80.0,
        "lly": 490.0,
        "urx": 230.0,
        "ury": 580.0
      },
      "stroke": {
        "width": 0.5,
        "color": [
          0.8,
          0.8,
          0.8
        ]
      }
    }
  ]
}