PHPackages                             forlabs/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. forlabs/php-font-lib

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

forlabs/php-font-lib
====================

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

0.1.0(3y ago)0231LGPL-3.0PHP

Since May 15Pushed 3y agoCompare

[ Source](https://github.com/dpiquet/php-font-lib)[ Packagist](https://packagist.org/packages/forlabs/php-font-lib)[ Docs](https://github.com/PhenX/php-font-lib)[ RSS](/packages/forlabs-php-font-lib/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (1)Versions (2)Used By (1)

[![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

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

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

1145d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4688628?v=4)[Damien PIQUET](/maintainers/dpiquet)[@dpiquet](https://github.com/dpiquet)

---

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 (9 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)")[![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)")[![chumanfu](https://avatars.githubusercontent.com/u/2536603?v=4)](https://github.com/chumanfu "chumanfu (2 commits)")[![uname-a40](https://avatars.githubusercontent.com/u/280461746?v=4)](https://github.com/uname-a40 "uname-a40 (2 commits)")[![lonnylot](https://avatars.githubusercontent.com/u/656791?v=4)](https://github.com/lonnylot "lonnylot (1 commits)")[![Magoja](https://avatars.githubusercontent.com/u/4168858?v=4)](https://github.com/Magoja "Magoja (1 commits)")[![michaeldyrynda](https://avatars.githubusercontent.com/u/558441?v=4)](https://github.com/michaeldyrynda "michaeldyrynda (1 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)")[![TimWolla](https://avatars.githubusercontent.com/u/209270?v=4)](https://github.com/TimWolla "TimWolla (1 commits)")[![amacneil](https://avatars.githubusercontent.com/u/637671?v=4)](https://github.com/amacneil "amacneil (1 commits)")[![winternet-studio](https://avatars.githubusercontent.com/u/5200270?v=4)](https://github.com/winternet-studio "winternet-studio (1 commits)")[![barryvdh](https://avatars.githubusercontent.com/u/973269?v=4)](https://github.com/barryvdh "barryvdh (1 commits)")[![ceeram](https://avatars.githubusercontent.com/u/111448?v=4)](https://github.com/ceeram "ceeram (1 commits)")[![chris-at-netshake](https://avatars.githubusercontent.com/u/19650557?v=4)](https://github.com/chris-at-netshake "chris-at-netshake (1 commits)")

### Embed Badge

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

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

###  Alternatives

[misd/linkify

Converts URLs and email addresses in text into HTML links

1163.2M12](/packages/misd-linkify)[n98/junit-xml

JUnit XML Document generation library

169.0M10](/packages/n98-junit-xml)

PHPackages © 2026

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