이미지 처리 및 GD imageloadfont
(PHP 4, PHP 5, PHP 7, PHP 8)
imageloadfont — 새 글꼴 로드
설명
imageloadfont(string $filename
): GdFont|false
imageloadfont()는 사용자 정의 비트맵을 로드하고 해당 식별자를 반환합니다.
매개변수
filename
- 글꼴 파일 형식은 현재 바이너리 및 아키텍처에 따라 다릅니다. 이것은 당신이 PHP를 실행하고 있는 머신과 같은 유형의 CPU에서 폰트 파일을 생성해야 한다는 것을 의미합니다.
글꼴 파일 형식
byte position C data type 설명 byte 0-3 int 글꼴의 문자 수 byte 4-7 int 글꼴의 첫 번째 문자 값(대개 공백의 경우 32) byte 8-11 int 각 문자의 픽셀 너비 byte 12-15 int 각 문자의 픽셀 높이 byte 16- char 총 (nchars*width*height) 바이트에 대해 각 문자의 픽셀당 1바이트 문자 데이터가 있는 배열입니다.
반환 값
GdFont 인스턴스를 반환하거나 실패 시 false
를 반환합니다.
변경 로그
버전 | 설명 |
---|---|
8.1.0 | 이제 GdFont 인스턴스를 반환합니다. 이전에는 int가 반환되었습니다. |
Examples
예제 #1 imageloadfont() 사용 예
<?php
// Create a new image instance
$im = imagecreatetruecolor(50, 20);
$black = imagecolorallocate($im, 0, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);
// Make the background white
imagefilledrectangle($im, 0, 0, 49, 19, $white);
// Load the gd font and write 'Hello'
$font = imageloadfont('./04b.gdf');
imagestring($im, $font, 0, 0, 'Hello', $black);
// Output to browser
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>
기타
- imagefontwidth() - 글꼴 너비 가져오기
- imagefontheight() - 글꼴 높이 가져오기