PHP code example of xenocrat / sfnt2woff

1. Go to this page and download the library: Download xenocrat/sfnt2woff library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xenocrat / sfnt2woff example snippets

 php
$sfnt2woff = new \xenocrat\sfnt2woff();
$sfnt = file_get_contents("font.ttf");
$sfnt2woff->sfnt_import($sfnt);
$woff = $sfnt2woff->woff1_export();
file_put_contents("font.woff", $woff);
 php
$sfnt2woff = new \xenocrat\sfnt2woff();
$sfnt = file_get_contents("font.ttf");
$sfnt2woff->sfnt_import($sfnt);
$woff = $sfnt2woff->woff2_export();
file_put_contents("font.woff2", $woff);
 php
public sfnt2woff::woff1_export(
    int $compression_level = -1
): string|false
 php
public sfnt2woff::woff2_export(
    int $compression_level = -1
): string|false
 php
public sfnt2woff::woffc_export(
    int $compression_level = -1
): string|false
 php
public sfnt2woff::get_woff_version(
): array
 php
public sfnt2woff::get_woff_meta(
): object|false
 php
public sfnt2woff::get_woff_priv(
): string|false
 php
public sfnt2woff::get_sfnt_info(
): array|false
 php
public sfnt2woff::get_otfc_info(
): array|false