Back to Vicinae

libglyph

src/lib/glyph/README.md

0.27.11.8 KB
Original Source

libglyph

A static table of emoji and curated Unicode symbols, plus emoji-specific helpers.

  • glyph/glyph.hpp — the table and lookups (glyph::).
  • glyph/emoji.hpp — emoji-only helpers: skin tones, segmentation, detection (emoji::).

Generated data

src/glyph.cpp, include/glyph/glyph.hpp and src/emoji-properties.cpp are generated by scripts/ from the Unicode Character Database, emoji-test/emoji-data and the CLDR English annotations, then committed. This is not part of the build: regenerate from time to time (new Unicode/Emoji release, curation tweaks) with

sh
make gen-db   # or `make emoji` from the repo root; needs node >= 22.18 (runs TypeScript directly) and network access

scripts/fetch.ts downloads the upstream files into scripts/assets/ (gitignored) and records their versions, which scripts/gen.ts stamps into the generated files' first line. Pin a release with UNICODE_VERSION=17.0.0 / CLDR_REF=48.2.0.

What gets included is decided by scripts/src/curate.ts (symbol block allowlist and per-category routing) and scripts/src/categories.ts (the category list, which is also the source of the glyph::Category enum order). Emoji keep the canonical emoji-test order; skin-tone variants are collapsed onto their skinnable base and composed at runtime.

emoji-properties.cpp holds the emoji binary-property ranges (Emoji, Emoji_Presentation, Emoji_Modifier, Emoji_Modifier_Base) feeding lookupProperties in src/emoji-properties.hpp, keeping the lib free of any Unicode-property runtime dependency.

Emoji segmentation

Extensions may pass emoji strings as icons, so we need to tell whether an arbitrary string is an emoji. Matching against the table is not enough — it doesn't cover every sequence and variation. We use the google emoji segmenter.