mundschenk-at/php-typography

A PHP library for improving your web typography

Package info

github.com/mundschenk-at/php-typography

pkg:composer/mundschenk-at/php-typography

Statistics

Installs: 975โ€‰173

Dependents: 13

Suggesters: 0

Stars: 78

Open Issues: 14

v6.7.0 2022-11-14 22:30 UTC

Requires

Suggests

None

Provides

None

Conflicts

None

Replaces

None

GPL-2.0-or-later 6b0414811f42e53e101f5ea5a8023c63eafd3dcb


README

๐Ÿ‘ Build Status
๐Ÿ‘ Latest Stable Version
๐Ÿ‘ Quality Gate Status
๐Ÿ‘ Coverage
๐Ÿ‘ License

A PHP library for improving your web typography:

  • 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.

Requirements

  • PHP 7.4.0 or above
  • The mbstring extension

Installation

The best way to use this package is through Composer:

$ composer require mundschenk-at/php-typography
$ vendor/bin/update-iana.php

Basic Usage

  1. Create a Settings object and enable the fixes you want.
  2. Create a PHP_Typography instance and use it to process HTML fragments (or whole documents) using your defined settings.
$settings = new \PHP_Typography\Settings();
$settings->set_hyphenation( true );
$settings->set_hyphenation_language( 'en-US' );

$typo = new \PHP_Typography\PHP_Typography();

$hyphenated_html = $typo->process( $html_snippet, $settings );

Roadmap

Please have a look at ROADMAP file for upcoming releases.

License

PHP-Typography is licensed under the GNU General Public License 2 or later - see the LICENSE file for details.