Read, inspect, convert, and subset OpenType, TrueType, WOFF, and WOFF2 fonts in PHP.

ALTO Font reads, inspects, converts, and subsets TrueType-based font files from PHP. It exposes metadata, character coverage, glyph measurements, outlines, and variable-font data without changing the source file.

Use it to identify a font, prepare TTF, WOFF, or WOFF2 output, or create a smaller font containing the characters an application needs. Text shaping and raster rendering remain the responsibility of the application using the font.

<?php

use Alto\Font\Font;

$font = Font::fromFile(__DIR__.'/fonts/Inter-Regular.ttf');
echo null === $font->glyphIdForCodepoint(0x41) ? 'A is missing' : 'A is available';

A font containing the capital letter A prints A is available.

Documentation

  • Installation: add the package with Composer and run a smoke test.
  • Getting started: read a font installed on your machine and check that it covers your text.
  • Fonts: families, faces, and files, and what a loaded face exposes.
  • Glyphs: map characters to glyphs, measure them, and trace their outlines.
  • Files: find a font by family, read a file or bytes, write TTF, WOFF, or WOFF2.
  • Subsetting: keep the characters your application uses and check what remains.
  • Compression: choose WOFF or WOFF2 and provide Brotli.
  • Formats: supported containers and outlines, detected by signature.
  • Tables: what subsetting keeps, rewrites, or refuses inside the font.
  • Errors: the exceptions the package raises and how to recover.

Next: Installation.