A library to read, parse, export and make subsets of different types of font files
8ctopus 6137b7d423 Add php 8.4 to github action workflow | 2 weeks ago | |
---|---|---|
.github | 1 week ago | |
maps | 13 years ago | |
src | 1 week ago | |
tests | 7 months ago | |
.gitattributes | 11 months ago | |
.gitignore | 11 months ago | |
AUTHORS.md | 7 months ago | |
LICENSE | 11 years ago | |
README.md | 11 months ago | |
SECURITY.md | 11 months ago | |
composer.json | 7 months ago | |
phpunit.xml.dist | 11 months ago |
This library can be used to:
This project was initiated by the need to read font files in the DOMPDF project.
$font = \FontLib\Font::load('fontfile.ttf');
$font->parse(); // for getFontWeight() to work this call must be done first!
echo $font->getFontName() .'<br>';
echo $font->getFontSubfamily() .'<br>';
echo $font->getFontSubfamilyID() .'<br>';
echo $font->getFontFullName() .'<br>';
echo $font->getFontVersion() .'<br>';
echo $font->getFontWeight() .'<br>';
echo $font->getFontPostscriptName() .'<br>';
$font->close();
$font = FontLib\Font::load('fontfile.ttf');
$font->parse();
$font->saveAdobeFontMetrics('fontfile.ufm');
$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();