An editable Unicode comparison worksheet for short text lessons. Change the two sample strings, their labels, explanations and notes; recompile to regenerate the code-point labels, UTF-16 code-unit counts and grapheme-cluster counts beside them.
This is a small teaching layout, not a Unicode database, text sanitizer or font coverage checker. It uses Typst’s string segmentation. Counts concern the source string, not the glyphs drawn by a font. There are no external package dependencies.
Start a worksheet
Requires Typst 0.15.0 or newer. After registry acceptance:
typst init @preview/punipo-text-lab:0.1.0 my-lesson
cd my-lesson
typst compile main.typ
For a local checkout before acceptance, place this directory at
LOCAL/preview/punipo-text-lab/0.1.0, then pass --package-path LOCAL to both
typst init and typst compile. Do not assume that an open registry PR is an
available registry release.
The initialized example is one A4 page with three comparisons: SPACE versus
NO-BREAK SPACE, precomposed versus combining acute, and text with/without ZERO
WIDTH SPACE. It uses compiler-bundled fonts and also compiles with
--ignore-system-fonts.
Make a different lesson
This complete example changes the text, titles, explanations, note, footer and
code-point notation. 0x is an alternative hexadecimal prefix, not different data.
#import "@preview/punipo-text-lab:0.1.0": text-lab, compare
#show: text-lab.with(
title: "My accent lesson",
subtitle: "Compare a word with two encodings of its final letter.",
credit: [My class],
)
#compare(
"A word, two sequences",
"café", "cafe\u{0301}",
left-label: "Precomposed", right-label: "Combining",
prefix: "0x",
explanation: [Four grapheme clusters each; four versus five code points.],
note: [The labels and counts update from the strings, not from this prose.],
)
You must update the explanatory prose when you change its examples. The library computes labels and counts; it does not fact-check a lesson’s claims. You can edit or remove the example’s PUNIPO footer. Attribution in your generated document is not required. Use short samples: individual comparisons stay together on a page, so an extremely long sample or explanation may exceed the page height. New scripts may need a suitable font; a missing glyph does not change the computed sequence.
API
inspect-string(value, prefix: "U+")returns a dictionary withlabels(array of hexadecimal strings),codepoints,utf16, andgraphemes. Empty text has zero counts and an empty label array.compare(title, left, right, left-label: "A", right-label: "B", explanation: [], note: [], prefix: "U+", accent: rgb("176F77"))renders an unbroken comparison panel. The two samples must be strings; the prose is content.text-lab(body, title: "Unicode, side by side", subtitle: "Change a string. Rebuild the sheet. Inspect what changed.", credit: [PUNIPO · Text Lab], paper: "a4", font: "Libertinus Serif", font-size: 11pt, accent: rgb("176F77"))supplies the page layout as a show rule. Code-point labels use the bundled DejaVu Sans Mono.Clusterson the sheet means grapheme clusters, andUTF-16means code units.
Related packages and scope
- unichar looks up character information from the Unicode Character Database. This package compares complete short strings and lays out editable explanations without bundling a database.
- simple-cheatsheet offers a general compact multicolumn sheet. This package specializes in paired text samples with recomputed sequence labels and counts.
- cartao lays out printable question, hint and answer cards. This package puts both sequences and their diagnostics together for an explained comparison.
These are different uses, not claims that other packages cannot be extended to make similar documents.
Sources and authorship
Created for PUNIPO by Codex, an AI assistant acting with the PUNIPO operator’s
authorization. The package is maintained through kanitabetakunai. It is not an
official Typst or Unicode Consortium package.
The teaching topic follows PUNIPO’s earlier MIT reference cards and spacing reference. No SVG, XML, Excalidraw drawing, font or code from those assets is embedded here. Their original MIT licenses remain unchanged. This package’s Typst implementation, editable example and prose were written for this package.
Technical references: Typst strings, Unicode line breaking, grapheme segmentation and normalization.
Licenses
lib.typand this README: MIT, copyright 2026 PUNIPO.template/main.typ,typst.toml, and the generatedthumbnail.png: MIT-0, copyright 2026 PUNIPO. Normal use, editing and redistribution of the initialized template and generated lessons do not require an attribution notice.- The full terms for both licenses are in LICENSE. No old MIT drawing has been relabeled as MIT-0. Compiler-bundled fonts are used for rendering but are not distributed as package files.