��������� ������ ������� TrueType.
��������� :
array imageTTFText(int im, int size, int angle, int x, int y, int color, string fontfile, string text)
��� ������� �������� ������ text � ����������� im ������ color. ��� ������, color ������ ������������ ����� ���������� ������������� �����. �������� angle ������ ���� ������� � �������� ��������� ������, ������������� �� ����������� ������ ������� �������. ���������� (x, y) ��������� ��������� ��� ���������� ������� ����� ������ (������ ��� �� ����� ������ ����). �������� size ������ ������ ������, ������� ����� �������������� ��� ������ ������. fontfile ������ ��������� ��� TTF-�����, � ������� � ��������� �����.
������� ���������� ������ �� 8 ���������. ������ �� ���� ������ ���������� (x,y) �������� ������ ���� ��������������, ���������� ������ ������ ������ � �����������, ������ ���� - ���������� �������� ������� ����, � �.�. ��� ��� � ����� ������ ������ ����� ����� ����� ������ angle, ����� ��������� 4 ���� ���������.
������ ������ text ����� ��������� ���������� ������������������ UTF-8 (� ���� {) ��� ������ �������� � ������, �������� 255.
��� ������������� �������������� �������� ������� ����� color ����������� ����������� ������ (antialiasing).
������ ������� ������� ���������� GD � FreeType.
<?php header("Content-type: image/jpeg"); $im = imagecreate(400, 30); $white = imagecolorallocate($im, 255, 255, 255); $black = imagecolorallocate($im, 0, 0, 0); // Replace path by your own font path imagettftext($im, 20, 0, 10, 20, $black, "/path/arial.ttf", "Testing... Omega: Ω"); imagejpeg($im); imagedestroy($im); ?>��������� ������ ������� ������ �� ������ �������
<?php $gi = imageCreate(200,100); $bg = imageColorAllocate($gi,0,220,0); $tx = imageColorAllocate($gi,25,2,228); $w = imageSX($gi); // ������ ������� $h = imageSY($gi); // ������ ������� imageFilledRectangle($gi,0,0,$w,$h,$bg); $szf = 20; // ������ ������ $ang = 240; // ���� �������� ������ $str = "Heyou"; // ����� ������ $font = "symbol.ttf" // ���� ������ $sz = imageTTFBBox($szf,$ang,$font,$str); $sdx = $sz[4]/2; $sdy = ($sz[7]+$sz[3])/2; imageTTFText($gi,$szf,$ang,$w/2-$sdx,$h/2-$sdy,$tx,$font,$str); Header("Content-Type: image/png"); imagePng($gi,"file.png"); ?>
������ �������, ���������� ������� ������ TrueType.
��������� :
attay imageTTFBBox(int size, int angle, string fontfile, string text)
��� ������� ������ �� ������� � �����������, � ������ ����������, ����� ������ � ��������� ������ �� ������ ������ text ������� size, ���������� ��� ����� angle � �����-������ �������. �������� fontfile ������ ���������� ���� � ����� ������, ������� ����� ����������� ��� ������.
������������ ������ �������� ��� ���������� � �������� ������ � �������, ������� �� ���, ��� ������ ������� imageTTFText(). ������ ������� ����� � ��� ����������.
0 � 1 - (x,y) ������ ������� ����
2 � 3 - (x,y) ������� ������� ����
4 � 5 - (x,y) ������� �������� ����
6 � 7 - (x,y) ������ �������� ����
���������� ����� ����� ������������� ��������.
������� ������� ���������� GD � FreeType.
�������� �� ����� ������ PostScript Type 1.
��������� :
int imagePSLoadFont(string filename)
���������� ���������� ������������ ������ ��� FALSE ��� ������ (����� ��������� ��������������).
<?php header("Content-type: image/jpeg"); $im = imagecreate(350, 45); $black = imagecolorallocate($im, 0, 0, 0); $white = imagecolorallocate($im, 255, 255, 255); $font = imagepsloadfont("bchbi.pfb"); // or locate your .pfb files on your machine imagepstext($im, "Testing... It worked!", $font, 32, $white, $black, 32, 32); imagepsfreefont($font); imagejpeg($im, "", 100); //for best quality...your mileage may vary imagedestroy($im); ?>��� ������� �������� ������ � ��� ������, ���� PHP ��� ������������� � ������ --enable-t1lib.
�������� ������ PostScript Type 1.
��������� :
void imagePSFreeFont(int fontindex)
������ ������� ����������� ������ �� ������, ��������� ���������� fontindex.
��� ������� �������� ������ � ��� ������, ���� PHP ��� ������������� � ������ --enable-t1lib.
��������� ����� ������������� ������.
��������� :
int imagePSEncodeFont(int font_ndex, string encodingfile)
��������� ���� ������������� encodingfile ��� ������ font_index. ��������� ������ PostScript �� ��������� �� ���������� ������� � ������, �������� 127, ������������� ��������� ��� ������������� ������������� �� ����������� �����. ������ ����� ������ � ������������ Tllibs, ����� � ����������� ������������ 2 ������� �����: IsoLatinl.enc � IsoL.atin2.enc.
���� ������������� ������������ ���������, ���������� �������� ps.default_encoding � ����� ������������ �� ��������� ����� ����� �������������, ������� ����� ����������� �������������.
��� ������� �������� ������ � ��� ������, ���� PHP ��� ������������� � ������ --enable-t1lib.
��������������� ������.
��������� :
bool imagePsExtendFont (int font_index, float extend)
������� ���������� ���������� ��� ������ ������, ��������� ���������� font_index �� �������, ��������� ���������� extend.
���� �������� ��������� extend ������ 1, �� ����� ����� �����������.
��� ������� �������� ������ � ��� ������, ���� PHP ��� ������������� � ������ --enable-t1lib.
��������� ������� ������.
��������� :
bool imagePsSlantFont(int font_index, double slant)
������� ������������� ������ ������ font_index � ��������, �������� ���������� slant.
��� ������� �������� ������ � ��� ������, ���� PHP ��� ������������� � ������ --enable-t1lib.
������ �������, ���������� ������� ������ PostScript Type 1.
��������� :
array imagePSBBox( string text, int font, int size [, int space [, int tightness [, float angle]]])
������� ������������ �� ��������� ����������:
size - ������ ������ � ��������;
space � ��������� ������� �������� �� ��������� � ����������� (����� ���� �������������);
tightness � ���������� ����� ��������� �� ���������) � ����������� (����� ���� �������������);
angle � ���� ������� ������ � ��������.
�������� space � tightness ���������� � ����� ������� (1/1000).
��������� space, tightness, angle �� �����������.
���������� ������� ������������ �����. ������� ���������� ������:
��� ������� �������� ������ � ��� ������, ���� PHP ��� ������������� � ������ --enable-t1lib.
����� ������ ������ ������� ������� PostScript Type 1.
��������� :
array imagePSText ( resource image, string text, int font, int size, int foreground, int background, int x, int y [, int space [, int tightness [, float angle [, int antialias_steps]]]])
�������� size ������ ������ ������.
���������� x, � ��������� ����� ������ ���� ������� �������.
����������� foreground � background �������� ����� ������ � ���� (��� ��������� ������ ��� ����������� ������).
�������� antialias_steps ��������� ������� ����� ������, ������������ ��� ����������� ������ (���������� �������� 4 � 16). ��� ������� �������� ������ 20 ����������� ������� ��������, ��� ��� ��� �������� �������������; ��� ������� ������� ����������� ������� ��������, ��� ��� ��� ����������� ��������������.
�������� angle ������ ������ ������ � ��������.
������� ���������� ������, ������� imagepsbbox().
��� ������� �������� ������ � ��� ������, ���� PHP ��� ������������� � ������ --enable-t1lib.