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. [PDF &amp; Document Generation](/categories/documents)
4. /
5. phppdf/tex-hyphenation

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

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

Knuth-Liang TeX hyphenation algorithm for phppdf

1.0.0(2w ago)02MITTeXPHP &gt;=8.4CI passing

Since Jul 13Pushed 2w agoCompare

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

READMEChangelog (1)Dependencies (8)Versions (2)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

41

—

FairBetter than 87% of packages

Maintenance96

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

20d ago

### 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 (4 commits)")

---

Tags

pdfhyphenationtypographytex

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### 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

[barryvdh/laravel-dompdf

A DOMPDF Wrapper for Laravel

7.3k104.2M424](/packages/barryvdh-laravel-dompdf)[tecnickcom/tcpdf

Deprecated legacy PDF engine for PHP. Use instead tecnickcom/tc-lib-pdf.

4.5k112.8M607](/packages/tecnickcom-tcpdf)[mpdf/mpdf

PHP library generating PDF files from UTF-8 encoded HTML

4.7k85.8M596](/packages/mpdf-mpdf)[knplabs/knp-snappy

PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page. Wrapper for wkhtmltopdf/wkhtmltoimage.

4.5k73.8M65](/packages/knplabs-knp-snappy)[spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

5.2k38.5M179](/packages/spatie-browsershot)[smalot/pdfparser

Pdf parser library. Can read and extract information from pdf file.

2.7k43.1M304](/packages/smalot-pdfparser)

PHPackages © 2026

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