Tincture.Font.UnicodeRanges (Tincture v0.1.0)

Copy Markdown View Source

Mapping between Unicode codepoints and OpenType OS/2.ulUnicodeRange bits.

The OS/2 table advertises which Unicode blocks a font claims to cover as a 128-bit field, split across four 32-bit words (ulUnicodeRange1..4). Bit n is set when the font covers the block assigned to bit n.

Tincture consults this only as a fallback: when a font's cmap cannot be parsed into a usable code-to-glyph map, the OS/2 range bits are the only remaining signal for whether a given codepoint is covered.

Bit assignments follow the OpenType specification (bits 0..122; bits 123..127 are reserved). Several bits cover more than one block — bit 9 (Cyrillic), for example, spans four discontiguous ranges.

Summary

Functions

Returns true when every ulUnicodeRange word is zero, meaning the font advertises no coverage at all and the field carries no information.

Returns the ulUnicodeRange bit covering codepoint, or nil if the codepoint falls outside every block with an assigned bit.

Returns true when the four ulUnicodeRange words advertise coverage of codepoint.

Functions

all_zero?(arg1)

@spec all_zero?(term()) :: boolean()

Returns true when every ulUnicodeRange word is zero, meaning the font advertises no coverage at all and the field carries no information.

bit_for_codepoint(codepoint)

@spec bit_for_codepoint(integer()) :: 0..122 | nil

Returns the ulUnicodeRange bit covering codepoint, or nil if the codepoint falls outside every block with an assigned bit.

supports_codepoint?(arg1, codepoint)

@spec supports_codepoint?({integer(), integer(), integer(), integer()}, integer()) ::
  boolean()

Returns true when the four ulUnicodeRange words advertise coverage of codepoint.

ranges is the {ulUnicodeRange1, ulUnicodeRange2, ulUnicodeRange3, ulUnicodeRange4} tuple read from the font's OS/2 table. Bits 0..31 live in word 1, bits 32..63 in word 2, and so on.