u

unichar

@preview

A partial port of the Unicode Character Database.

v0.4.0
MIT AND Unicode-3.0
5 downloads

Package Information

Last Updated
Minimum Typst Version
0.14.0
Authors
Malo
Categories
scriptingintegration

1. Get the package

Download the package using the TPIX CLI:

tpix get @preview/unichar:0.4.0

2. Import in your Typst file

Add this to your .typ file:

#import "@preview/unichar:0.4.0": *

Version History

0.4.00.14.0
fe25d22b178b...
0.3.20.14.0
227fbe57c30e...
0.3.10.14.0
2981b0ada935...
0.3.00.11.0
876a7e766f52...
0.2.00.11.0
f45b8cd0cd80...
0.1.00.11.0
bae5c053c767...

Unichar

This package ports part of the Unicode Character Database to Typst. Notably, it includes information from UnicodeData.txt and Blocks.txt.

Usage

This package defines a single function: codepoint. It lets you get the information related to a specific codepoint. The codepoint can be specified as a string containing a single character, or with its value.

#codepoint("√").name \
#codepoint(sym.times).block.name \
#codepoint(0x00C9).general-category \
#codepoint(sym.eq).math-class \
#codepoint("⧖").info.aliases

Result of the code example: SQUARE ROOT // Latin-1 Supplement // Lu // relation // ("vertical bowtie", "white framus")

You can display a codepoint in the style of Template:Unichar using the show entry:

#codepoint(sym.aleph).show \
#codepoint(sym.angzarr).show \
#codepoint(0x1249).show \
#codepoint(0x100000).show

Result of the code example: Each codepoint is displayed using the "U+" syntax followed by a representative glyph and the symbol name in small capitals, or relevant information inside chevrons if the codepoint does not have a name.

Changelog

Version 0.4.0

  • Properly isolate text in codepoint show rule.
  • Provide informative aliases from NamesList.txt under codepoint(..).info.aliases.
  • Math classes now use their Typst names.
  • Use a Wasm plugin.

Version 0.3.2

  • Fix a bug where some information would not be retrieved properly.

Version 0.3.1

  • Improve codepoint show rule.
  • Fix a panic occurring when using a codepoint that does not belong to a block.
  • Update to Unicode 17.0.0.

Version 0.3.0

  • Add math-class attribute to codepoints.
    • Some codepoints have their math class overridden by Typst. This is the Unicode math class, not the one used by Typst.
  • The id of codepoints now returns a string without the "U+" prefix.

Version 0.2.0

  • Codepoints now have an id attribute which is its corresponding "U+xxxx" string.
  • The block attribute of a codepoint now contains a name, a start, and a size.
  • Fix an issue that made some codepoints cause a panic.
  • Include data from NameAlias.txt.

Version 0.1.0

  • Add the codepoint function.