2012-07-23 2 views
-1
/*create watermark*/ 

    // Create the image 
    $im = imagecreate(460, 50); 

    // Create some colors 
    $grey = imagecolorallocate($im, 230, 231, 232); 
    $dark_grey = imagecolorallocate($im, 128, 130, 133); 

    // The text to draw 
    $text = "foobar"; 

    // Set the enviroment variable for GD 
putenv('GDFONTPATH=' . realpath('.')); 

$font = 'Tondu_beta'; 



    // Add the text 
    imagettftext($im, 15, 0, 15, 35, $dark_grey, $font, $text); 


    $wm_w = imagesx($im); //get width 
    $wm_h = imagesy($im); //get height 

    $wmresource = $im; //watermark resource 

//imagejpeg($wmresource); 

/*end watermark*/ 

글꼴 파일은 Tondu_Beta.ttf입니다. 위의 코드는 로컬 컴퓨터에서 정상적으로 작동했지만 라이브 서버에 업로드 한 후에 회색 상자 만 제공했습니다. 여기 뭐가 잘못 됐니? 감사합니다 ^^imagettftext() 작동하지 않음

UPDATE는 : Could not find/open font bla.bla..bla...

+0

오류 로그를 확인하고 참조 글꼴 및 PHP 파일 모두 루트 디렉토리에있을 때

"./Tondu_beta.ttf" 

이 나를 위해 일한 사용해보십시오 . – ceejayoz

+0

라이브 서버에 글꼴이 없을 수 있습니다 ... – Palladium

+0

스크립트가 해당 폴더의 글꼴을 찾는 것을 알고 있습니까? – Palladium

답변

0

오류가 자기 설명이다 : 나는 그것이 나에게이 오류를 준 기억한다. 라이브 서버에 해당 글꼴 (Tondu_Beta.ttf)이 설치되어 있지 않습니다. 서버에 글꼴을 설치하거나 서버에있는 글꼴을 선택하십시오. 스트레이트 doc에서

0

:

fontfile

The path to the TrueType font you wish to use.

Depending on which version of the GD library PHP is using, when fontfile does not begin with a leading/then .ttf will be appended to the filename and the library will attempt to search for that filename along a library-defined font path.

When using versions of the GD library lower than 2.0.18, a space character, rather than a semicolon, was used as the 'path separator' for different font files. Unintentional use of this feature will result in the warning message: Warning: Could not find/open font. For these affected versions, the only solution is moving the font to a path which does not contain spaces.

In many cases where a font resides in the same directory as the script using it the following trick will alleviate any include problems.

<?php 
// Set the enviroment variable for GD 
putenv('GDFONTPATH=' . realpath('.')); 

// Name the font to be used (note the lack of the .ttf extension) 
$font = 'SomeFont'; 
?> 
+0

내 코드에 이미 코드가 있습니까? 내 GD 버전은 2.0.34 – siaooo

+0

아, 나는 그것을 놓쳤다. . . 그렇다면 글꼴 파일 이름의 대소 문자 차이가 다른 글꼴과 일치 할 것입니다. . . – ernie

1

관련 문제