2011-12-17 3 views
2

imagettftext()를 사용하여 텍스트 렌더링에 몇 가지 문제가 있습니다. 어쨌든 그냥 채워진 사각형을 보여줍니다. 오류가 전혀 없습니다. http://postimage.org/image/k61c8xi0n/imagettftext를 사용하는 동안 텍스트 대신 채워진 사각형

  • PHP 버전 : 5.3.8
  • GD 지원 : 사용
  • GD 버전 : 번들 (2.0.34 호환)
  • 하는 Freetype 지원 : 사용
  • 하는 Freetype 연동 : FreeType에서와
  • Freetype 버전 : 2.4.3

다음은 코드입니다. str은 없습니다. ange. 글꼴 경로가 작동합니다.

<?php 
header("Content-type: image/png"); 
$template = imagecreatefrompng("template.png"); 

imagealphablending($template, false); 
imagesavealpha($template, true); 

$white = imagecolorallocate($template, 255, 255, 255); 
imagettftext($template, 20, 0, 100, 50, $white, 'arial.ttf', 'Some text'); 

imagepng($template); 
?> 
+0

http://www.postimage.org/image/k61c8xi0n/ -> fonterror. 그렇지 않으면 더 많은 메모리를 할당하려고 시도하십시오. ini_set ('memory_limit', '256M'); –

+0

@ ZulkhaeryBasrul 이미 시도했지만 아무 것도 변경되지 않았습니다. 여전히 오류가 있습니다. 그리고 그것은 Arial입니다. – user1103838

답변

3

내가 true로 imagealphablending를 설정 한 경우, 코드를 사용하여 (또는 주석)이 잘 작동합니다.

+0

고마워요, 마침내 작동합니다! – user1103838

0

사용 :

$font = dirname(__FILE__)."/arial.ttf"; 
imagettftext($template, 20, 0, 100, 50, $white, $font, 'Some text'); 
관련 문제