A library to read, parse, export and make subsets of different types of font files
Brian Sweeney 991d6a954f Set minimum PHP version to 7.1 for unit testing | 6 months ago | |
---|---|---|
.github | 6 months ago | |
maps | 13 years ago | |
src | 6 months ago | |
tests | 6 months ago | |
.gitattributes | 10 months ago | |
.gitignore | 10 months ago | |
AUTHORS.md | 6 months ago | |
LICENSE | 10 years ago | |
README.md | 10 months ago | |
SECURITY.md | 10 months ago | |
composer.json | 6 months ago | |
phpunit.xml.dist | 10 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();