PHP-GD: Dealing with Unicode characters

Posted by sehugg on Stack Overflow See other posts from Stack Overflow or by sehugg
Published on 2010-05-21T02:42:59Z Indexed on 2010/05/21 2:50 UTC
Read the original article Hit count: 401

Filed under:
|
|
|

I am developing a web service that renders characters using the PHP GD extension, using a user-selected TTF font.

This works fine in ASCII-land, but there are a few problems:

  1. The string to be rendered comes in as UTF-8. I would like to limit the list of user-selectable fonts to be only those which can render the string properly, as some fonts only have glyphs for ASCII characters, ISO 8601, etc.

  2. In the case where some decorative characters are included, it would be fine to render the majority of characters in the selected font and render the decorative characters in Arial (or whatever font contains the extended glyphs).

It does not seem like PHP-GD has support for querying the font metadata sufficiently to figure out if a character can be rendered in a given font. What is a good way to get font metrics into PHP? Is there a command-line utility that can dump in XML or other parsable format?

© Stack Overflow or respective owner

Related posts about php

Related posts about php-gd