Questions tagged [imagettftext]
174 questions
27
votes
5 answers
Right align text in an image with imagettftext(), PHP
I am setting up dynamic forum signature images for my users and I want to be able to put their username on the image. I am able to do this just fine, but since usernames are different lengths and I want to right align the username, how can I go…

James Simpson
- 13,488
- 26
- 83
- 108
24
votes
10 answers
20
votes
4 answers
Aligning php Generated Image dynamic text in center
i want to align the text generated on the image to the center of the image. for the moment, i dont know if it is possible to align it. below is the code.
$im = @imagecreatefromjpeg('poloroid.jpg');
// Create some colors
$white =…

Shazery Nasir
- 281
- 1
- 6
- 16
17
votes
1 answer
imagettfbbox calculates wrong rectangle when text begins with number
The issue is, that when using imagettfbbox to calculate text dimensions, too small rectangle is returned when input text begins with numbers. This is my code:
$fontSize = 150;
$font = "font/courier_new.ttf";
$text = $_GET["text"];
//Determine font…

Tomáš Zato
- 50,171
- 52
- 268
- 778
16
votes
4 answers
make text string read from right to left in imagettftext() function
I want to write a text string from right to left instead of from left to right with the imagettftext (); function
I read in the manual that the angle variable controls this, it says that 0 angle means left to right, so I tried 180, 360 but nothing…

Ahmad Sattar
- 321
- 2
- 10
12
votes
2 answers
Error while writting Arabic to image
My previous related question:
php work with images : write complete word in arabic , ttf font
My problem was:
If I want to write احمد in image it appears as د م ح ا
Well, I fixed it and now the output: ا ح م د
Using this function:
function…

Passer By
- 181
- 1
- 11
11
votes
2 answers
Text out of the box for converting into image in php
I am trying to convert text into image. I already did it, but the are some cases when text is out of the image box
The "e" of the word "The" is cut. I have tried decreasing the font size or increasing the width of the image, but in some cases this…

Luis
- 325
- 4
- 20
10
votes
2 answers
Font that supports all utf-8 characters for php imagettftext
I'm using imagettftext in php to generate images. Is there a true type font that supports all utf-8 characters?

Tom Kincaid
- 4,887
- 6
- 47
- 72
9
votes
2 answers
PHP imagettftext baseline workaround
I am writing to print text to an image using PHP. However, the function imagettftext() uses the baseline, whereas I need the text vertically centered.
So, I either need a method to print text with y not the distance from top to baseline, but from…

arik
- 28,170
- 36
- 100
- 156
9
votes
5 answers
PHP - imagettftext not working and GD installed
It's being long hours that I'm still looking for answer to this problem..
All the solutions I find are around catching the font name but I am pretty sure this isn't my problem.
It looks like GD is installed
array(11) {
["GD Version"]=>
…

Steve Peretz
- 91
- 1
- 1
- 2
8
votes
4 answers
Using the imagettftext function with multiple lines?
I'm creating transparent text -> png images with php and so far so good. The only problem is that I want the ability to have the text word wrap due to a fixed width.. Or alternatively be able to insert breaklines into the text. Has anyone had any…

ionfish
- 151
- 1
- 4
- 9
7
votes
6 answers
php imagettftext letter spacing
Does anybody have a function that draws a ttf string (imagettftext) with specified letter spacing?
I cannot find any build-in GD function so I think that it should be done letter by letter adding some constant width.
Maybe someone have such function…

radzi0_0
- 1,250
- 2
- 14
- 24
7
votes
4 answers
imagettftext cannot open font file
Using the example from php.net I get a warning, and the image is not rendered correctly. I supply a full path to the .ttf file like so: /var/www/public/myfont.ttf
PHP Warning: imagettftext() [

Jon Skarpeteig
- 4,118
- 7
- 34
- 53
7
votes
3 answers
PHP imagefttext (imagettftext) not displaying anything
I'm almost positive that there is a stupid reason this is not working, but I just can't figure this one out. I'm just trying to print out some text as a graphic with imagettftext, but I can't get the words to display. This is on a GoDaddy server,…

SenorPuerco
- 871
- 3
- 9
- 19
7
votes
5 answers
PHP function imagettftext() to write text with smileys
I am using imagettftext function to write text on image but my text contain smileys and it replace smileys to square box
Here is mycode:
$black = imagecolorallocate ( $main_img, 0x00, 0x00, 0x00 );
$font_path = "Arial.ttf";
imagettftext ( $main_img,…

Bhumi Shah
- 9,323
- 7
- 63
- 104