The typographic niceties of a font

Turn on ligatures, small capitals, oldstyle figures or kerning for a font, under a new name of its own.

Summary

A good font hides refinements that books have used for centuries. Some pairs of letters are drawn in one stroke so they do not bump into each other. Capitals can be small, the height of lowercase letters, for a quiet heading. Figures can rise and fall like letters instead of standing all in a row. And the space between two letters can close up where the font asks for it. Each of these sits in the font file already, switched off until you ask for it.

Technically

Written at the top level of a request, under "font_variants"

font_variants builds one more font from another, with the OpenType features turned on — ligatures, small capitals, oldstyle figures, kerning — and makes it available under its own name. The original font stays as it is: both live side by side in the same request. The four features turn on separately, which is what lets the same text be shown with and without. The base font is an embedded font, a client font or one from the font store.

Request schema

  • font_variants — array, optional, empty by default.
  • font_variants[].name — string, required. The variant's name.
  • font_variants[].from — string, required. The name of the original font: an embedded font (fonts), a client font, or one from the font store.
  • font_variants[].ligatures — boolean, optional, false by default. Joins the pairs of letters the font draws as one shape.
  • font_variants[].small_capitals — boolean, optional, false by default. Draws lowercase letters as small capitals.
  • font_variants[].oldstyle_figures — boolean, optional, false by default. Draws figures rising and falling like lowercase letters.
  • font_variants[].kerning — boolean, optional, false by default. Closes up each pair by what the font says about it.

What the variant delivers rests on the tables the font carries: a font with no ligature table draws the same text as its base. A name another font already goes by is refused.

A whole request that creates a PDF

One name below stands for a font file: put the encoded file in its place, or send the file itself beside the description, as a supplied part of the same call. One page carries a real font already encoded, and its request posts as it stands.

{
  "fonts": [{ "name": "body", "data": "PASTE_THE_FONT_FILE_BASE64_HERE" }],
  "font_variants": [
    { "name": "body_small_capitals", "from": "body", "small_capitals": true }
  ],
  "items": [
    {
      "type": "text",
      "rect": { "llx": 60, "lly": 740, "urx": 535, "ury": 765 },
      "content": ["Chapter one"],
      "font": "body_small_capitals",
      "font_size": 16
    }
  ]
}

The line that sends it, in three languages

The fonts

Carrying a font inside the document The older Type 1 font programs The fourteen fonts all reading software owns A font whose letters you draw yourself A backup font for the rarer signs Fonts whose letters cost one byte

Where to go next

Every JSON key of a request, in one page The other forty-one settings of a request

See the prices See the examples