Text Rendering Showcase
A one-page sheet of everything text can do in a document — for teams that write in several languages and want to see each one set properly before they commit to a template.
- Inline typography. Bold, italic and bold-italic; underline, strikethrough, deleted and inserted text; subscripts and superscripts; caps, colour, size, letter spacing, highlights and a link.
- An icon font. A strip of coloured icons and a glyph before each section heading, drawn from the icon face the engine ships, coloured and sized like any letter.
- Twelve writing systems. A table of native samples in Latin, Cyrillic, Greek, Arabic, Persian, Hebrew, Devanagari, Thai, Han, Japanese kana and Hangul, each shaped for its script.
- "Hello" in one paragraph. A greeting line that switches face for each language with a single
[font, …]tag. - Bidirectional columns. Three contract terms in English beside their Arabic counterparts, ordered and aligned from the right.
- An ordered list with inline tags. Italic, bold, a flagged value and an inline Arabic word inside English items.
- Plus a QR code and a circular seal whose text runs along curves in Arabic, English, Greek and Hindi.
Features used: PDF/A-2b conformance, columns, tables, lists, SVG, barcodes (qrcode), inserted and deleted text, links, Arabic, Chinese, Cyrillic, Devanagari, Greek, Hebrew, Japanese kana, Korean, Thai text
- Output
- Template
- Data
How it's built
Many scripts in one paragraph
Each script that needs a face of its own is declared once under fonts, and a [font, Family] tag switches to it for a run. The greeting line sets thirteen languages in one paragraph this way; each run is shaped for its script: Arabic letters join, Devanagari forms conjuncts, Thai stacks its marks (Fonts).
{ "document": {
"fonts": {
"Arabic": { "regular": "fonts/NotoSansArabic-Regular.ttf", "bold": "fonts/NotoSansArabic-Bold.ttf" },
"Devanagari": { "regular": "fonts/NotoSansDevanagari-Regular.ttf", "bold": "fonts/NotoSansDevanagari-Bold.ttf" },
"Thai": { "regular": "fonts/NotoSansThai-Regular.ttf", "bold": "fonts/NotoSansThai-Bold.ttf" },
"CJK": { "regular": "fonts/NotoSansCJKsc-Regular.otf", "bold": "fonts/NotoSansCJKsc-Bold.otf" } },
"content": [
{ "p": "Arabic [font, Arabic]مرحبا[/font] · Hindi [font, Devanagari]नमस्ते[/font] · Thai [font, Thai]สวัสดี[/font] · Japanese [font, CJK]こんにちは[/font]." } ] } }
Only the glyphs a document uses are embedded, so a large CJK face adds a few kilobytes, not its whole file.
Icons from a font
The coloured strip under the band and the glyph in front of the first three section headings come from the icon face the engine ships, declared by its vendored/ path. An icon is a character of that face, so it takes a colour, a size and a place in a line like any letter:
{ "document": {
"fonts": { "fa": { "regular": "vendored/fa-solid-900.otf" } },
"styles": { "iconStrip": { "fontFamily": "fa", "fontSize": 18, "color": "#0F172A" } },
"content": [
{ "p": "[color, #B91C1C]\uf1ab[/color] [color, #1D4ED8]\uf0ac[/color] [color, #15803D]\uf00c[/color]", "style": "iconStrip" },
{ "p": "[font, fa]\uf031[/font] INLINE TYPOGRAPHY" } ] } }
For icons drawn as shapes rather than characters, see the icon components.
Right-to-left beside left-to-right
The bidirectional block is a two-column columns: English terms on the left, their Arabic counterparts on the right. The Arabic column's styles set direction: "rtl" and textAlign: "right", so each paragraph is ordered and aligned from the right edge (Columns, Styles).
{ "document": {
"styles": {
"colEn": { "fontSize": 10, "color": "#1E293B", "marginBottom": 3 },
"colAr": { "fontSize": 11, "color": "#1E293B", "direction": "rtl", "textAlign": "right", "marginBottom": 3 } },
"content": [
{ "columns": { "widths": [1, 1], "gap": 26, "rows": [
[ { "p": "Payment due within 30 days of the invoice date.", "style": "colEn" } ],
[ { "p": "الدفع مستحق خلال ثلاثين يومًا من تاريخ الفاتورة.", "style": "colAr" } ] ] } } ] } }