PHPackages                             aklump/dompdf-fonts - 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. aklump/dompdf-fonts

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

aklump/dompdf-fonts
===================

Simplify the usage of TrueType fonts with DomPDF.

0.0.18(2y ago)1112BSD-3-ClausePHP

Since Oct 16Pushed 2y ago1 watchersCompare

[ Source](https://github.com/aklump/dompdf-fonts)[ Packagist](https://packagist.org/packages/aklump/dompdf-fonts)[ Docs](https://github.com/aklump/dompdf-fonts)[ RSS](/packages/aklump-dompdf-fonts/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (17)Used By (0)

DOMPDF Fonts
============

[](#dompdf-fonts)

I wrote this project to simplify using [custom fonts](https://github.com/dompdf/dompdf/wiki/About-Fonts-and-Character-Encoding) with [DOMPDF](https://dompdf.github.io/).

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

[](#installation)

1. `composer require aklump/dompdf-fonts`
2. Create a directory in your project to hold the source fonts and the configuration file.
3. Copy the config file found in *vendor/aklump/dompdf-fonts/dompdf-fonts.config.dist.yml* to the font folder as *dompdf-fonts.config.yml*.

### In a Drupal Module

[](#in-a-drupal-module)

#### Installation

[](#installation-1)

1. `cd my_module`
2. Install as a dev requirement: `composer require --dev aklump/dompdf-fonts`
3. `mkdir fonts`
4. `cp vendor/aklump/dompdf-fonts/dompdf-fonts.config.dist.yml fonts/dompdf-fonts.config.yml`

#### Importing

[](#importing)

1. Copy source font into `fonts/`.
2. `./vendor/bin/import.php fonts/dompdf-fonts.config.yml`

*For example:*

```
composer require aklump/dompdf-fonts
mkdir fonts
cp vendor/aklump/dompdf-fonts/dompdf-fonts.config.dist.yml fonts/dompdf-fonts.config.yml
```

Get the .ttf font files
-----------------------

[](#get-the-ttf-font-files)

1. Download one or more font families, say from
2. For use with DomPDF you only need the *.ttf* versions. Copy those to your source directory. In the examples shown below, that directory is *./fonts*.
3. You will need up to four versions of the font: normal, bold, italic and bold italic.

*Example file tree.*

```
.
├── dist
│   └── dompdf_fonts
│       ├── Merriweather--bold-italic.ttf
│       ├── Merriweather--bold-italic.ufm
│       ├── Merriweather--bold.ttf
│       ├── Merriweather--bold.ufm
│       ├── Merriweather--italic.ttf
│       ├── Merriweather--italic.ufm
│       ├── Merriweather--normal.ttf
│       ├── Merriweather--normal.ufm
│       ├── _style.scss
│       └── installed-fonts.json
└── fonts
    ├── dompdf-fonts.config.yml
    ├── Merriweather--bold-italic.ttf
    ├── Merriweather--bold.ttf
    ├── Merriweather--italic.ttf
    ├── Merriweather--normal.ttf
    └── dompdf
        └── import.php

```

Set the import configuration
----------------------------

[](#set-the-import-configuration)

1. *dompdf-fonts.config.yml* should have been copied from *dompdf-fonts.config.dist.yml* when you installed this, if not you must manually do so now.
2. Update *dompdf-fonts.config.yml* as appropriate. All paths are relative to *dompdf-fonts.config.yml*'s parent directory.

*File: \_dompdf-fonts.config.yml*

```
sources:
  - ../Merriweather*.ttf
output: ../../dist/dompdf_fonts/
```

Run the importer
----------------

[](#run-the-importer)

1. Run `php vendor/bin/import.php path/to/dompdf-fonts.config.yml` to process your fonts.
2. Inspect to make sure your output directory contains the necessary files.

Use with Dompdf instances
-------------------------

[](#use-with-dompdf-instances)

1. Set the fonts directory to match `output.path` on every new DOMPDF instance in your code. This is an example from a Drupal 9 module.

```
$options = new \Dompdf\Options();

// Determine the configuration directory by reading the import config.
$fonts_base_path = \Drupal::service('extension.list.module')
    ->getPath('my_module') . '/fonts';
$fonts_config = \Symfony\Component\Yaml\Yaml::parseFile($fonts_base_path . '/dompdf-fonts.config.yml');
$fonts_dir = realpath($fonts_base_path . '/' . $fonts_config['output']['path']);
$options->setFontDir($fonts_dir);

$dompdf = new \Dompdf\Dompdf($options);
```

Use with HTML markup
--------------------

[](#use-with-html-markup)

1. To see your font in the browser you must import the SCSS partial. When only rendering PDFs, DOMPDF does not use *\_style.scss*.

*File: my\_module/scss/\_pdf.scss*

```
@import "../dist/dompdf_fonts/style";

@mixin pdf_font_serif {
  font-family: Merriweather, Georgia, Times, "Times New Roman", serif;
}

h1 {
  @include pdf_font_serif;
}
```

Resource Links
--------------

[](#resource-links)

-
-

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

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

Every ~35 days

Recently: every ~130 days

Total

16

Last Release

780d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/79476f3b82f9c766433c7eb401cbcfc636cd5d5ccf2b2e6b50ea81d1de6c2730?d=identicon)[aklump](/maintainers/aklump)

---

Top Contributors

[![aklump](https://avatars.githubusercontent.com/u/425737?v=4)](https://github.com/aklump "aklump (50 commits)")

### Embed Badge

![Health badge](/badges/aklump-dompdf-fonts/health.svg)

```
[![Health](https://phpackages.com/badges/aklump-dompdf-fonts/health.svg)](https://phpackages.com/packages/aklump-dompdf-fonts)
```

###  Alternatives

[barryvdh/laravel-dompdf

A DOMPDF Wrapper for Laravel

7.3k87.6M274](/packages/barryvdh-laravel-dompdf)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M385](/packages/shopware-core)[sensiolabs/gotenberg-bundle

A Symfony bundle that provides seamless integration with Gotenberg for generating PDFs and screenshots from various sources (HTML, Markdown, Office documents, URLs) with a clean, builder-based API.

210210.4k2](/packages/sensiolabs-gotenberg-bundle)[easybook/easybook

Book publishing application

76011.5k](/packages/easybook-easybook)[drutiny/drutiny

This is a generic Drupal 7 and Drupal 8 site auditing and optional remediation tool.

132122.2k17](/packages/drutiny-drutiny)

PHPackages © 2026

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