PHPackages                             phppdf/tex-hyphenation - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. phppdf/tex-hyphenation

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

phppdf/tex-hyphenation
======================

Knuth-Liang TeX hyphenation algorithm for phppdf

00TeXCI passing

Since Jun 17Pushed yesterdayCompare

[ Source](https://github.com/phppdf/tex-hyphenation)[ Packagist](https://packagist.org/packages/phppdf/tex-hyphenation)[ RSS](/packages/phppdf-tex-hyphenation/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

phppdf/tex-hyphenation
======================

[](#phppdftex-hyphenation)

A pure PHP implementation of the Knuth-Liang TeX hyphenation algorithm. It splits a word into the fragments allowed at valid hyphenation points, using the same pattern format as TeX (e.g. `hy3ph`, `.ach4`).

This package implements the `PhpPdf\Text\Hyphenator` interface from [phppdf/phppdf](https://phppdf.github.io/phppdf/), so it plugs directly into `TextBox` and other phppdf text-layout components.

Requirements
------------

[](#requirements)

- PHP 8.4+
- `ext-mbstring`

Installation
------------

[](#installation)

```
composer require phppdf/tex-hyphenation
```

Usage
-----

[](#usage)

`TeXHyphenator` is constructed with an array of raw TeX pattern strings. Bundled pattern files for several locales are included under `resources/hyphenation/`:

```
use PhpPdf\Text\TeXHyphenator;

$patterns = file(
    __DIR__ . '/vendor/phppdf/tex-hyphenation/resources/hyphenation/en-US.tex',
    FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES,
) ?: [];

$hyphenator = new TeXHyphenator($patterns);

$hyphenator->breakWord('hyphenation'); // ['hy', 'phen', 'a', 'tion']
```

The result is a list of fragments; join consecutive fragments with a hyphen wherever a line break is needed.

### Minimum margins

[](#minimum-margins)

`leftMin` and `rightMin` control how many characters must remain before the first break and after the last break, respectively (TeX defaults: 2 and 3):

```
$hyphenator = new TeXHyphenator($patterns, leftMin: 3, rightMin: 3);
```

### Bundled locales

[](#bundled-locales)

LocaleFile`af-ZA``resources/hyphenation/af-ZA.tex``en-GB``resources/hyphenation/en-GB.tex``en-US``resources/hyphenation/en-US.tex``en-ZA``resources/hyphenation/en-ZA.tex``es-ES``resources/hyphenation/es-ES.tex``fr-FR``resources/hyphenation/fr-FR.tex``nl-NL``resources/hyphenation/nl-NL.tex`### Use with phppdf

[](#use-with-phppdf)

```
use PhpPdf\Builder\TextBox;
use PhpPdf\Text\TeXHyphenator;

$box = TextBox::create($text, $metrics, 12, 200.0, hyphenator: new TeXHyphenator($patterns));
```

License
-------

[](#license)

MIT

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance65

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/0ee7f711ef4d45ada0ac92c7ab2f548055a7cfbe718da6c4bbb81b2f6693c528?d=identicon)[waltertamboer](/maintainers/waltertamboer)

---

Top Contributors

[![waltertamboer](https://avatars.githubusercontent.com/u/508054?v=4)](https://github.com/waltertamboer "waltertamboer (2 commits)")

### Embed Badge

![Health badge](/badges/phppdf-tex-hyphenation/health.svg)

```
[![Health](https://phpackages.com/badges/phppdf-tex-hyphenation/health.svg)](https://phpackages.com/packages/phppdf-tex-hyphenation)
```

###  Alternatives

[mck89/peast

Peast is PHP library that generates AST for JavaScript code

19037.7M41](/packages/mck89-peast)[karriere/json-decoder

JsonDecoder implementation that allows you to convert your JSON data into PHP class objects

140439.4k12](/packages/karriere-json-decoder)[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9642.0k](/packages/sauladam-shipment-tracker)[jstewmc/rtf

Read and write Rich Text Format (RTF) documents with PHP

46143.1k6](/packages/jstewmc-rtf)[json-mapper/laravel-package

The JsonMapper package for Laravel

25188.9k3](/packages/json-mapper-laravel-package)[jamesmoss/toml

A parser for TOML implemented in PHP.

3231.7k15](/packages/jamesmoss-toml)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
