Graphics function Library: Imagettftext

Source: Internet
Author: User
Keywords imagettftext php Chinese function manual graphics function library
Tags aliyun array example function function library graphics graphics function library html

Imagettftext

(PHP3, PHP4)

Imagettftext---&http://www.aliyun.com/zixun/aggregation/37954.html ">nbsp; Write text to graphics using TrueType fonts

Syntax: array imagettftext (int im, int size, int angle, int x, int y, int col, string fontfile, string text)

Description:

Imagettftext () uses the TrueType font file Fontfile, in the graphics IM, in the coordinates x,y position, the angle is angle, draws the color col the string text.

The coordinate x,y will be defined as the datum point of the first character, unlike imagestring (), imagestring () is the upper-right corner defined as the first character.

Angle units are degrees, 0 degrees will read text from left to right (3 o'clock), while higher values indicate reverse clock rotation (for example: 90 degrees will result in text being read from bottom to top).

Fontfile is the path you want to use the TrueType font.

Text is a literal string that can contain UTF-8 contiguous characters (& #123的形式) to access characters other than the first 255 characters in the font.

Col is a color index, and using a negative color index closes antialiasing.

Imagettftext () returns an array of 8 elements, representing the four vertices of the text block, the order of the vertices is upper left, right, bottom right, bottom left, and vertices are relative to the text, so regardless of the angle. "Upper left" means that when you look at the upper-left corner of the text in a horizontal direction.

This example will produce a black gif 400x30 pixel graphic, and the white word "testing ..." font Arial.

Example:

<?php

Header ("Content-type:image/gif");

$im = Imagecreate (400, 30);

$black = imagecolorallocate ($im, 0, 0, 0);

$white = Imagecolorallocate ($im, 255, 255, 255);

Imagettftext ($im, 0, $white, "/path/arial.ttf", "Testing ... Omega: & #937; ");

Imagegif ($im); Imagedestroy ($im);

?>

This function requires the GD library and the FreeType library.

Reference: Imagettfbbox ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.