Skip to content

Repository files navigation

tc-lib-unicode-data

Unicode data tables and constants used by the Tecnick text stack.

Latest Stable Version Build Coverage License Downloads

Sponsor on GitHub

💖 Part of the tc-lib-pdf / TCPDF ecosystem (100M+ installs). Sponsor its maintenance →


Overview

tc-lib-unicode-data is a data-centric package that provides Unicode lookup tables, mappings, and constants consumed by tc-lib-unicode and related libraries.

It externalizes large Unicode datasets into a dedicated package so runtime libraries can stay focused on algorithms instead of data distribution. Versioned data updates also become easier to manage and review as Unicode standards evolve.

Namespace \Com\Tecnick\Unicode\Data
Author Nicola Asuni info@tecnick.com
License GNU LGPL v3 - see LICENSE
API docs https://tcpdf.org/docs/srcdoc/tc-lib-unicode-data
Packagist https://packagist.org/packages/tecnickcom/tc-lib-unicode-data

Features

Data Coverage

  • Unicode property and identity constants
  • Script/category mapping data
  • Bracket, mirroring, and shaping-related tables

Integration Role

  • Runtime dependency for higher-level Unicode processing
  • Pure data distribution, no heavy runtime logic
  • Deterministic, versioned updates

Unicode data

Arabic, Bracket, Mirror, Pattern and Type are generated from the Unicode Character Database; Type::UNICODE_VERSION reports the version they derive from.

Class UCD source Content
Type extracted/DerivedBidiClass.txt Bidi_Class of every code point (UAX #9)
Pattern extracted/DerivedBidiClass.txt Regular expressions matching right-to-left and Arabic text
Mirror BidiMirroring.txt Bidi_Mirroring_Glyph values used by rule L4
Bracket BidiBrackets.txt Paired brackets used by rule N0
Arabic ArabicShaping.txt, UnicodeData.txt Joining types, presentation forms and ligatures

Type::UNI only lists the code points whose Bidi_Class is not L; Type::getType() resolves any code point, including the blocks whose unassigned code points default to R, AL or ET.

\Com\Tecnick\Unicode\Data\Type::getType(0x05D0);          // 'R'
\Com\Tecnick\Unicode\Data\Type::getBidiClass(0x0660);     // BidiClass::AN
\Com\Tecnick\Unicode\Data\Arabic::getJoiningType(0x0628); // 'D'

To rebuild the tables from a newer UCD release:

make gendata UCDVERSION=17.0.0
make qa

Upgrading from 2.x

  • Type::UNI no longer contains the code points whose Bidi_Class is L: read it through Type::getType() instead of Type::UNI[$ord] ?? $fallback.
  • Type::getBidiClass() returns BidiClass::L for the code points that are not listed, and null only for the explicit formatting codes (LRE, LRO, RLE, RLO, PDF, LRI, RLI, FSI, PDI).
  • Pattern::RTL and Pattern::ARABIC are code point based (u modifier) and require a valid UTF-8 subject.
  • Mirror::UNI follows BidiMirroring.txt: the quotation marks U+2018, U+2019, U+201C, U+201D, U+301D and U+301E are no longer mirrored.
  • Arabic::SUBSTITUTE rows always hold the four [isolated, final, initial, medial] forms, repeating the isolated and final ones where the letter has no initial or medial form.
  • Arabic::END is derived from the Joining_Type property and now lists every character that does not join to the following one.
  • Arabic::JOINING and Arabic::getJoiningType() expose the Joining_Type property.

Requirements

  • PHP 8.2 or later
  • Composer

Installation

composer require tecnickcom/tc-lib-unicode-data

Quick Start

<?php

require_once __DIR__ . '/vendor/autoload.php';

echo md5(\Com\Tecnick\Unicode\Data\Identity::CIDHMAP);

Development

make deps
make help
make qa

Packaging

make rpm
make deb

For system packages, bootstrap with:

require_once '/usr/share/php/Com/Tecnick/Unicode/Data/autoload.php';

Contributing

Contributions are welcome. Please review CONTRIBUTING.md, CODE_OF_CONDUCT.md, and SECURITY.md.

About

PHP library containing UTF-8 font definitions

Resources

Code of conduct

Contributing

Security policy

Stars

5 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages