Uses PHP-Typography library and exposes it as Twig Extension. See class-settings.php for possible options.
- Hyphenation — over 50 languages supported
- Space control, including:
- widow protection
- gluing values to units
- forced internal wrapping of long URLs & email addresses
- Intelligent character replacement, including smart handling of:
- quote marks (‘single’, “double”)
- dashes ( – )
- ellipses (…)
- trademarks, copyright & service marks (™ ©)
- math symbols (5×5×5=53)
- fractions (1⁄16)
- ordinal suffixes (1st, 2nd)
- CSS hooks for styling:
- ampersands,
- uppercase words,
- numbers,
- initial quotes & guillemets.
Twig Typography Extension can be easily installed using composer
composer require parisek/twig-typography
$twig = new Twig_Environment($loader);
$twig->addExtension(new Parisek\Twig\TypographyExtension(__DIR__ . '/typography.yml'));
{{ title|typography }}
<h1>{{ "Lorem Ipsum"|typography }}</h1>
{{ title|typography({'set_dewidow': FALSE}) }}
{% typography %}
<h1>Lorem Ipsum</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce ullamcorper semper nunc, a hendrerit leo auctor ultricies.
</p>
{% endtypography %}