Liberation font family bundle for
dskripchenko/php-pdf —
ships 12 TTFs (Sans / Serif / Mono × Regular / Bold / Italic /
Bold Italic) and a ready-to-use FontProvider implementation.
dskripchenko/php-pdf is MIT-licensed. The Liberation fonts ship under
the SIL Open Font License (OFL) 1.1, which is permissive and
GPL-compatible but distinct from MIT (different naming rules for
derivatives, different redistribution clauses). Keeping fonts in a
separate package:
- isolates the OFL license zone from the MIT zone;
- lets callers opt out of the ~4 MB font bundle when they ship their own fonts;
- enables future sibling packages (
php-pdf-fonts-noto,php-pdf-fonts-roboto, etc.) without changing the core.
Liberation Fonts 2.1.5 (latest stable), 12 files in assets/fonts/:
| Family | Variants |
|---|---|
| LiberationSans | Regular, Bold, Italic, BoldItalic |
| LiberationSerif | Regular, Bold, Italic, BoldItalic |
| LiberationMono | Regular, Bold, Italic, BoldItalic |
The Liberation family is metric-compatible with Microsoft's proprietary fonts — text laid out for Arial / Times New Roman / Courier New will render with the same line wrapping using the Liberation equivalent, so DOCX-input → PDF and HTML-templates → PDF workflows produce identical pagination.
Glyph coverage: full Latin (Western and Eastern European), Cyrillic, Greek, Hebrew, Arabic, and Devanagari basics.
composer require dskripchenko/php-pdf-fonts-liberationPHP 8.2+. No native extensions required.
use Dskripchenko\PhpPdf\Build\DocumentBuilder;
use Dskripchenko\PhpPdf\Layout\Engine;
use Dskripchenko\PhpPdfFontsLiberation\LiberationFontProvider;
$bytes = DocumentBuilder::new()
->heading(1, 'Annual Report')
->paragraph('Тысяча красивых символов с правильным кернингом.')
->toBytes(new Engine(fontProvider: new LiberationFontProvider));LiberationFontProvider resolves common proprietary names to their
metric-compatible Liberation equivalent automatically:
| Requested name | Resolved to |
|---|---|
Arial |
LiberationSans |
Arial-Bold |
LiberationSans-Bold |
Times New Roman |
LiberationSerif |
Times New Roman-Italic |
LiberationSerif-Italic |
Courier New |
LiberationMono |
A template that says font-family: "Times New Roman" works out of
the box.
Use Dskripchenko\PhpPdf\Font\ChainedFontProvider to stack providers
so Liberation acts as a fallback for missing glyphs:
use Dskripchenko\PhpPdf\Font\ChainedFontProvider;
use Dskripchenko\PhpPdf\Font\DirectoryFontProvider;
use Dskripchenko\PhpPdfFontsLiberation\LiberationFontProvider;
$fonts = new ChainedFontProvider([
new DirectoryFontProvider(__DIR__.'/my-brand-fonts'), // checked first
new LiberationFontProvider, // fallback
]);This package mixes two licenses:
| Zone | License |
|---|---|
src/ (PHP wrapper) |
MIT — see LICENSE |
assets/fonts/ TTFs |
SIL OFL 1.1 — see OFL.txt |
Both are permissive, GPL-compatible, and allow commercial use.
Liberation Fonts © Red Hat, Inc., Pavel Hlaváč, and others. Upstream: https://github.com/liberationfonts/liberation-fonts