@@ -8,15 +8,14 @@ This library can be used to:
8
8
* Extract advanced info (horizontal metrics, glyph names, glyph shapes, etc)
9
9
* Make an Adobe Font Metrics (AFM) file from a font
10
10
11
- You can find a demo GUI [ here] ( http://pxd.me/php-font-lib/www/font_explorer.html ) .
12
-
13
11
This project was initiated by the need to read font files in the [ DOMPDF project] ( https://github.com/dompdf/dompdf ) .
14
12
15
13
Usage Example
16
14
-------------
17
15
16
+ ### Base font information
18
17
```
19
- $font = \FontLib\Font::load('../../ fontfile.ttf');
18
+ $font = \FontLib\Font::load('fontfile.ttf');
20
19
$font->parse(); // for getFontWeight() to work this call must be done first!
21
20
echo $font->getFontName() .'<br>';
22
21
echo $font->getFontSubfamily() .'<br>';
@@ -27,3 +26,21 @@ echo $font->getFontWeight() .'<br>';
27
26
echo $font->getFontPostscriptName() .'<br>';
28
27
$font->close();
29
28
```
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