Skip to content

Commit 1f8f77e

Browse files
authored
Include more usage samples
1 parent b68fe45 commit 1f8f77e

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

README.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ This library can be used to:
88
* Extract advanced info (horizontal metrics, glyph names, glyph shapes, etc)
99
* Make an Adobe Font Metrics (AFM) file from a font
1010

11-
You can find a demo GUI [here](http://pxd.me/php-font-lib/www/font_explorer.html).
12-
1311
This project was initiated by the need to read font files in the [DOMPDF project](https://github.com/dompdf/dompdf).
1412

1513
Usage Example
1614
-------------
1715

16+
### Base font information
1817
```
19-
$font = \FontLib\Font::load('../../fontfile.ttf');
18+
$font = \FontLib\Font::load('fontfile.ttf');
2019
$font->parse(); // for getFontWeight() to work this call must be done first!
2120
echo $font->getFontName() .'<br>';
2221
echo $font->getFontSubfamily() .'<br>';
@@ -27,3 +26,21 @@ echo $font->getFontWeight() .'<br>';
2726
echo $font->getFontPostscriptName() .'<br>';
2827
$font->close();
2928
```
29+
30+
### Font Metrics Generation
31+
```
32+
$font = FontLib\Font::load('fontfile.ttf');
33+
$font->parse();
34+
$font->saveAdobeFontMetrics('fontfile.ufm');
35+
```
36+
37+
### Create a font subset
38+
```
39+
$font = FontLib\Font::load('fontfile.ttf');
40+
$font->setSubset("abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ.:,;' (!?)+-*/== 1234567890"); // characters to include
41+
$font->reduce();
42+
touch('fontfile.subset.ttf');
43+
$font->open('fontfile.subset.ttf', FontLib\BinaryStream::modeReadWrite);
44+
$font->encode(array("OS/2"));
45+
$font->close();
46+
```

0 commit comments

Comments
 (0)