phenx/php-font-lib
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
The phenx/php-font-lib is a unique PHP library designed to read, parse, export, and make subsets of different types of font files. It supports numerous font types, including TrueType, OpenType (with TrueType glyphs), and WOFF font files. The library also provides functionality for extracting basic and advanced information from the font files. You can garner details about the font's name, style, horizontal metrics, glyph names, glyph shapes, and much more. Additionally, the tool allows users to create an Adobe Font Metrics (AFM) file from a particular font. This project was born out of the need to read font files in the DOMPDF project.
To utilize the phenx/php-font-lib in your code, you first need to load the desired font file using the \FontLib\Font::load()
function, followed by the parse()
method. After you've loaded and parsed the font file, you can extract a plethora of font details using available methods.
Here is a simple example that shows how to use this package:
$font = \FontLib\Font::load('../../fontfile.ttf');
$font->parse();
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>';
Make sure to replace '../../fontfile.ttf'
with the actual path of your font file.
The documentation for phenx/php-font-lib can be found on their GitHub repository under the README file. Comprehensive details on how the library works, the specifications it follows, and examples of how to use it can be found here. However, to interactively explore the library and directly visualize its capabilities, users can visit: php-font-lib demo GUI.