Re: Calculate string width using some font.
| From: | Juan Felipe Alvarez Saldarriaga | Date: | Mon, 05 Feb 2007 19:54:47 +0000 |
| Subject: | Re: Calculate string width using some font. | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-248374@lists.php.net to get a copy of this message | ||
setcookie wrote:
pdf_stringwidth() may help you regards fra*Yea I saw that too but you know, pdflib is not free.
atdetermineHey list! :)my name's not list but what the heck: take a look at these function, they should light the way: http://php.net/manual/en/function.imageftbbox.php http://php.net/manual/en/function.imagepsbbox.php http://php.net/manual/en/function.imagettfbbox.php http://php.net/imageloadfont everything is pixels. there is no dpi - your screen & printer has a certain dpi and thathow big the image displays on either. okay not much help - I had brain freeze half thru.K, np, Ill try use imagettfbbox() function instead. Thx.with some Y font size to use in an svg-to-pdf conversion. This is what I try to do: 1. Create a dummy image. 2. Set the text there using font X and the font size Y (it seems that when I create the image it renders it at 72dpi so I need to reduce itI've got a problem trying to calculate a string width using an X font
values300dpi) I'm not sure what the imagettftext() function returns, are those
100 );measured in pixels ?yes.the image at 300dpi is reduce the size to 24% of its original size. http://www.printingforless.com/resolution.html That's the code: *** // Create dummy image. $rsc_image = imagecreate( 1, 1 ); // Set image. $arr_ftx = imagettftext( $rsc_image, $int_font_size, 0, 0, 0, -1, "./fonts/{$str_font_file}", $str_variable_value ); // Destroy dummy image. imagedestroy( $rsc_image ); // Set structure of widths. // TODO: Magik numbers. $arr_variable_pixels[$str_variable_index] = ( ( $arr_ftx[2] * 24 ) /I read in some page that the proportion to reduce
*** Thx for any help.