https://github.com/xenocrat/sfnt2woff
A PHP class for converting OTF/TTF files to WOFF.
https://github.com/xenocrat/sfnt2woff
converter font otf php ttf woff
Last synced: about 2 months ago
JSON representation
A PHP class for converting OTF/TTF files to WOFF.
- Host: GitHub
- URL: https://github.com/xenocrat/sfnt2woff
- Owner: xenocrat
- License: bsd-3-clause
- Created: 2019-06-06T17:48:05.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-11-24T11:14:55.000Z (7 months ago)
- Last Synced: 2025-04-22T22:07:34.488Z (about 2 months ago)
- Topics: converter, font, otf, php, ttf, woff
- Language: PHP
- Homepage:
- Size: 38.1 KB
- Stars: 18
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
## What is this?
sfnt2woff is a PHP class for converting OTF/TTF files to WOFF.
## Requirements
* PHP 8.0+
* ZLIB extension## Usage
Convert a font to WOFF:
$sfnt2woff = new \xenocrat\sfnt2woff();
$sfnt = file_get_contents("font.ttf");
$sfnt2woff->import($sfnt);
$woff = $sfnt2woff->export();
file_put_contents("font.woff", $woff);Import OTF/TTF font file:
$sfnt2woff->import($sfnt);
Disable the integrity test:
$sfnt2woff->strict = false;
Set the compression level (1-9):
$sfnt2woff->compression_level = 9;
Set the WOFF file version:
$sfnt2woff->version_major = 1;
$sfnt2woff->version_minor = 1;Set the extended metadata block:
$xml = simplexml_load_file("example.xml");
$sfnt2woff->set_meta($xml);Set the private data block:
$string = sha1("example");
$sfnt2woff->set_priv($string);Export the WOFF font file:
$woff = $sfnt2woff->export();