From 3e446120d2439f09445a830bc7ba5cf067dcd8e4 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Thu, 11 Apr 2013 19:06:18 +0800 Subject: [PATCH] Fixed the function responsible for returning a list of fonts available --- lib.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib.php b/lib.php index f3e56da..be400cb 100644 --- a/lib.php +++ b/lib.php @@ -397,6 +397,9 @@ function customcert_get_fonts() { // Set the name of the font to null, the include next should then set this // value, if it is not set then the file does not include the necessary data. $name = null; + // Some files include a display name, the include next should then set this + // value if it is present, if not then $name is used to create the display name. + $displayname = null; // Some of the TCPDF files include files that are not present, so we have to // suppress warnings, this is the TCPDF libraries fault, grrr. @include("$fontdir/$font"); @@ -404,13 +407,17 @@ function customcert_get_fonts() { if (is_null($name)) { continue; } - // Format the font name, so "FontName-Style" becomes "Font Name - Style". - $formatname = preg_replace("/([a-z])([A-Z])/", "$1 $2", $name); - $formatname = preg_replace("/([a-zA-Z])-([a-zA-Z])/", "$1 - $2", $formatname); - $options[$name] = $formatname; - ksort($options); + // Remove the extension of the ".php" file that contains the font information. + $filename = basename($font, ".php"); + // Check if there is no display name to use. + if (is_null($displayname)) { + // Format the font name, so "FontName-Style" becomes "Font Name - Style". + $displayname = preg_replace("/([a-z])([A-Z])/", "$1 $2", $name); + $displayname = preg_replace("/([a-zA-Z])-([a-zA-Z])/", "$1 - $2", $displayname); + } + $options[$filename] = $displayname; } - + ksort($options); } return $options;