PHPackages                             dompdf/php-font-lib - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. dompdf/php-font-lib

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

dompdf/php-font-lib
===================

A library to read, parse, export and make subsets of different types of font files.

1.0.2(4mo ago)1.8k40.2M↓12.3%255[16 issues](https://github.com/dompdf/php-font-lib/issues)[7 PRs](https://github.com/dompdf/php-font-lib/pulls)7LGPL-2.1-or-laterPHPPHP ^7.1 || ^8.0CI passing

Since Nov 13Pushed 4mo ago25 watchersCompare

[ Source](https://github.com/dompdf/php-font-lib)[ Packagist](https://packagist.org/packages/dompdf/php-font-lib)[ Docs](https://github.com/dompdf/php-font-lib)[ RSS](/packages/dompdf-php-font-lib/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (10)Dependencies (1)Versions (19)Used By (7)

[![PHPUnit tests](https://github.com/dompdf/php-font-lib/actions/workflows/phpunit.yml/badge.svg)](https://github.com/dompdf/php-font-lib/actions/workflows/phpunit.yml)

PHP Font Lib
============

[](#php-font-lib)

This library can be used to:

- Read TrueType, OpenType (with TrueType glyphs), WOFF font files
- Extract basic info (name, style, etc)
- Extract advanced info (horizontal metrics, glyph names, glyph shapes, etc)
- Make an Adobe Font Metrics (AFM) file from a font

This project was initiated by the need to read font files in the [DOMPDF project](https://github.com/dompdf/dompdf).

Usage Example
-------------

[](#usage-example)

### Base font information

[](#base-font-information)

```
$font = \FontLib\Font::load('fontfile.ttf');
$font->parse();  // for getFontWeight() to work this call must be done first!
echo $font->getFontName() .'';
echo $font->getFontSubfamily() .'';
echo $font->getFontSubfamilyID() .'';
echo $font->getFontFullName() .'';
echo $font->getFontVersion() .'';
echo $font->getFontWeight() .'';
echo $font->getFontPostscriptName() .'';
$font->close();
```

### Font Metrics Generation

[](#font-metrics-generation)

```
$font = FontLib\Font::load('fontfile.ttf');
$font->parse();
$font->saveAdobeFontMetrics('fontfile.ufm');
```

### Create a font subset

[](#create-a-font-subset)

```
$font = FontLib\Font::load('fontfile.ttf');
$font->parse();
$font->setSubset("abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ.:,;' (!?)+-*/== 1234567890"); // characters to include
$font->reduce();
touch('fontfile.subset.ttf');
$font->open('fontfile.subset.ttf', FontLib\BinaryStream::modeReadWrite);
$font->encode(array("OS/2"));
$font->close();
```

###  Health Score

71

—

ExcellentBetter than 100% of packages

Maintenance74

Regular maintenance activity

Popularity78

Solid adoption and visibility

Community42

Growing community involvement

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 50.8% 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

Every ~301 days

Recently: every ~185 days

Total

17

Last Release

140d ago

Major Versions

0.5.6 → 1.0.02024-04-29

### Community

Maintainers

![](https://www.gravatar.com/avatar/7300b27cf32acabfa6335244ecda3f65760b4865d290837a7170f8e25b436c83?d=identicon)[bsweeney](/maintainers/bsweeney)

---

Top Contributors

[![PhenX](https://avatars.githubusercontent.com/u/42170?v=4)](https://github.com/PhenX "PhenX (99 commits)")[![bsweeney](https://avatars.githubusercontent.com/u/485897?v=4)](https://github.com/bsweeney "bsweeney (35 commits)")[![mondrake](https://avatars.githubusercontent.com/u/1174864?v=4)](https://github.com/mondrake "mondrake (9 commits)")[![BernardoSilva](https://avatars.githubusercontent.com/u/1537510?v=4)](https://github.com/BernardoSilva "BernardoSilva (8 commits)")[![williamdes](https://avatars.githubusercontent.com/u/7784660?v=4)](https://github.com/williamdes "williamdes (7 commits)")[![8ctopus](https://avatars.githubusercontent.com/u/13252042?v=4)](https://github.com/8ctopus "8ctopus (4 commits)")[![pocketarc](https://avatars.githubusercontent.com/u/5393?v=4)](https://github.com/pocketarc "pocketarc (4 commits)")[![u01jmg3](https://avatars.githubusercontent.com/u/1266205?v=4)](https://github.com/u01jmg3 "u01jmg3 (3 commits)")[![uname-a40](https://avatars.githubusercontent.com/u/280461746?v=4)](https://github.com/uname-a40 "uname-a40 (2 commits)")[![ren1244](https://avatars.githubusercontent.com/u/15166082?v=4)](https://github.com/ren1244 "ren1244 (2 commits)")[![chumanfu](https://avatars.githubusercontent.com/u/2536603?v=4)](https://github.com/chumanfu "chumanfu (2 commits)")[![BuslikDrev](https://avatars.githubusercontent.com/u/32706609?v=4)](https://github.com/BuslikDrev "BuslikDrev (2 commits)")[![OlegKunitsyn](https://avatars.githubusercontent.com/u/2870028?v=4)](https://github.com/OlegKunitsyn "OlegKunitsyn (1 commits)")[![PaolaRuby](https://avatars.githubusercontent.com/u/79208489?v=4)](https://github.com/PaolaRuby "PaolaRuby (1 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")[![PowerKiKi](https://avatars.githubusercontent.com/u/72603?v=4)](https://github.com/PowerKiKi "PowerKiKi (1 commits)")[![TimWolla](https://avatars.githubusercontent.com/u/209270?v=4)](https://github.com/TimWolla "TimWolla (1 commits)")[![winternet-studio](https://avatars.githubusercontent.com/u/5200270?v=4)](https://github.com/winternet-studio "winternet-studio (1 commits)")[![Xxx-Bin](https://avatars.githubusercontent.com/u/16422604?v=4)](https://github.com/Xxx-Bin "Xxx-Bin (1 commits)")[![amacneil](https://avatars.githubusercontent.com/u/637671?v=4)](https://github.com/amacneil "amacneil (1 commits)")

---

Tags

extractfontfont-filesphptruetypettfwoff

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dompdf-php-font-lib/health.svg)

```
[![Health](https://phpackages.com/badges/dompdf-php-font-lib/health.svg)](https://phpackages.com/packages/dompdf-php-font-lib)
```

PHPackages © 2026

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