我是Joomla dev和php的新手,如果我正在做一些愚蠢的事情,请告诉我!当Joomla内调用字体时,图片不显示
我在用户用他们的名字,日期等完成测验后创建了要打印的证书。我已将图像显示出来并显示文本,但是当我添加字体时什么也没有显示出来。
下面是我使用的基础脚本和作品(背景图像和字体的工作):
$image_file = 'images/certificate_page.png';
$my_img = imagecreatefrompng ($image_file);
$font_size_big = 24;
$text_colour = imagecolorallocate($my_img, 0, 0, 0);
$font_file = 'FelipaRegular.ttf';
imagefttext($my_img, $font_size_big, 0, 5, 75, $text_colour, $font_file, "test with font");
imagestring($my_img, 4, 30, 25, "test without font", $text_color);
header("Content-type: image/png");
imagepng($my_img);
imagecolordeallocate($text_color);
imagedestroy($my_img);
当我试图内的Joomla应用它的问题开始。
<img src="<?php echo JURI::root().'index.php?tmpl=certgenerator&quizmod='.$quizmod.'' ?>" />
和文件生成器(certgenerator.php):
defined('_JEXEC') or die;
require_once("includes/variables_certificate.php");
$image_file = JURI::root().'templates/'.$this->template.'/images/certificate_page.png';
$my_img = imagecreatefrompng ($image_file);
$font_size_big = 24;
$text_color = imagecolorallocate($my_img, 0, 255, 0);
$font_file = 'FelipaRegular.ttf';
imagefttext($my_img, $font_size_big, 0, 55, 75, $text_color, $font_file, "why u no work"); //if commented out image displays but not font obviously, as it's written now it returns a blank page
imagestring($my_img, 4, 30, 25, "works", $text_color); //works but doesn't include font
header("Content-type: image/png");
imagepng($my_img);
imagecolordeallocate($text_color);
imagedestroy($my_img);
参考:
http://php.net/manual/en/function.imagettftext.php
我已经试过imagettftext我是从这样的一个模板内调用它vs imagefttext,没有扩展名,带有扩展名,来自上面链接的一堆东西,所有相同的结果。有任何想法吗?我在猜测(并希望!)一些愚蠢的东西?
有效的字体文件在正确的目录中具有正确的权限? – 2012-07-27 04:56:04
这两个脚本与字体位于同一目录中;尽管它可能是Joomla中的路径问题。我试过了一堆不成功的路径 - Joomla会需要一个特定的路径或位置吗? – Gisto 2012-07-27 12:12:12