f



How do you generate an array of actual font names from your /fonts folder in PHP?

Consider my code:

[PHP]
	/**
	 * Set the TTF array property $ttfArray
	 *
	 * @access private
	 * @see actual_path
	 */
	function &setTTFArray() {					// STATIC VOID METHOD
		global $ttfPath;					// OBTAIN VAR FROM project_globals.inc.php
		if (is_dir($ttfPath)) {
		 $dirID = @opendir(actual_path($ttfPath));
		 while ($ttf = @readdir($dirID)) if
(@is_file(actual_path("$ttfPath/$ttf")) && preg_match('/\.ttf$/i',
$ttf)) @array_push($this->ttfArray, actual_path("$ttfPath/$ttf"));
		}
	}
[/PHP]

This will generate an array of TTF font names, however, the problem is
that it generates an array of TTF font FILE names, which is usually
utterly unreadable, at least unknowable, to the user.

How can I change it to be an array of the actual TTF font names and not
the literal TTF font FILE names?

The directory will be utterly dynamic as this is from a portable web
application.

Thanx
Phil

0
1/10/2007 7:16:23 AM
comp.lang.php 32646 articles. 0 followers. Post Follow

1 Replies
803 Views

Similar Articles

[PageSpeed] 16

comp.lang.php wrote:
> How can I change it to be an array of the actual TTF font names and
> not the literal TTF font FILE names?
>

When you are able to run Perl, the best thing you can do is to have a look 
at the Font::TTF::Name package, build a small perl script that uses its 
functionality and call the script from PHP through system/exec.

If you feel up to some extensive reading, here are the specs:

http://www.microsoft.com/typography/default.mspx


JW 


0
jw137 (829)
1/10/2007 2:20:22 PM
Reply: