https://github.com/mundschenk-at/php-typography
A PHP library for improving your web typography.
https://github.com/mundschenk-at/php-typography
composer-package css-hooks hyphenation php smartquotes typography
Last synced: 11 months ago
JSON representation
A PHP library for improving your web typography.
- Host: GitHub
- URL: https://github.com/mundschenk-at/php-typography
- Owner: mundschenk-at
- License: gpl-2.0
- Created: 2017-08-05T09:55:24.000Z (almost 9 years ago)
- Default Branch: main
- Last Pushed: 2024-06-15T19:02:43.000Z (almost 2 years ago)
- Last Synced: 2025-06-09T16:05:35.947Z (about 1 year ago)
- Topics: composer-package, css-hooks, hyphenation, php, smartquotes, typography
- Language: PHP
- Size: 8.66 MB
- Stars: 75
- Watchers: 5
- Forks: 6
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Roadmap: ROADMAP.md
Awesome Lists containing this project
README
# PHP-Typography

[](https://packagist.org/packages/mundschenk-at/php-typography)
[](https://sonarcloud.io/dashboard?id=mundschenk-at_php-typography)
[](https://sonarcloud.io/dashboard?id=mundschenk-at_php-typography)
[](https://packagist.org/packages/mundschenk-at/php-typography)
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:
```BASH
$ 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.
```PHP
$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](ROADMAP.md) file for upcoming releases.
## License
PHP-Typography is licensed under the GNU General Public License 2 or later - see the [LICENSE](LICENSE) file for details.