Fonts Whose Signs Come Out in Colour
Set the signs a colour font paints in layers in the colours of its palette, while the text around them stays text.
See It in a Real PDF
A tick, a cross and a dash drawn by the program, added to the document as a font, and set among ordinary words.
Summary
Some font files hold signs painted in several colours: a star, a flag, a warning sign. Each is a stack of flat shapes laid one over the other, each filled with a colour from a palette the file holds, and some files hold several palettes. You name the characters you want in colour, and they come out on the page as the file paints them; every other letter of the same line comes out in the plain face, and the whole line can still be selected, copied and searched.
Technically
Written at the top level of a request, under
"color_fonts"
color_fonts builds, from a font already declared, a font items draw with by a name of its own. The file it is made from paints some of its glyphs, in its COLR table, as stacks of flat coloured layers, and holds in its CPAL table the palettes those layers are filled from. Each character of characters the file paints in colour is drawn by a font of drawings the document carries beside the face, which fills the outline of each layer, the bottom one first, with the colour the palette gives it; a layer the file paints in the text colour takes the colour in force where the text is shown. Every other character — left out of characters, with no glyph, or painted in no colour — is drawn by the plain face. The text stays selectable and searchable. Only layered colour is painted, COLR version 0: signs that are pictures, and colour with gradients, are not.
Request Schema
-
color_fonts— array, optional, empty by default. -
color_fonts[].name— string, required. The name items draw with this font by. -
color_fonts[].from— string, required. The name of the font it is made from: one the request embeds infonts, one of the client's own, one from the font store. Never one ofstandard_fonts: those fourteen fonts travel outside the file, so there is no file to read colours from. -
color_fonts[].characters— string, required. The characters drawn in colour, wherever the file paints them. -
color_fonts[].palette— integer, optional. The number of the palette the colours come from, counting from 0. Absent, the colours come from palette 0, and a file holding no palette paints nothing in colour. A number past the palettes the file holds is refused, and the answer says how many it holds.
Scope: the name declared, and it alone. The font it is made from stays reachable under its own name, unchanged. Two fonts made from one file, each with its own palette, set the same sign in two sets of colours on one line.
A font declared under the name it is made from, or under a name another font already answers to, is refused, and so is a file whose colour tables cannot be read. A file the request carries is a font of the client's own, and needs the same entitlement.
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" },
{ "name": "signs-file", "data": "PASTE_THE_COLOUR_FONT_FILE_BASE64_HERE" }
],
"color_fonts": [
{ "name": "signs", "from": "signs-file", "characters": "★⚑" },
{
"name": "signs-dark",
"from": "signs-file",
"characters": "★",
"palette": 1
}
],
"items": [
{
"type": "text",
"rect": { "llx": 72, "lly": 700, "urx": 523, "ury": 740 },
"content": [
{ "text": "★", "font": "signs" },
" Approved, ",
{ "text": "⚑", "font": "signs" },
" Flagged"
],
"font": "body",
"font_size": 18,
"color": [0, 0, 0]
},
{
"type": "text",
"rect": { "llx": 72, "lly": 650, "urx": 523, "ury": 690 },
"content": [{ "text": "★", "font": "signs-dark" }, " Approved"],
"font": "body",
"font_size": 18,
"color": [0, 0, 0]
}
]
}
The fonts
Carrying a Font inside the Document The Older Type 1 Font Programs The Fourteen Fonts All Reading Software Owns The Typographic Niceties of a Font A Font Whose Letters You Draw Yourself A Backup Font for the Rarer Signs Fonts Whose Letters Cost One Byte Fonts the Document Names without Carrying A Font Whose Makers Forbid Carrying It Fonts Carried Whole
Where to Go Next
Every JSON key of a request, in one page The other forty-one settings of a request