PHP code example of atelier / text

1. Go to this page and download the library: Download atelier/text 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/ */

    

atelier / text example snippets


echo SvgText::fromFile('Inter-Regular.woff2')->path('Hello', size: 72)->d();

use Atelier\Text\SvgText;

$path = SvgText::fromFile(__DIR__.'/fonts/Inter-Regular.woff2')
    ->path('Hello', size: 72, baselineY: 84);

echo '<svg viewBox="0 0 240 100" xmlns="http://www.w3.org/2000/svg">';
echo '<path d="'.htmlspecialchars($path->d(), \ENT_QUOTES).'" />';
echo '</svg>';

$svg = SvgText::fromFile(__DIR__.'/fonts/Inter-Regular.woff2')
    ->svg('Hello', size: 72, idPrefix: 'headline');

echo $svg->toPrettyString();

use Alto\Font\FontFinder;
use Alto\Font\FontQuery;
use Atelier\Text\SvgText;

$finder = FontFinder::fromDirectories(__DIR__.'/fonts');

$font = SvgText::fromFinder($finder, FontQuery::family('Inter')->weight(700));
$path = $font->path('Hello', size: 72);
bash
php examples/woff2-demo.php